multiparty vendor
auqid
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Jul-15-2024
08:28 AM
I am integrating PayPal into a multi-vendor site where the payment workflow is designed to:
- Authorize payment when a customer requests a service.
- Capture payment when the seller accepts the request.
- Disburse payment to the seller upon service completion.
Steps and Issues:
Order Creation:
- Intent: 'authorize'
- Custom Reference ID: Generated using a custom function.
- Payload:
const paypalRequest = {
intent: 'AUTHORIZE',
purchase_units: [
{
reference_id: generateCustomReferenceID(),
amount: {
currency_code: currentCurrency,
value: toMoney(totalPayin),
breakdown: {
item_total: {
currency_code: currentCurrency,
value: toMoney(totalPayin),
},
},
},
payee: {
email_address: payeePaypalEmail,
},
items: lineItems
.filter(k => k.code != 'line-item/provider-commission')
.map(item => ({
name: findPaypalItemLabel(item),
quantity: item.quantity,
unit_amount: {
currency_code: currentCurrency,
value: toMoney(item.unitPrice.amount),
},
})),
},
],
};
Order Creation Request:
const orderResponse = await createOrder(paypalRequest);Payment Authorization:
- Authorization Request:const [success, error] = await authorizePayment(orderID);
const authorizationId = success?.purchase_units[0]?.payments?.authorizations[0]?.id;
const reference_id = success?.purchase_units[0]?.reference_id;
if (error) {
return res.status(500).send({ message: 'Order id is not present.' });
}Payment Capture (upon seller acceptance):
- Payload:
- const payload = {
payment_instruction: {
disbursement_mode: 'DELAYED',
platform_fees: [
{
amount: {
currency_code: currentCurrency,
value: '10',
},
},
],
},
}; - Capture Request:
const captureURL = `/v2/payments/authorizations/${authorizationId}/capture`;
const response = await axiosWithPaypal.post(captureURL, payload);
Disbursement (upon service completion): - const res = await axiosWithPaypal.post('/v1/payments/referenced-payouts-items', {
"reference_id": reference_id,
"reference_type": "TRANSACTION_ID"
}, {
headers: {
'Content-Encoding': 'gzip',
'Prefer': 'respond-async',
'PayPal-Request-Id': 'some-idempotency-data'
},
}); - Issue: The disbursement request returns a 202 response, indicating success, but no funds are transferred from the buyer's account to the seller's account in the sandbox environment.
- Payload:
- Authorization Request:
Labels:
- Labels:
-
Holds
-
Sending Money
0 REPLIES 0

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- How to Setting up the PayPal Payflow Pro on Shopify in Sandbox & Production mode? in Payflow
- need to create separate payment with QR code that will split payment between the vendor and myself in Sandbox Environment
- Are there any restrictions to charge using only html, vanilla javascript and php with rest api? in REST APIs
- Getting "Invalid Transaction Type" Error When Calling Payflow Gateway API in Payflow
- GET /customer/partners/:partner_id/merchant-integrations/:seller_id returning 404 in Sandbox. Help! in Sandbox Environment