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
Payment product code assigned by Rebell.
Merchant-generated unique identifier (idempotency key). Max length : 64 characters
Payment amount details. ISO-4217 currency code (e.g., EUR)
Access token obtained from the authorization flow. Max length : 128 characters
Order details. Description shown in user’s transaction history
Webhook URL for payment notifications.
Response Parameters
Rebell payment identifier
Echo of merchant payment request ID
Payment completion time (ISO 8601)
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
resultStatus resultCode Description Action SSUCCESSPayment successful Update subscription status FINVALID_ACCESS_TOKENToken invalid or expired Re-authorize user FINSUFFICIENT_BALANCEUser has insufficient funds Notify user, retry later FRISK_REJECTRejected by risk system Contact user FUSER_NOT_EXISTUser not found Check access token UPAYMENT_IN_PROCESSPayment processing Poll 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:
Identify Failure Reason
Check the resultCode to understand why the payment failed
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
Retry Strategy
Implement a retry schedule (e.g., retry after 1, 3, 7 days)
Grace Period
Maintain service during grace period while retrying
Apply Token Get access tokens for agreement payments
Inquiry Payment Check payment status