Skip to main content
POST /v2/authorizations/prepare The prepare endpoint is used to set up contract information for agreement payment scenarios. It returns an authorization URL that the user visits to sign the payment agreement.

Use Case

Use this endpoint when implementing subscription or recurring payment flows:
  1. User wants to set up automatic payments
  2. You call prepare to create the contract terms
  3. User is redirected to the authorization URL
  4. User reviews and signs the agreement in the Rebell app
  5. You receive an authCode via callback
  6. Exchange the authCode for an accessToken using applyToken

Request Parameters

referenceClientId
string
required
Identifier to distinguish merchant businesses.Max length: 16 characters
scopes
string
required
Authorization scope. Use AGREEMENT_PAY for agreement payment scenarios.Max length: 16 characters
extendInfo
string
JSON string containing additional contract configuration.Max length: 4096 characters

Response Parameters

result
object
required
Standard result object with resultCode, resultStatus, resultMessage
authUrl
string
Authorization URL for the user to sign the contract. Pass this URL to my.call("signContract") JSAPI or redirect the user to it.Max length: 256 characters

Example Request

{
  "referenceClientId": "305XST2CSG0N4P0xxxx",
  "scopes": "AGREEMENT_PAY",
  "extendInfo": "{\"contractTitle\":\"Monthly Subscription\",\"contractDesc\":\"Automatic payment of €9.99 on the 1st of each month for Premium membership.\",\"agreedAmount\":{\"currency\":\"EUR\",\"value\":\"999\"},\"startTime\":\"2025-02-01\",\"contractStatusNotifyUrl\":\"https://merchant.example.com/webhooks/contract-status\"}"
}

Example Response

{
  "result": {
    "resultCode": "SUCCESS",
    "resultStatus": "S",
    "resultMessage": "success"
  },
  "authUrl": "https://wallet.rebellapp.com/auth?authId=xxxxx"
}

Result Codes

resultStatusresultCodeDescriptionAction
SSUCCESSContract prepared successfullySave authUrl for user redirection
FPARAM_ILLEGALInvalid parametersCheck request parameters
FINVALID_AUTH_CLIENTInvalid auth client IDVerify your referenceClientId
FINVALID_AUTH_CLIENT_STATUSAuth client status invalidContact support

Implementation Example

async function prepareAgreementPayment(userId, plan) {
  const extendInfo = {
    contractTitle: `${plan.name} Subscription`,
    contractDesc: `Automatic payment of €${(plan.price / 100).toFixed(2)} ${plan.frequency} for ${plan.name}.`,
    agreedAmount: {
      currency: 'EUR',
      value: String(plan.price)
    },
    startTime: getNextBillingDate(),
    contractStatusNotifyUrl: `${process.env.BASE_URL}/webhooks/contract-status`
  };

  const response = await rebellAPI.call('/v2/authorizations/prepare', {
    referenceClientId: userId,
    scopes: 'AGREEMENT_PAY',
    extendInfo: JSON.stringify(extendInfo)
  });

  if (response.result.resultStatus === 'S') {
    // Store authUrl for this user/subscription
    await saveAuthUrl(userId, plan.id, response.authUrl);
    return response.authUrl;
  }

  throw new Error(`Prepare failed: ${response.result.resultMessage}`);
}

Next Steps

After the user completes authorization at the authUrl, you’ll receive an authCode via your callback. Use it with:

Apply Token

Exchange the authorization code for an access token