Checkouts
Create a checkout
Creates a new checkout.
POST
/
checkouts
Create a checkout
curl --request POST \
--url https://pay.chargily.net/test/api/v2/checkouts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"price": "<string>",
"quantity": 123
}
],
"amount": 123,
"currency": "<string>",
"payment_method": "<string>",
"success_url": "<string>",
"customer_id": "<string>",
"failure_url": "<string>",
"webhook_endpoint": "<string>",
"description": "<string>",
"locale": "<string>",
"shipping_address": "<string>",
"collect_shipping_address": true,
"percentage_discount": 123,
"amount_discount": 123,
"metadata": [
{}
]
}
'import requests
url = "https://pay.chargily.net/test/api/v2/checkouts"
payload = {
"items": [
{
"price": "<string>",
"quantity": 123
}
],
"amount": 123,
"currency": "<string>",
"payment_method": "<string>",
"success_url": "<string>",
"customer_id": "<string>",
"failure_url": "<string>",
"webhook_endpoint": "<string>",
"description": "<string>",
"locale": "<string>",
"shipping_address": "<string>",
"collect_shipping_address": True,
"percentage_discount": 123,
"amount_discount": 123,
"metadata": [{}]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [{price: '<string>', quantity: 123}],
amount: 123,
currency: '<string>',
payment_method: '<string>',
success_url: '<string>',
customer_id: '<string>',
failure_url: '<string>',
webhook_endpoint: '<string>',
description: '<string>',
locale: '<string>',
shipping_address: '<string>',
collect_shipping_address: true,
percentage_discount: 123,
amount_discount: 123,
metadata: [{}]
})
};
fetch('https://pay.chargily.net/test/api/v2/checkouts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://pay.chargily.net/test/api/v2/checkouts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'price' => '<string>',
'quantity' => 123
]
],
'amount' => 123,
'currency' => '<string>',
'payment_method' => '<string>',
'success_url' => '<string>',
'customer_id' => '<string>',
'failure_url' => '<string>',
'webhook_endpoint' => '<string>',
'description' => '<string>',
'locale' => '<string>',
'shipping_address' => '<string>',
'collect_shipping_address' => true,
'percentage_discount' => 123,
'amount_discount' => 123,
'metadata' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://pay.chargily.net/test/api/v2/checkouts"
payload := strings.NewReader("{\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 123\n }\n ],\n \"amount\": 123,\n \"currency\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"success_url\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"failure_url\": \"<string>\",\n \"webhook_endpoint\": \"<string>\",\n \"description\": \"<string>\",\n \"locale\": \"<string>\",\n \"shipping_address\": \"<string>\",\n \"collect_shipping_address\": true,\n \"percentage_discount\": 123,\n \"amount_discount\": 123,\n \"metadata\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://pay.chargily.net/test/api/v2/checkouts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 123\n }\n ],\n \"amount\": 123,\n \"currency\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"success_url\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"failure_url\": \"<string>\",\n \"webhook_endpoint\": \"<string>\",\n \"description\": \"<string>\",\n \"locale\": \"<string>\",\n \"shipping_address\": \"<string>\",\n \"collect_shipping_address\": true,\n \"percentage_discount\": 123,\n \"amount_discount\": 123,\n \"metadata\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pay.chargily.net/test/api/v2/checkouts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 123\n }\n ],\n \"amount\": 123,\n \"currency\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"success_url\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"failure_url\": \"<string>\",\n \"webhook_endpoint\": \"<string>\",\n \"description\": \"<string>\",\n \"locale\": \"<string>\",\n \"shipping_address\": \"<string>\",\n \"collect_shipping_address\": true,\n \"percentage_discount\": 123,\n \"amount_discount\": 123,\n \"metadata\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "01hj5n7cqpaf0mt2d0xx85tgz8",
"entity": "checkout",
"livemode": false,
"amount": 2500,
"currency": "dzd",
"fees": 0,
"fees_on_merchant": 0,
"fees_on_customer": 0,
"pass_fees_to_customer": null,
"chargily_pay_fees_allocation": "customer",
"status": "pending",
"locale": "en",
"description": null,
"metadata": null,
"success_url": "https://my-app.com/payments/success",
"failure_url": "https://my-app.com/payments/failure",
"webhook_endpoint": 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": {
"type": "percentage",
"value": 50
},
"amount_without_discount": 5000,
"checkout_url": "https://pay.chargily.dz/test/checkouts/01hj5n7cqpaf0mt2d0xx85tgz8/pay"
}
Body parameters
array
integer
Required if the parameter
items is not provided.The total amount of the checkout.string
Required if the parameter
amount is provided.A lowercase ISO currency
code.
Currently supported currencies are: “dzd”.string
default:"edahabia"
The payment method that will be used to pay the checkout. Currently supported
payment methods are: “edahabia”, “cib” and “chargily_app”. The customer can always change the payment method at the checkout page.When the payment method is “chargily_app”, a “qr_code_url” param will be returned in the response.
string
required
The URL where your customer will be redirected after a successful payment.
string
The URL where your customer will be redirected after a failed or canceled
payment.
string
The URL of your endpoint that will receive the webhook events sent by Chargily
Pay.
string
A description of the checkout. You can use this field to save a note about the
checkout.
string
The language of the checkout page, accepted values are: ‘ar’, ‘en’ or ‘fr’.
boolean
DEPRECATED, use chargily_pay_fees_allocation instead.A Boolean value indicates whether the Chargily Pay fees will be paid by you,
the merchant, or your customers.
string
Can be one of “customer”, “merchant” or “split”.Choose who is going to pay Chargily Pay fees (“Merchant” means you will pay the fees, “Customer” means the customer will pay the fees, “Split” means you will split the fees with the customer).
string
The shipping address of the customer for the checkout.
boolean
A Boolean value indicates whether the shipping address should be collected
from the customer.
integer
Prohibited if the parameter
amount_discount is provided.A percentage discount that will be applied to the total amount of the
checkout.integer
Prohibited if the parameter
percentage_discount is provided.An amount discount that will be applied to the total amount of the checkout.array
A Set of key-value pairs that can be used to store additional information
about the product.
Returns
If the request is successful, it returns a checkout object.{
"id": "01hj5n7cqpaf0mt2d0xx85tgz8",
"entity": "checkout",
"livemode": false,
"amount": 2500,
"currency": "dzd",
"fees": 0,
"fees_on_merchant": 0,
"fees_on_customer": 0,
"pass_fees_to_customer": null,
"chargily_pay_fees_allocation": "customer",
"status": "pending",
"locale": "en",
"description": null,
"metadata": null,
"success_url": "https://my-app.com/payments/success",
"failure_url": "https://my-app.com/payments/failure",
"webhook_endpoint": 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": {
"type": "percentage",
"value": 50
},
"amount_without_discount": 5000,
"checkout_url": "https://pay.chargily.dz/test/checkouts/01hj5n7cqpaf0mt2d0xx85tgz8/pay"
}
Previous
Retrieve a checkoutRetrieves all the information of an already-existing checkout by providing it's unique identifier (ID).
Next
⌘I
Create a checkout
curl --request POST \
--url https://pay.chargily.net/test/api/v2/checkouts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"price": "<string>",
"quantity": 123
}
],
"amount": 123,
"currency": "<string>",
"payment_method": "<string>",
"success_url": "<string>",
"customer_id": "<string>",
"failure_url": "<string>",
"webhook_endpoint": "<string>",
"description": "<string>",
"locale": "<string>",
"shipping_address": "<string>",
"collect_shipping_address": true,
"percentage_discount": 123,
"amount_discount": 123,
"metadata": [
{}
]
}
'import requests
url = "https://pay.chargily.net/test/api/v2/checkouts"
payload = {
"items": [
{
"price": "<string>",
"quantity": 123
}
],
"amount": 123,
"currency": "<string>",
"payment_method": "<string>",
"success_url": "<string>",
"customer_id": "<string>",
"failure_url": "<string>",
"webhook_endpoint": "<string>",
"description": "<string>",
"locale": "<string>",
"shipping_address": "<string>",
"collect_shipping_address": True,
"percentage_discount": 123,
"amount_discount": 123,
"metadata": [{}]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [{price: '<string>', quantity: 123}],
amount: 123,
currency: '<string>',
payment_method: '<string>',
success_url: '<string>',
customer_id: '<string>',
failure_url: '<string>',
webhook_endpoint: '<string>',
description: '<string>',
locale: '<string>',
shipping_address: '<string>',
collect_shipping_address: true,
percentage_discount: 123,
amount_discount: 123,
metadata: [{}]
})
};
fetch('https://pay.chargily.net/test/api/v2/checkouts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://pay.chargily.net/test/api/v2/checkouts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'price' => '<string>',
'quantity' => 123
]
],
'amount' => 123,
'currency' => '<string>',
'payment_method' => '<string>',
'success_url' => '<string>',
'customer_id' => '<string>',
'failure_url' => '<string>',
'webhook_endpoint' => '<string>',
'description' => '<string>',
'locale' => '<string>',
'shipping_address' => '<string>',
'collect_shipping_address' => true,
'percentage_discount' => 123,
'amount_discount' => 123,
'metadata' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://pay.chargily.net/test/api/v2/checkouts"
payload := strings.NewReader("{\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 123\n }\n ],\n \"amount\": 123,\n \"currency\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"success_url\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"failure_url\": \"<string>\",\n \"webhook_endpoint\": \"<string>\",\n \"description\": \"<string>\",\n \"locale\": \"<string>\",\n \"shipping_address\": \"<string>\",\n \"collect_shipping_address\": true,\n \"percentage_discount\": 123,\n \"amount_discount\": 123,\n \"metadata\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://pay.chargily.net/test/api/v2/checkouts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 123\n }\n ],\n \"amount\": 123,\n \"currency\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"success_url\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"failure_url\": \"<string>\",\n \"webhook_endpoint\": \"<string>\",\n \"description\": \"<string>\",\n \"locale\": \"<string>\",\n \"shipping_address\": \"<string>\",\n \"collect_shipping_address\": true,\n \"percentage_discount\": 123,\n \"amount_discount\": 123,\n \"metadata\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pay.chargily.net/test/api/v2/checkouts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"price\": \"<string>\",\n \"quantity\": 123\n }\n ],\n \"amount\": 123,\n \"currency\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"success_url\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"failure_url\": \"<string>\",\n \"webhook_endpoint\": \"<string>\",\n \"description\": \"<string>\",\n \"locale\": \"<string>\",\n \"shipping_address\": \"<string>\",\n \"collect_shipping_address\": true,\n \"percentage_discount\": 123,\n \"amount_discount\": 123,\n \"metadata\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "01hj5n7cqpaf0mt2d0xx85tgz8",
"entity": "checkout",
"livemode": false,
"amount": 2500,
"currency": "dzd",
"fees": 0,
"fees_on_merchant": 0,
"fees_on_customer": 0,
"pass_fees_to_customer": null,
"chargily_pay_fees_allocation": "customer",
"status": "pending",
"locale": "en",
"description": null,
"metadata": null,
"success_url": "https://my-app.com/payments/success",
"failure_url": "https://my-app.com/payments/failure",
"webhook_endpoint": 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": {
"type": "percentage",
"value": 50
},
"amount_without_discount": 5000,
"checkout_url": "https://pay.chargily.dz/test/checkouts/01hj5n7cqpaf0mt2d0xx85tgz8/pay"
}