Skip to main content
POST /v2/payments/pay Initiates a payment using a previously authorized agreement (subscription payment). This endpoint is used for recurring payments where the user has already signed a payment agreement.

Use Case

After a user signs a payment agreement via the authorization flow, you can charge them automatically without requiring interaction:
  • Monthly subscriptions
  • Recurring billing
  • Scheduled payments
  • Usage-based charges

Request Parameters

productCode
string
required
Payment product code assigned by Rebell.
paymentRequestId
string
required
Merchant-generated unique identifier (idempotency key).Max length: 64 characters
paymentAmount
object
required
Payment amount details.
accessToken
string
required
Access token obtained from the authorization flow.Max length: 128 characters
order
object
Order details.
paymentNotifyUrl
string
Webhook URL for payment notifications.

Response Parameters

result
object
required
Standard result object
paymentId
string
Rebell payment identifier
paymentRequestId
string
Echo of merchant payment request ID
paymentTime
string
Payment completion time (ISO 8601)
paymentAmount
object
Confirmed payment amount

Example Request

{
  "productCode": "5105010010000100040",
  "paymentRequestId": "SUB-20240110-001",
  "paymentAmount": {
    "currency": "EUR",
    "value": "999"
  },
  "accessToken": "281010033AB2F588D14B43238637264FCA5AAF35xxxx",
  "order": {
    "orderDescription": "Premium subscription - January 2024"
  },
  "paymentNotifyUrl": "https://merchant.example.com/webhooks/payment"
}

Example Response

{
  "result": {
    "resultCode": "SUCCESS",
    "resultStatus": "S",
    "resultMessage": "success"
  },
  "paymentId": "2024011012345678901234",
  "paymentRequestId": "SUB-20240110-001",
  "paymentTime": "2024-01-10T00:01:00+01:00",
  "paymentAmount": {
    "currency": "EUR",
    "value": "999"
  }
}

Result Codes

resultStatusresultCodeDescriptionAction
SSUCCESSPayment successfulUpdate subscription status
FINVALID_ACCESS_TOKENToken invalid or expiredRe-authorize user
FINSUFFICIENT_BALANCEUser has insufficient fundsNotify user, retry later
FRISK_REJECTRejected by risk systemContact user
FUSER_NOT_EXISTUser not foundCheck access token
UPAYMENT_IN_PROCESSPayment processingPoll with inquiryPayment

Implementation Example

class SubscriptionBilling {
  async processMonthlyBilling(subscription) {
    const paymentRequestId = `SUB-${subscription.id}-${Date.now()}`;

    try {
      // Ensure we have a valid access token
      const accessToken = await tokenManager.getValidAccessToken(
        subscription.userId
      );

      const response = await rebellAPI.pay({
        productCode: process.env.REBELL_PRODUCT_CODE,
        paymentRequestId,
        paymentAmount: {
          currency: 'EUR',
          value: String(subscription.priceInCents)
        },
        accessToken,
        order: {
          orderDescription: `${subscription.planName} - ${getCurrentMonth()}`
        },
        paymentNotifyUrl: `${process.env.BASE_URL}/webhooks/payment`
      });

      if (response.result.resultStatus === 'S') {
        await this.recordPayment(subscription.id, {
          paymentId: response.paymentId,
          amount: subscription.priceInCents,
          status: 'success'
        });
        return { success: true };
      }

      if (response.result.resultStatus === 'U') {
        // Payment processing - will be confirmed via webhook
        return { success: false, pending: true, paymentId: response.paymentId };
      }

      // Payment failed
      return {
        success: false,
        error: response.result.resultCode,
        message: response.result.resultMessage
      };

    } catch (error) {
      await this.recordPaymentFailure(subscription.id, error);
      throw error;
    }
  }
}

Handling Payment Failures

When a subscription payment fails:
1

Identify Failure Reason

Check the resultCode to understand why the payment failed
2

Take Appropriate Action

  • INSUFFICIENT_BALANCE: Notify user, schedule retry
  • INVALID_ACCESS_TOKEN: Prompt user to re-authorize
  • RISK_REJECT: Contact user, may need manual review
3

Retry Strategy

Implement a retry schedule (e.g., retry after 1, 3, 7 days)
4

Grace Period

Maintain service during grace period while retrying

Apply Token

Get access tokens for agreement payments

Inquiry Payment

Check payment status