Stripe checkout session
The ParityDeals Checkout API extends the capabilities of Stripe's Checkout API by incorporating dynamic pricing adjustments based on user location, holidays, and other criteria defined within ParityDeals.
On this page
Endpoint
POST https://www.paritydeals.com/api/v1/stripe-checkout/
This endpoint creates a checkout session with Stripe and applies geographic pricing and discounts as configured in ParityDeals.
Parameters
pd_identifier
(required): This parameter is used to specify a unique identifier associated with a particular deal.ip_address
(optional): Pass the IP address. This is necessary only if you are implementing this in server-side.apply_coupons
(optional):set this field true to automatically fetches and applies pricing based on the user’s location at checkout.checkout_data
(conditional):You will need to pass the checkout_data as a object checkout_data is similar as th data specified in stripe documentation. https://docs.stripe.com/api/checkout/sessions/create. This Parameter is required if payment_id is not provided.payment_id
(conditional):The unique identifier for the product on Stripe .This Parameter is required if checkout_data is not provided.success_url
(required): The URL to which a user will be redirected after a successful purchase.
const fetchCheckoutUrl = async () => {
const data = {
pd_identifier: 'your_pd_identifier', // Replace with actual pd identifier
ip_address: '', // Replace with actual ip_address
apply_coupons: true, // Set it to false if you don't want automatically apply the coupons
payment_id: 'your_payment_id', // Replace with actual payment ID
checkout_data: {}, // Replace with the actual Stripe checkout data
success_url: 'https://your-success-url.com' // Set the URL for post-checkout redirection.
};
try {
const response = await fetch('https://www.paritydeals.com/api/v1/stripe-checkout/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
const result = await response.json();
console.log('Successfully created Checkout session:', result);
} catch (error) {
console.error('Error while Checkout session:', error);
}
};
// Call the function
fetchCheckoutUrl();
Behavior
when the user make the POST request using this API it will return a checkout url based on the data that is passed in the API and returns a id and URL.
example result:
{
"id": "cs_live_a1HmmI9644trNrGaxfCMYrsZgK3QMiklsMqNEBNzEKWmNkzJtViECUBNpB",
"url": "https://checkout.stripe.com/c/pay/cs_live_a1HmmI9644trNrGaxfCMYrsZgK3QMiklsMqNEBNzEKWmNkzJtViECUBNpB#fid2cXdsdWBEZmZqcGtxJz8nZGZmcVo0SnYzXGdJSzZUVUlxRnRgJyknZHVsTmB8Jz8ndW5aaWxzYFowNE49Q0hnVkZsMWJHYjBcRmBGVEZ8ZFxWVF1XcUpEVXRgYE9HNGExQElMMz1IaDQ1ZkpqTl0wTGdwRm1AUVZ0Qmg8aHddbzdHclRIR1J8MjJfPEhKY3Z1czU1NF1PbX9TclMnKSdjd2poVmB3c2B3Jz9xd3BgKSdpZHxqcHFRfHVgJz8ndmxrYmlgWmxxYGgnKSdga2RnaWBVaWRmYG1qaWFgd3YnP3F3cGB4JSUl"
}