Recharge-hosted checkout

The Recharge-hosted Checkout presents an interface allowing you to process checkouts that will sync into the Recharge system and is the recommended checkout method when using Recharge's API integration. This article covers using Recharge's hosted checkout with your custom integration. Create a checkout experience for customers directing to Recharge’s hosted checkout by using Recharge’s Checkouts resource.

Use Recharge's Checkout API to create a checkout experience for customers that directs them to the Recharge-hosted checkout. The Recharge-hosted heckout is availabe on your storefront and lets you process checkouts that sync with the Recharge system.

📘

Platform

  • Custom

Overview

There are two steps to process checkout orders via the Recharge-hosted checkout:

  1. Create the Checkout object
  2. Redirect checkout to Recharge


Step 1 - Create the Checkout object

There are two main steps to process checkouts via the Recharge-Hosted Checkout.

Call your middleware to build the checkout object when a user clicks the checkout button on the storefront (or any action that triggers the checkout process is taken).

POST your cart contents (or custom-built line items) to the Recharge checkout endpoint, along with any miscellaneous properties (ie. UTM parameters, discount codes).

Example POST to /checkouts

import requests
import json

headers = {
  "X-Recharge-Access-Token": "<your_api_token>",
  "Accept": "application/json",
  "Content-Type": "application/json"
}
url = "https://api.rechargeapps.com/checkouts"
data = {
  "line_items": [
    {
      "charge_interval_frequency": 5,
      "cutoff_day_of_month": None,
      "cutoff_day_of_week": None,
      "expire_after_specific_number_of_charges": None,
      "fulfillment_service": "manual",
      "order_day_of_month": None,
      "order_day_of_week": None,
      "order_interval_frequency": 5,
      "order_interval_unit": "day",
      "product_id": <product_id>,
      "quantity": 6,
      "requires_shipping": True,
      "taxable": True,
      "variant_id": <variant_id>,
    }
  ],
}
result = requests.post(url, json.dumps(data), headers=headers)

Step 2- Redirect customers to Recharge

After the API creates the checkout record, it responds with a Token property. You can include this token property in a redirect URL to send back to Recharge, allowing the customer to complete the transaction via the ReCharge-Hosted Checkout. The URL to redirect to is:

https://checkout.rechargeapps.com/r/checkout/<Token>


Need Help? Contact Us