This topic describes how to integrate a Rebilly hosted deposit form into your website, or checkout flow, using the Rebilly API.
Rebilly hosted deposits provide a secure and compliant way to deposit funds. Deposit forms use fully responsive design, built-in error messaging, and validation. The creation of hosted deposit forms is limited to one per organization. Use Rebilly hosted deposits to control deposit amounts that are presented to the customer and to process the deposit.
Optionally, use deposit strategies to determine the amounts presented to the customer. Deposit strategies filter deposit requests by currency, customer segmentation (tags), or prior deposit behavior. If a deposit request matches several strategies, a strategy is randomly selected.
To complete this tutorial, you need a Rebilly account, a website ID, an organization ID, a secret API key, and a customer ID. You must also have at least one payment gateway configured in your Rebilly account. If you are testing in the sandbox environment, a test payment gateway called TestProcessor
is already configured.
Payment methods that are displayed in the hosted deposit form are based on the gateway configuration. For more information, see Set up a payment gateway.
Obtain your organization ID, website ID, and secret API key
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 screen, press Create API key.
- In the API key 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.
Configure a payment gateway
To set up or configure a payment gateway, see Set up a payment gateway.
Create a customer
This example creates or updates (upserts) a customer with a specified ID. 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 detailed information about this API operation, see Upsert a customer.
How to use the interactive example
- Select the sandbox server environment:
- In the top right of the interactive example, press the Environment dropdown.
- Select Sandbox server.
- Enter your organization ID:
- Locate
server /customers/{id}
press . - In the Server variables section, press Edit.
- In the Value field, enter your organization ID and press Save.
- Locate
- Enter your secret API key:
- Press Security.
- In the API key field, press
{{SecretApiKey}}
, then press Set value. - In the Value field, enter your secret Rebilly sandbox API key and press Save. For more information, see Prerequisites.
- Enter a customer ID:
- In the URL field beneath the Environment field, press
{{id}}
. - Press Set value.
- In the Value field, enter a customer ID.
Example:cus_01HDP7FFX2PGDVH1995EA4QY95
.
- In the URL field beneath the Environment field, press
- Enter your website ID:
- Press Body.
- In the
websiteId
, enter your website ID. - Optionally, change the customer details.
- Press Send.
Theid
value from this response is used as thecustomerId
value when creating the deposit request in Step 2. ThewebsiteId
value is also used in Step 2.
This step creates a deposit strategy. Use deposit strategies to determine the amounts presented to the customer. Deposit strategies filter deposit requests by currency, customer segmentation (tags), or prior deposit behavior. If a deposit request matches several strategies, a strategy is randomly selected.
Deposit strategies are optional. You do not need to create a deposit strategy to create a deposit request.
For detailed information about this API operation, see Create a deposit strategy.
Interactive example
This example creates a deposit strategy that displays buttons for deposit amounts of $10, $20, $30, and $40. The strategy supports custom deposits between $10 and $1000, with a minimum of $10 and a multiple of $10. The strategy does not adjust the base amount to the last deposit.
How to use the interactive example
- Enter your organization ID:
- Beneath the Environment field, press
{{server}}
. - Beneath the URL, press Show nested variables, then press Edit.
- In the Value field, enter your organization ID and press Save.
- Beneath the Environment field, press
- Enter your secret API key:
- Press Security.
- In the API key field, press
{{SecretApiKey}}
, then press Set value. - In the Value field, enter your secret Rebilly sandbox API key and press Save. For more information, see Prerequisites.
- Enter strategy details:
- Press Body.
- In the
name
field, enter a strategy name.
Example:Test strategy
. - In the
amounts
field, specify the amounts to display as buttons in the deposit form.
Example:{"calculator": "absolute", "baseAmount": 10.00, "increments": [10.00, 20.00, 30.00], "adjustBaseToLastDeposit": false}
. - Optionally, in the
customAmount
field, specify the custom amount limits.
Example:{"minimum": 10.00, "multipleOf": 10.00, "maximum": 1000.00}
.
- Press Send.
Use theid
value from this response as thestrategyId
value when creating the deposit request in Step 2.
This step creates a deposit request using the customer that you created and the website ID that you obtained in the previous step. When the customer opens the URL included in the response, a Rebilly hosted deposit form is displayed to complete the deposit.
In the response, in the _links
field, under "rel": "deposit"
, the href
field contains the deposit URL.
For detailed information about this API operation, see Create a deposit request.
Interactive example
This example creates a deposit request using the customerId
value you created in the previous step.
How to use the interactive example
- Select the sandbox server environment:
- In the top right of the interactive example, press the Environment dropdown.
- Select Sandbox server.
- Enter your organization ID:
- Locate
server /deposit-requests
press . - In the Server variables section, press Edit.
- In the Value field, enter your organization ID and press Save.
- Locate
- Enter your secret API key:
- Press Security.
- In the API key field, press
{{SecretApiKey}}
, then press Set value. - In the Value field, enter your secret Rebilly sandbox API key and press Save. For more information, see Prerequisites.
- Enter the deposit details:
- Press Body.
- In the
customerId
field, enter theid
of a customer. To create a customer, see Prerequisites. - In the
websiteId
field, enter your website ID. - Optionally, to apply a specific strategy for the request, use the
strategyId
field. To create a strategy, see Step 1. - Optionally, to apply a deposit amount limit, in the
amountLimits
field, specifyminimum
andmaximum
amount values. Limits overrideamounts
andcustomAmount
values.
- Press Send.
In the response, in the_links
field, under"rel": "deposit"
, thehref
field contains the deposit URL. The value is used to redirect the customer to the deposit form in Step 3.
Redirect the customer to the deposit URL that you created in Step 2. After completing the deposit form, the hosted payment form is displayed to complete the deposit.