This guide describes how to use the Rebilly API to create 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.
Complete this section to create the resources needed for this guide in your Rebilly sandbox, such as a product, pricing plan, and customer. This section also explains how to obtain required Rebilly sandbox IDs and a secret API key. If you have already created these resources, skip this step and continue to Step 1: Create an order.
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
TestProcessoris already configured. - The ready to payout instruction must be active and configured on the gateway. This setting must be manually configured on the
TestProcessorgateway. For more information, see set up a payment gateway.
Payment methods that are displayed in the hosted payment form are based on the gateway and payment method configuration. For more information, see Set up a payment gateway and Payment method configuration.
Expand to complete prerequisites
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 API interaction creates a product in your Rebilly sandbox account. For more information, see Create a product.
To create a product you must have your Rebilly website ID, organization ID, and secret API key. For more information, see Prerequisites.
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. For more information, see Obtain Rebilly sandbox IDs and secret key.
- 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 Obtain Rebilly sandbox IDs and secret key.
- Optionally, to change the product details, press Body.
- Press Send.
In the response, note theidvalue. This is the product ID.
This API interaction creates a pricing plan for a product in your Rebilly sandbox account. For more information, see Create a plan.
To create a pricing plan, you must have a product ID. For more information, see Create a product.
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. For more information, see Obtain Rebilly sandbox IDs and secret key.
- 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 Obtain Rebilly sandbox IDs and secret key.
- Enter a product ID:
- Press Body.
- In the
productIdfield, enter a product ID. For more information, see Create a product. - Optionally, change the plan details.
- Press Send.
In the response, note theidvalue. This is the plan ID.
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:
- Locate and press
server /, then in the Server variables section, press . - In the Value field, enter your organization ID and press Save. For more information, see Obtain Rebilly sandbox IDs and secret key.
- 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 Obtain Rebilly sandbox IDs and secret key.
- 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. For more information, see Obtain Rebilly sandbox IDs and secret key. - Optionally, change the customer details.
- Press Send.
In the response, note theidvalue. This is the customer ID.
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
To obtain the required values mentioned in this interactive example, complete the Prerequisites section.
- 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 Obtain Rebilly sandbox IDs and secret key.
- Enter the order details:
- Press Body.
- In the
customerIdfield, enter a customer ID.
Use the customer ID you created in Upsert a customer. - In the
websiteIdfield, enter your website ID. - In the
idfield, enter a pricing plan ID.
Use the pricing plan ID you created in Create a pricing plan.
- Press Send.
- In the response, note the
recentInvoiceIdvalue. This is used in the next step.
This step creates a hosted payment form URL where the customer can complete payment for the invoice you created in the previous step. For more information, see Create a transaction.
How to use the interactive example
To obtain the required values mentioned in this interactive example, complete the Prerequisites section.
- 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 Obtain Rebilly sandbox IDs and secret key.
- Enter the transaction details:
- In the
customerIdfield, enter the customer ID used in Step 1.
Use the customer ID you created in Step 1. - In the
websiteIdfield, enter the website ID used in Step 1. - In the
invoiceIdsfield, enter therecentInvoiceIdvalue from the response in Step 1: Create an order.
- In the
- Press Send.
- In the response, in the
_linksfield, locate theapprovalUrlvalue. This is the hosted payment form URL. The customer uses this link to pay for the order using a hosted payment form in Step 3: Complete the payment.
This step completes the payment using the hosted payment form URL obtained in Step 2.
- Open the hosted payment form URL in a web browser.
- Enter this test card number
4111 1111 1111 1111, with any future expiration date, and any 3 digits for the CVC number.
For more test cards, see Test payment cards, IBANs, and ACH details.