Redirect customers

United States
Canada

When you request a hosted checkout session using the checkouts endpoint, you can include the redirectUrls parameter. This parameter redirects customers to another link (URL) after payment. You can set more than one redirect location or URL.
You can include the following status in the redirectUrls object:

  • success—use this URL when a payment is successfully completed.
  • failure—use this URL when a payment is attempted but not completed.
  • cancel—use this URL when the customer leaves the checkout session before payment.

By default, a Clover-hosted confirmation page appears after a successful payment.

📘

Note

If redirectUrls parameters are configured on the Merchant Dashboard, then the URLs in the request are used instead of the URLs set in the Create Checkout API.

Example–Set a redirect URL when payment is successfully completed

Prerequisites

  • Use secure HTTP(S) URL for redirectUrls—success, failure, cancel—as unencrypted (HTTP) URL will not work.
  • Include the customer details in the payload.
app.route('/redirects', methods = ['GET', 'POST'])
def redirects(): #if request.method == 'POST':
    url = "https://sandbox.dev.clover.com/invoicingcheckoutservice/v1/checkouts"
payload = {
    "customer": {
        "firstName": "ace",
        "lastName": "place",
        "email": "[email protected]"
    },
    "redirectUrls": {
        "success": "https://www.merchant.com/",
        "failure": "https://www.merchant.com/",
        "cancel": "https://www.merchant.com/",

    },
    "shoppingCart": {
        "lineItems": [{
            "name": "itemA",
            "price": 500,
            "unitQty": 1
        }]
    }
}
headers = {
    "accept": "application/json",
    "X-Clover-Merchant-Id": "6CQXXXXXXXYE1",
    "content-type": "application/json",
    "authorization": "80e0****-****-****-********3f4a"
}

response = requests.request("POST", url, headers = headers, json = payload)
print(response.text)
return render_template("redirect.html")