Last updated
These docs are intended for a developer audience.Dismiss

Hosted payment form API integration

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.

Important

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.

Payment methods that are displayed in the hosted payment form are based on the gateway configuration. 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.

  1. Log in or sign up to Rebilly.
  2. Obtain your organization ID and website ID:
    1. In the left navigation bar, press Settings .
    2. In the Management section, press My organization & websites.
    3. In the Organization details section, note the ID value.
    4. In the Website section, note the ID value. For more information, see Organizations and websites.
  3. Obtain your secret API key:
    1. In the left navigation bar, press Automations .
    2. In the Development section, press API keys.
    3. Optionally, if you have not created a secret key:
      1. In top right of the screen, press Create API key.
      2. In the API key type section, select Secret.
      3. Optionally, in the Organizations dropdown, select the organizations that can use the API key.
      4. Optionally, in the Allowed IPs field, enter the IP addresses that are permitted to use the API key.
      5. Press Save API key.
      6. Go to the API keys page.
    4. 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
  1. Enter your organization ID:
    1. Beneath the Environment field, press {{server}}.
    2. Beneath the URL, press Show nested variables, then press Edit.
    3. In the Value field, enter your organization ID and press Save.
  2. Enter your secret API key:
    1. Press Security.
    2. In the API key field, press {{SecretApiKey}}, then press Set value.
    3. In the Value field, enter your secret Rebilly sandbox API key and press Save. For more information, see Prerequisites.
  3. Enter a customer ID:
    1. In the URL field beneath the Environment field, press {{id}}.
    2. Press Set value.
    3. In the Value field, enter a customer ID.
      Example: cus_01HDP7FFX2PGDVH1995EA4QY95.
  4. Enter your website ID:
    1. Press Body.
    2. In the websiteId, enter your website ID.
    3. Optionally, change the customer details.
  5. Press Send.
    The id value from this response is used as the customerId value when creating the order in Step 2.
Loading...

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
  1. Enter your organization ID:
    1. Beneath the Environment field, press {{server}}.
    2. Beneath the URL, press Show nested variables, then press Edit.
    3. In the Value field, enter your organization ID and press Save.
  2. Enter your secret API key:
    1. Press Security.
    2. In the API key field, press {{SecretApiKey}}, then press Set value.
    3. In the Value field, enter your secret Rebilly sandbox API key and press Save. For more information, see Prerequisites.
  3. Enter the order details:
    1. Press Body.
    2. In the customerId field, enter the id value from the previous response Step 1.
    3. In the websiteId field, enter your website ID.
  4. Press Send.
    The recentInvoiceId value from this response is used in the next step.
Loading...

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
  1. Enter your organization ID:
    1. Beneath the Environment field, press {{server}}.
    2. Beneath the URL, press Show nested variables, then press Edit.
    3. In the Value field, enter your organization ID and press Save.
  2. Enter your secret API key:
    1. Press Security.
    2. In the API key field, press {{SecretApiKey}}, then press Set value.
    3. In the Value field, enter your secret Rebilly sandbox API key and press Save. For more information, see Prerequisites.
  3. Enter the transaction details:
    1. In the customerId field, enter the id value from the response in Step 1.
    2. In the websiteId field, enter the same website ID value that you used in Step 1.
    3. In the invoiceIds field, enter the recentInvoiceId value from the response in Step 2.
  4. Press Send.
  5. To complete a test transaction: Use 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
Loading...