These docs are intended for a developer audience.
Create a payment form using the Rebilly API
This tutorial describes how use the Rebilly API to create a customer, an order, and process a payment using a hosted payment form in the sandbox environment.
Rebilly hosted payment forms simplify the process of accepting payments. Rebilly hosts your payment form and ensures that your payments process is secure and PCI compliant.
Prerequisites
Complete this section to interact with your Rebilly sandbox in the interactive examples in this tutorial, and to use your own data.
To complete a payment using a Rebilly payment form:
- An active gateway is required. If you are testing in the sandbox environment, a test payment gateway called
TestProcessor
is already configured. - The ready to payout instruction must be active and configured on the gateway. This setting must be manually configured on the
TestProcessor
gateway. For more information, see set up a payment gateway.
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, click Settings .
- In the Management section, click 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, click Automations .
- In the Development section, click API keys.
- Optionally, if you have not created a secret key:
- In top right of the screen, click Add API.
- In the API key type section, select Secret, then complete the form and click Save API key.
- Go back to the API Keys page.
- Select a secret key and copy the Key value.
Step 1: Upsert a customer
This step creates or updates (upserts) a customer with a specified ID. For more information, see Upsert a customer with predefined ID.
How to use the interactive example
- Enter your organization ID:
- Beneath the Environment field, click
{{server}}
. - Beneath the URL, click Show nested variables, then click Edit.
- In the Value field, enter your organization ID and click Save.
- Beneath the Environment field, click
- Enter your secret API key:
- Click Security.
- In the API key field, click
{{SecretApiKey}}
, then click Set value. - In the Value field, enter your secret Rebilly sandbox API key and click Save. For more information, see Prerequisites.
- Enter a customer ID:
- In the URL field beneath the Environment field, click
{{id}}
. - Click Set value.
- In the Value field, enter a customer ID.
Example:cus_01HDP7FFX2PGDVH1995EA4QY95
.
- In the URL field beneath the Environment field, click
- Enter your website ID:
- Click Body.
- In the
websiteId
, enter your website ID. - Optionally, change the customer details.
- Click Send.
Theid
value from this response is used as thecustomerId
value when creating the order in Step 2.
Step 2: Create an order
This step creates a subscription order for the customer you created in the previous step. For more information, see Create an order.
How to use the interactive example
- Enter your organization ID:
- Beneath the Environment field, click
{{server}}
. - Beneath the URL, click Show nested variables, then click Edit.
- In the Value field, enter your organization ID and click Save.
- Beneath the Environment field, click
- Enter your secret API key:
- Click Security.
- In the API key field, click
{{SecretApiKey}}
, then click Set value. - In the Value field, enter your secret Rebilly sandbox API key and click Save. For more information, see Prerequisites.
- Enter the order details:
- Click Body.
- In the
customerId
field, enter theid
value from the previous response Step 1. - In the
websiteId
field, enter your website ID.
- Click Send.
TherecentInvoiceId
value from this response is used in the next step.
Step 3: Pay the invoice
This step creates a transaction that pays the invoice for the order created in Step 2. For more information, see Create a transaction.
How to use the interactive example
- Enter your organization ID:
- Beneath the Environment field, click
{{server}}
. - Beneath the URL, click Show nested variables, then click Edit.
- In the Value field, enter your organization ID and click Save.
- Beneath the Environment field, click
- Enter your secret API key:
- Click Security.
- In the API key field, click
{{SecretApiKey}}
, then click Set value. - In the Value field, enter your secret Rebilly sandbox API key and click Save. For more information, see Prerequisites.
- Enter the transaction details:
- Click Send.
- Use a test payment card to complete the transaction.