Per user price or return urls

Prepare a custom checkout session for a specific user

You can create a checkout session through our API for a specific user, to customize any of these parameters:

  • price

  • success URL

  • error URL

Create a custom checkout session

To prepare a custom checkout session, you will need the following parameters from your dashboard:

  • your project api secret: in your project, bottom of the left menu "api key",

  • your product ID: in your project, checkout, products,

  • user wallet address and email.

To customize the checkout session, you may want to set (each field is optional):

  • custom price: set as cents, like "150" for 1.5$

  • success url: the redirect url will always contains the purchase id (added as ‘id’ in query string) and transaction hash

  • error url: the error redirect URL will contain error id and message (‘error_id’ and ‘error_message’ in query string).

curl -X POST https://api.checkout.cometh.io/v1/checkout-sessions \
  -H "Content-Type: application/json" \
  -H "apisecret: <your project api secret>" \
  -d '{
    "productId": <your product ID>,
    "price": "<price in cents>",
    "successUrl": "<success url>",
    "failUrl": "<error url>",
    "userAddress": "<user wallet adress (recipient)>",
    "email": "<user email>",
    "parameters": {
      "to": "<user wallet adress (recipient)>"
    }
  }'

Only use this from your backend as it involves your API secret

As result, you will obtain a transactionId and session that you will use to redirect the user to checkout page.

{
  "transactionId": "16e5cac8-ef57-4159-9a7e-aa94cdecf5cd",
  "session": "pi_3QKZBeIVzbOzFT4x2sYrxwJz_secret_KGUwv7QOTuJKVZY2srwBdB2g4"
}

Redirect the user to (customized) checkout page

To prepare a custom checkout session, you will need the following parameter from your dashboard:

  • your project public api key: in your project, bottom of the left menu "api key".

With specific transactionID and session from the previous request, you can redirect the user to this url:

https://checkout.cometh.io/?transaction_id=<transactionID>&session=<session>&checkout_api_key=<your public api key>

Last updated