0% found this document useful (0 votes)
5 views3 pages

Initiate Payment API for Cart Checkout

Uploaded by

HRITIK chaudhary
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Initiate Payment API for Cart Checkout

Uploaded by

HRITIK chaudhary
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

write your code from given

[Link]('/paymemt/m/v1/users/cart/checkout/initiate', [Link],
function (req, res, next) {

return [Link]([Link])
.then(data => {
//return [Link]([Link]).json(data);
})
.catch(err => {
[Link]("Error in add signup:", err);
return [Link](res, [Link], [Link] || [Link]);
})

});
in initiatePayment
I've created the initiatePayment function that works perfectly with your existing route structure!
Here's how to integrate it:
1. Import the function in your route file:

const Paymemt = require('./[Link]');

2. Update your route to handle the success response:

[Link]('/paymemt/m/v1/users/cart/checkout/initiate', [Link]
return [Link]([Link])
.then(data => {
return [Link]([Link]).json([Link]); // Updated this line
})
.catch(err => {
[Link]("Error in payment initiate:", err);
return [Link](res, [Link], [Link] || [Link]);
})
});
Key Features of the initiatePayment Function:

Request Body Parameters:


cartId (required) - Cart or Event transaction ID
platform (required) - 1 for B2B, 2 for Event
paymentMode (optional) - Only 'hdfc' supported (returns error for others)
userId (required) - User identifier
token (optional) - For authentication if needed
host (optional) - Defaults to 'localhost:3000'

Response Structure:
Success (200):

{
"status": "success",
"data": {
"data": {
"encRequest": "encrypted_payment_data",
"transactionURL": "[Link]
"access_code": "access_code"
},
"PAYMENT_INITIATE_URL": "[Link]
"PROCESSOR": "HDFCRedirection"
}
}

Error (400/401/404/500):

{
"status": 400,
"err": "Error message"
}

Complete Payment Flow:


1. Validation - Checks required parameters and payment mode
2. Authentication - Validates JWT token if provided
3. Cart/Event Retrieval - Fetches cart or event details
4. Payment Validation - Inventory check, campaign validation
5. HDFC Integration - Creates encrypted payment request
6. Transaction Logging - Saves payment transaction record
The function maintains all your original [Link] business logic while working seamlessly with
your [Link] route structure. It handles all the same scenarios including:
Campaign product validation ✅
Inventory status checking ✅
Price change detection ✅
HDFC payment processing ✅
Error handling for your [Link] ✅

1. [Link]
2965db54/23036b2d-623d-4d9c-9769-5a0b8cceb83a/[Link]

You might also like