Integration Guide

Everything you need to accept payments on your website in minutes.

1 Installation

Add the RR Pay SDK to your website by including this script just before the closing </body> tag:

<script src="https://pay.yourdomain.com/sdk/rrpay.js"></script>

2 Initialize SDK

Initialize the SDK with your merchant key:

RRPay.init('pk_live_YOUR_MERCHANT_KEY');
Test vs Live Keys

Use pk_test_... for development and pk_live_... for production.

3 Accept Payments

One-Time Payment

<div id="pay-button"></div>

<script>
  RRPay.init('pk_live_YOUR_KEY');

  RRPay.createButton('#pay-button', {
    amount: 99.99,
    description: 'Product Name',
    onSuccess: function(result) {
      console.log('Paid!', result.sessionId);
      window.location.href = '/thank-you';
    }
  });
</script>

Subscription (Recurring)

<div id="subscribe-button"></div>

<script>
  RRPay.init('pk_live_YOUR_KEY');

  RRPay.createSubscriptionButton('#subscribe-button', {
    amount: 29.99,
    interval: 'month',
    trialDays: 14,
    onSuccess: function(result) {
      console.log('Subscribed!', result.subscriptionId);
      console.log('Status:', result.status); // 'trialing' or 'active'
    }
  });
</script>

Billing Intervals

Configure how often customers are billed with flexible interval options:

Interval Code Example
Weekly interval: 'week' $9.99/week
Monthly interval: 'month' $29.99/month
Yearly interval: 'year' $299/year
Bi-weekly interval: 'week', intervalCount: 2 $19.99 every 2 weeks
Quarterly interval: 'month', intervalCount: 3 $79.99 every 3 months

Free Trials

Offer customers a free trial period before charging:

RRPay.createSubscriptionButton('#btn', {
  amount: 49.99,
  interval: 'month',
  trialDays: 14  // 14-day free trial
});
How trials work
  1. Customer enters card details (validated, not charged)
  2. Trial period begins immediately
  3. First charge happens automatically when trial ends
  4. Customer can cancel anytime during trial

Setup Fees

Charge a one-time setup fee along with the recurring subscription:

RRPay.createSubscriptionButton('#btn', {
  amount: 49.99,        // Monthly recurring amount
  interval: 'month',
  setupFee: 99.00       // One-time fee charged today
});

Managing Subscriptions

// Get subscription status
const sub = await RRPay.getSubscription('sub_abc123');
console.log(sub.status);  // 'active', 'trialing', 'canceled', etc.

// Cancel subscription (at end of billing period)
await RRPay.cancelSubscription('sub_abc123');

// Cancel immediately
await RRPay.cancelSubscription('sub_abc123', { cancelAtPeriodEnd: false });

// Update payment method (opens modal)
await RRPay.updatePaymentMethod('sub_abc123');

API Options

One-Time Payment Options

OptionTypeDescription
amountnumberAmount in dollars (e.g., 99.99)
descriptionstringWhat the payment is for
customerEmailstringPre-fill email field
orderIdstringYour order/invoice ID
metadataobjectCustom data returned in webhooks
onSuccessfunctionCalled on successful payment
onErrorfunctionCalled on failure/cancel

Subscription Options

OptionTypeDescription
amountnumberAmount per billing cycle
intervalstring'week', 'month', or 'year'
intervalCountnumberFor custom intervals (default: 1)
trialDaysnumberFree trial period in days
setupFeenumberOne-time setup fee
planIdstringYour plan identifier
customerEmailstringPre-fill email
metadataobjectCustom data
onSuccessfunctionCalled on success
onErrorfunctionCalled on failure

Webhooks Optional

Receive real-time notifications when payment events occur. Contact us to configure your webhook URL.

Event Types

// One-time payment completed
{
  "type": "checkout.completed",
  "data": {
    "sessionId": "cs_abc123",
    "orderId": "order_456",
    "amount": 9999,
    "status": "complete"
  }
}

// Subscription created
{
  "type": "subscription.created",
  "data": {
    "subscriptionId": "sub_xyz789",
    "status": "trialing",
    "currentPeriodEnd": "2024-02-15T00:00:00Z"
  }
}

// Recurring payment successful
{
  "type": "invoice.paid",
  "data": {
    "subscriptionId": "sub_xyz789",
    "amount": 2999
  }
}

// Payment failed
{
  "type": "invoice.payment_failed",
  "data": {
    "subscriptionId": "sub_xyz789",
    "error": "Card declined"
  }
}

Testing

Use test credentials to verify your integration before going live:

Test Credentials

API Key pk_test_...
Card Number 4111 1111 1111 1111
Expiry Date Any future date (e.g., 12/28)
CVV Any 3 digits (e.g., 123)

Complete Example

Here's a full working example you can copy and customize:

<!DOCTYPE html>
<html>
<head>
    <title>Checkout</title>
</head>
<body>
    <h1>Pro Plan - $29.99/month</h1>
    <p>Start with a 14-day free trial</p>

    <div id="subscribe-btn"></div>

    <script src="https://pay.yourdomain.com/sdk/rrpay.js"></script>
    <script>
        RRPay.init('pk_live_YOUR_KEY');

        RRPay.createSubscriptionButton('#subscribe-btn', {
            amount: 29.99,
            interval: 'month',
            trialDays: 14,
            customerEmail: 'customer@example.com',

            onSuccess: function(result) {
                // Subscription created!
                console.log('ID:', result.subscriptionId);
                console.log('Status:', result.status);

                // Redirect to your app
                window.location.href = '/welcome?sub=' + result.subscriptionId;
            },

            onError: function(error) {
                console.log('Cancelled or failed');
            }
        });
    </script>
</body>
</html>

Need Help?

We're here to help you get integrated quickly:

Common Questions

How much do I earn?

Estimated earnings:

  • Traditional processing: ~$97 per $10,000 in volume
  • "Fees Included" program: ~$140 per $10,000 in volume

Understanding the fees

When a customer pays with a card, the fee has three parts:

Component Who sets it Negotiable?
Interchange Card networks (Visa/MC) & issuing banks No
Card brand fees Visa/Mastercard No
Processor markup The processor Yes

Why rates vary

Your actual costs depend on card type:

  • Basic credit cards: ~1.8% - 2.1%
  • Rewards/premium cards: ~2.0% - 2.6%
  • Corporate cards: Even higher

Plus a small per-transaction fee.

Recommended pricing

Charge a minimum of 3.79% + $0.30 per transaction

This is competitive and provides healthy margin. For "Fees Included" (fees passed to customer), you can charge slightly higher.

Bottom line: Sell on service quality, not price. Most of the fee goes to card networks - processor margins are thin.