CreateCheckoutSession
This endpoint is there to create a checkout session with redirect url
POST
https://sandbox.pgecom.com/api/v1/checkout
Request Body
Name
Type
Description
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
{
"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
}
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);
});
Last updated
Was this helpful?