This topic describes how to integrate payout requests into your website or checkout flow using the Rebilly API.
Use this integration to create payout requests on behalf of customers using the API, then redirect customers to a Rebilly-hosted payout form where customers select or add a payment instrument for the payout, rather than embedding the form on your website.
To integrate an embedded withdrawal form using the Cashier JavaScript library, where customers enter a withdrawal amount, choose a payment instrument, and submit the withdrawal, see Integrate a withdrawal form.
Prerequisites
Complete this section to configure your payment gateway and obtain the resources needed for this guide: an active payment gateway with the ready to payout instruction, a website ID, an organization ID, a secret API key, and a customer ID. If you already have these resources, skip this section and go to Create a payout request using the API.
To process payout requests, the ready to payout instruction must be active on at least one payment gateway.
If you are testing in the sandbox environment and using the TestProcessor gateway, you must manually configure this setting on the TestProcessor gateway.
For more information, see Configure a gateway to manage payout requests.
When you first log in to Rebilly, you create an organization as part of the setup process. A default website is created when a new organization is created. For more information, see Organizations and websites.
- Log in or sign up to Rebilly.
- Obtain your organization ID and website ID:
- In the left navigation bar, press Settings.
- In the Management section, press My organization & websites.
- In the Organization details section, note the ID value.
- In the Website section, note the ID value. For more information, see Organizations and websites.
- Obtain your secret API key:
- In the left navigation bar, press Automations.
- In the Development section, press API keys.
- Optionally, if you have not created a secret key:
- In top right of the page, press Create API key.
- In the Description field, enter a recognizable name for the key.
- In the Type section, select Secret.
- Optionally, in the Organizations dropdown, select the organizations that can use the API key.
- Optionally, in the Allowed IPs field, enter the IP addresses that are permitted to use the API key.
- Press Save API key.
- Go to the API keys page.
- Select a secret key and copy the Key value.
This step creates or updates (upserts) a customer with a specified ID.
This operation prevents duplicate customers. If the customer already has an identifier within your system, that customer is updated. If the customer does not have an identifier, a new customer is created.
For more information, see Upsert a customer.
Interactive example
How to use the interactive example
- Enter your organization ID:
- Locate and press
server /, then in the Server variables section, press . - In the Value field, enter your organization ID and press Save.
- Locate and press
- Enter your secret API key:
- Press Security.
- In the API key field, enter your secret Rebilly sandbox API key. For more information, see Prerequisites.
- Enter a customer ID:
- Press Path.
- In the input field, enter a customer ID. Example:
cus_01HDP7FFX2PGDVH1995EA4QY95.
- Enter your website ID:
- Press Body.
- In the
websiteIdfield, enter your website ID. - Optionally, change the customer details.
- Press Send.
Theidvalue from this response is used as thecustomerIdvalue when creating the payout request in Step 1. Create a payout request.
This process describes how to create a payout request using the Rebilly API.
This step creates a payout request using the customer that you created in the previous step.
In the response, the selectPaymentInstrumentUrl field contains the URL of the hosted payout form. Redirect the customer to this URL to select or add a preferred payment instrument on which to receive the payout.
For more information, see Create a payout request.
Interactive example
How to use the interactive example
- Enter your organization ID:
- Locate and press
server /, then in the Server variables section, press . - In the Value field, enter your organization ID and press Save.
- Locate and press
- Enter your secret API key:
- Press Security.
- In the API key field, enter your secret Rebilly sandbox API key.
For more information, see Prerequisites.
- Enter the payout request details:
- Press Body.
- In the
websiteIdfield, enter a website ID. - In the
customerIdfield, enter a customer ID. - In the
currencyfield, enter a currency code. - In the
amountfield, enter an amount that is less than50.The amount must be less than
50to complete the process in the sandbox environment.
- Press Send.
In the response, theselectPaymentInstrumentUrlfield contains the URL of the hosted payout form. In the next step, redirect the customer to the hosted payout form.
Redirect the customer to the hosted payout form using the selectPaymentInstrumentUrl URL from Step 1. In the hosted payout form, the customer selects or adds a preferred payment instrument on which to receive the payout. For test payment card details, see Test cards, IBANs, and ACH details.
This process describes how to allocate a payout to a customer's payment instrument using the Rebilly API.
Payouts can also be allocated using the Rebilly UI. For more information, see Allocate funds.
This step retrieves the payout request you created in Step 1. Create a payout request, after the customer added or selected a payment instrument in the hosted payout form.
For more information, see Retrieve a payout request.
Interactive example
How to use the interactive example
- Enter your organization ID:
- Locate and press
server /, then in the Server variables section, press . - In the Value field, enter your organization ID and press Save.
- Locate and press
- Enter your secret API key:
- Press Security.
- In the API key field, enter your secret Rebilly sandbox API key.
For more information, see Prerequisites.
- Enter a payout request ID:
- Press Path.
- In the input field, enter a payout request ID.
- In the Value field, enter the
idvalue from the response in Create a payout request. This is the payout request ID.
- Press Send.
In the response, thepaymentInstrumentIdfield contains the ID of the payment instrument on which the customer would prefer to receive the payout.
This step processes the payout request by allocating an amount to a credit transaction. This amount is transferred to the customer's payment instrument. The customer has indicated their preference, but the funds may be sent to any applicable payment instrument held by the customer.
For more information, see Create a credit transaction.
Interactive example
How to use the interactive example
- Enter your organization ID:
- Locate and press
server /, then in the Server variables section, press . - In the Value field, enter your organization ID and press Save.
- Locate and press
- Enter your secret API key:
- Press Security.
- In the API key field, enter your secret Rebilly sandbox API key.
For more information, see Prerequisites.
- Enter the details of the payout request:
- Press Body.
- In the
websiteIdfield, enter thewebsiteIdvalue from Retrieve a payout request. - In the
customerIdfield, enter theidvalue from Retrieve a payout request.
Use the customer ID you obtained in Retrieve a payout request. - In the
currencyfield, enter the currency code value from Retrieve a payout request. - In the
amountfield, enter the amount value from Retrieve a payout request. - In the
paymentInstrumentIdfield, to use the customer's preferred payment instrument, use the value you obtained in the response in Retrieve a payout request. Or select another payment instrument held by the customer.
Use the payment instrument ID you obtained in Retrieve a payout request. - Optionally, if you would like to use a specific payment gateway: in the
gatewayAccountIdfield, enter the ID of the gateway.The amount must be less than
50to complete the process in the sandbox environment.
- Press Send.
In the response, thestatusfield value iscompleted, and theresultvalue isapproved. This payout was successful.
This process describes how to cancel a payout request with a specified ID using the Rebilly API.
A payout request can be canceled when it is in the pending, ready, approved, or in-progress status.
For more information, see Cancel a payout request.
Interactive example
How to use the interactive example
- Enter your organization ID:
- Locate and press
server /, then in the Server variables section, press . - In the Value field, enter your organization ID and press Save.
- Locate and press
- Enter your secret API key:
- Press Security.
- In the API key field, enter your secret Rebilly sandbox API key.
For more information, see Prerequisites.
- Enter a payout request ID:
- Press Path.
- In the input field, enter a payout request ID. Use the payout request ID you obtained in Step 1. Create a payout request.
- Press Send.
In the response, thestatusfield value iscanceled. This indicates that the payout request is canceled.