Create a Checkout

Don’t forget to replace <YOUR_SECRET_KEY_HERE> with your API Secret Key

For more details about the Checkout Create endpoint, refer to its API Reference.

curl --request POST \
  --url https://pay.chargily.net/test/api/v2/checkouts \
  --header 'Authorization: Bearer <YOUR_SECRET_KEY_HERE>' \
  --header 'Content-Type: application/json' \
  --data '{
  "items": [
    [
      "price": "01hhy57e5j3xzce7ama8gtk7m0",
      "quantity": 1
    ]
  ],
  "success_url": "https://your-cool-website.com/payments/success"
}'

Response

If everything worked, you should get a response like this:

json
{
   "id": "01hj5n7cqpaf0mt2d0xx85tgz8",
   "entity": "checkout",
   "livemode": false,
   "amount": 5000,
   "fees": 0,
   "pass_fees_to_customer": 0,
   "status": "pending",
   "locale": "ar",
   "description": null,
   "metadata": null,
   "success_url": "https://your-cool-website.com/payments/success",
   "failure_url": null,
   "payment_method": null,
   "invoice_id": null,
   "customer_id": "01hj150206g0jxnh5r2yvvdrna",
   "payment_link_id": null,
   "created_at": 1703144567,
   "updated_at": 1703144567,
   "shipping_address": null,
   "collect_shipping_address": 0,
   "discount": null,
   "amount_without_discount": null,
   "checkout_url": "https://pay.chargily.dz/test/checkouts/01hj5n7cqpaf0mt2d0xx85tgz8/pay"
}

Which is the Checkout object you just created.

You can see in the Response a parameter called checkout_url:

"checkout_url": "https://pay.chargily.dz/test/checkouts/01hj5n7cqpaf0mt2d0xx85tgz8/pay"

This is the URL you can redirect your customer to, to complete the payment.

Now, when your customer goes to the payment link and successfully pays, how can your website or app be notified about this? This is important for handling post-payment actions, like updating an order status to “paid”. We use Webhooks for this.

Next

You will see now how to make your website or application react to a successful payment using Webhooks.

Receive webhooks

You can now create a Checkout using the Price you just created.