CreateCheckoutSession
This endpoint is there to create a checkout session with redirect url
Last updated
This endpoint is there to create a checkout session with redirect url
Last updated
POST
https://sandbox.pgecom.com/api/v1/checkout
Name | Type | Description |
---|---|---|
{
"message": "Checkout successfully created",
"customerId": "c2908b96-69d9-4948-b342-25656f7890c8",
"amount": 148,
"paymentMethod": "pgpay",
"shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
"merchantId": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
"orderId": "237a3154-fe0a-475a-a0b0-f291c4da597a",
"products": [
{
"productType": "physical",
"published": false,
"inventory": 34,
"shopId": "bf6d4273-3cd4-4319-a349-92e6c089d407",
"comparePrice": 0,
"status": "active",
"slug": "mont",
"createdAt": "2023-11-05T08:10:19Z",
"vendor": "tabb nabbers",
"name": "Mont",
"isFeatured": false,
"costPerItem": 0,
"isContinueSellingOutStock": false,
"userID": "7d4fd0d8-5da1-4911-8485-1b926c3d4e33",
"updatedAt": "2023-11-05T08:10:19Z",
"description": "This is another great demo again",
"price": 50,
"id": "fb533bc2-e676-4078-a09a-f286931c2fc6",
"mainImageUrl": "https://res.cloudinary.com/dnfoyqynm/image/upload/v1699171794/7d4fd0d8-5da1-4911-8485-1b926c3d4e33/tabb%20nabbers/products/19282000-d2e2-4469-884c-5636539e1fe3.jpg",
"quantity": 1
},
{
"categoryIds": [],
"productType": "physical",
"inventory": 20,
"published": false,
"shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
"comparePrice": 0,
"status": "active",
"slug": "pantalon",
"createdAt": "2023-11-21T13:32:19Z",
"name": "Pantalon",
"vendor": "facebook",
"isFeatured": false,
"costPerItem": 0,
"isContinueSellingOutStock": false,
"updatedAt": "2023-11-21T13:32:19Z",
"userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
"description": "This is another great demo",
"id": "999f182d-8547-4c47-a4ee-6d3d83598924",
"price": 49,
"mainImageUrl": "https://res.cloudinary.com/dnfoyqynm/image/upload/v1700573529/facebook/products/whatsapp-image-2023-04-28-at-11.10.17-am-3.jpg",
"quantity": 2
}
],
"checkoutUrl": "https://www.pgecom.com/payment/pgpay/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOiI1ZjU2ZGZhMy1hNDE1LTQ4MTgtODI3NS00NGZjNjNlY2UzZmQiLCJhbW91bnQiOjE0OCwicGhvbmUiOiIrMSA0MDQgODI1IDM0NDQiLCJpc1Byb2QiOmZhbHNlLCJvcmRlcklkIjoiMjM3YTMxNTQtZmUwYS00NzVhLWEwYjAtZjI5MWM0ZGE1OTdhIiwicGdQYXlNZXJjaGFudE5hbWUiOiJQR2Vjb20iLCJyZWRpcmVjdFVybCI6IiMiLCJ0cmFuc2FjdGlvblR5cGUiOiJjaGVja291dCIsInF1YW50aXR5IjowLCJjdXN0b21lckVtYWlsIjoiY2hlY2tvdXQiLCJwYXltZW50UHJvdmlkZXIiOiJwZ3BheSIsImlhdCI6MTcwMzc1NzQ2NywiZXhwIjoxNzAzNzYxMDY3fQ.LGVswaaCLT8SlHa8W_uK9--9-QMUFlPqnIHInL2lgR4",
"totalPrice": 148
}
{
"message": "Provided list of item keys contains duplicates",
"code": "ValidationException",
"[__type]": "See error.__type for details.",
"time": "2023-12-28T09:44:51.347Z",
"requestId": "020L7BP2USGM6ACA6V69BOR773VV4KQNSO5AEMVJF66Q9ASUAAJG",
"statusCode": 400,
"retryable": false,
"retryDelay": 2.636094949981982
}
{
"message": "Too many requests, please try again later.",
"status": 429
}
{
"message": "Product ids with 2 not found, please double check the product id"
}
{
"message": "Merchant with id 5f56dfa3-a415-4818-8275-44fc63ece3fd is not allowed to checkout"
}
const axios = require('axios');
let data = '{\n "merchantId": "5f56dfa3-a415-4818-8275-44fc63ece3fd",\n "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",\n "paymentMethod": "pgpay",\n "customer": {\n "name": "Esterling Accime",\n "email": "accime@pgecom.com",\n "phone": "+1 404 825 3444"\n },\n "shippingAddress": {\n "apartment": "",\n "line1": "9700 Medlock Bridge Road",\n "city": "Johns Creek",\n "state": "Georgia",\n "country": "US",\n "postalCode": 90076\n },\n "billingAddress": {\n "apartment": "",\n "line1": "9700 Medlock Bridge Road",\n "city": "Johns Creek",\n "state": "Georgia",\n "country": "US",\n "postalCode": 90076\n },\n "products": [\n {\n "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",\n "quantity": 2,\n "price": 49,\n "id": "999f182d-8547-4c47-a4ee-6d3d83598924",\n "name": "Demo 1"\n },\n {\n "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",\n "quantity": 1,\n "price": 29,\n "id": "fb533bc2-e676-4078-a09a-f286931c2fc6",\n "name": "Demo 2"\n }\n ],\n "currency": "usd"\n}';
let config = {
method: 'post',
url: 'https://sandbox.pgecom.com/api/v1/checkout',
headers: { },
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
import http.client
conn = http.client.HTTPSConnection("https://sandbox.pgecom.com")
payload = ''
headers = {}
conn.request("POST", "/api/v1/checkout", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"
url = URI("https://sandbox.pgecom.com/api/v1/checkout")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request.body = "{\n \"merchantId\": \"5f56dfa3-a415-4818-8275-44fc63ece3fd\",\n \"shopId\": \"0a40d129-0728-4b10-b32e-117abd6938c3\",\n \"paymentMethod\": \"pgpay\",\n \"customer\": {\n \"name\": \"Esterling Accime\",\n \"email\": \"accime@pgecom.com\",\n \"phone\": \"+1 404 825 3444\"\n },\n \"shippingAddress\": {\n \"apartment\": \"\",\n \"line1\": \"9700 Medlock Bridge Road\",\n \"city\": \"Johns Creek\",\n \"state\": \"Georgia\",\n \"country\": \"US\",\n \"postalCode\": 90076\n },\n \"billingAddress\": {\n \"apartment\": \"\",\n \"line1\": \"9700 Medlock Bridge Road\",\n \"city\": \"Johns Creek\",\n \"state\": \"Georgia\",\n \"country\": \"US\",\n \"postalCode\": 90076\n },\n \"products\": [\n {\n \"shopId\": \"0a40d129-0728-4b10-b32e-117abd6938c3\",\n \"quantity\": 2,\n \"price\": 49,\n \"id\": \"999f182d-8547-4c47-a4ee-6d3d83598924\",\n \"name\": \"Demo 1\"\n },\n {\n \"shopId\": \"0a40d129-0728-4b10-b32e-117abd6938c3\",\n \"quantity\": 1,\n \"price\": 29,\n \"id\": \"fb533bc2-e676-4078-a09a-f286931c2fc6\",\n \"name\": \"Demo 2\"\n }\n ],\n \"currency\": \"usd\"\n}"
response = http.request(request)
puts response.read_body
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://sandbox.pgecom.com/api/v1/checkout');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setBody('{\n "merchantId": "5f56dfa3-a415-4818-8275-44fc63ece3fd",\n "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",\n "paymentMethod": "pgpay",\n "customer": {\n "name": "Esterling Accime",\n "email": "accime@pgecom.com",\n "phone": "+1 404 825 3444"\n },\n "shippingAddress": {\n "apartment": "",\n "line1": "9700 Medlock Bridge Road",\n "city": "Johns Creek",\n "state": "Georgia",\n "country": "US",\n "postalCode": 90076\n },\n "billingAddress": {\n "apartment": "",\n "line1": "9700 Medlock Bridge Road",\n "city": "Johns Creek",\n "state": "Georgia",\n "country": "US",\n "postalCode": 90076\n },\n "products": [\n {\n "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",\n "quantity": 2,\n "price": 49,\n "id": "999f182d-8547-4c47-a4ee-6d3d83598924",\n "name": "Demo 1"\n },\n {\n "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",\n "quantity": 1,\n "price": 29,\n "id": "fb533bc2-e676-4078-a09a-f286931c2fc6",\n "name": "Demo 2"\n }\n ],\n "currency": "usd"\n}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
curl --location 'http://localhost:3002/api/v1/checkout' \
--data-raw '{
"merchantId": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
"shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
"paymentMethod": "pgpay",
"customer": {
"name": "Esterling Accime",
"email": "accime@pgecom.com",
"phone": "+1 404 825 3444"
},
"shippingAddress": {
"apartment": "",
"line1": "9700 Medlock Bridge Road",
"city": "Johns Creek",
"state": "Georgia",
"country": "US",
"postalCode": 90076
},
"billingAddress": {
"apartment": "",
"line1": "9700 Medlock Bridge Road",
"city": "Johns Creek",
"state": "Georgia",
"country": "US",
"postalCode": 90076
},
"products": [
{
"shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
"quantity": 2,
"price": 49,
"id": "999f182d-8547-4c47-a4ee-6d3d83598924",
"name": "Demo 1"
},
{
"shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
"quantity": 1,
"price": 29,
"id": "fb533bc2-e676-4078-a09a-f286931c2fc6",
"name": "Demo 2"
}
],
"currency": "usd"
}'
merchantId
String
shopId
String
paymentMethod
String
customer.name
String
customer.email
String
customer.phone
String
shippingAddress.apartment
String
shippingAddress.line1
String
shippingAddress.city
String
shippingAddress.state
String
shippingAddress.country
String
shippingAddress.postalCode
Number
billingAddress.apartment
String
billingAddress.line1
String
billingAddress.city
String
billingAddress.state
String
billingAddress.country
String
billingAddress.postalCode
Number
currency
String
products[0].shopId
String
products[0].quantity
Number
products[0].price
Number
products[0].id
String
products[0].name
String
successUrl
String
errorUrl
String