How to update purchase units of order subscription?
Temp20230331z
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Mar-31-2023
02:57 AM
After making payment for order subscription, I need to update purchase_units for order, but can't update and get error like below:
'{"name":"UNPROCESSABLE_ENTITY","details":[{"issue":"VALIDATION_ERROR","description":"VALIDATION_ERROR"}],"message":"The requested action could not be performed, semantically incorrect, or failed business validation.","debug_id":"b89e67b96b614","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-VALIDATION_ERROR","rel":"information_link"}]}',
this is my code:
const request = new paypal.orders.OrdersPatchRequest(orderId);
request.requestBody([
{
op: 'add',
path: `/purchase_units/@reference_id=='default'`,
value: {
amount: {
currency_code: 'USD',
value: '96.02',
breakdown: {
item_total: {
currency_code: 'USD',
value: '96.02'
},
shipping: {
currency_code: 'USD',
value: '0.00'
},
tax_total: {
currency_code: 'USD',
value: '0.00'
},
shipping_discount: {
currency_code: 'USD',
value: '0.00'
}
}
}
}
}
]);
this is the order details:
{ id: '19H72724AY945592S',
intent: 'CAPTURE',
status: 'APPROVED',
payment_source:
{ paypal:
{ email_address: 'xxxx',
account_id: '5WTG3YGN3CNTL',
name: [Object],
address: [Object] } },
purchase_units: [],
payer:
{ name: { given_name: 'Minh', surname: 'student' },
email_address: 'xxxx',
payer_id: '5WTG3YGN3CNTL',
address: { country_code: 'US' } },
create_time: '2023-03-31T05:43:34Z',
links:
[ { href:
'https://api.sandbox.paypal.com/v2/checkout/orders/19H72724AY945592S',
rel: 'self',
method: 'GET' },
{ href:
'https://api.sandbox.paypal.com/v2/checkout/orders/19H72724AY945592S',
rel: 'update',
method: 'PATCH' },
{ href:
'https://api.sandbox.paypal.com/v2/checkout/orders/19H72724AY945592S/capture',
rel: 'capture',
method: 'POST' } ] }
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 Enable or Disable Subscription Auto-Renewal? in REST APIs
- I don'r get a redirect after successfully buying a subscription (redirect, subscription) in REST APIs
- Merchant isn't able to accept PayPal payments at this time in NVP/SOAP APIs
- How to create a Paypal in 3 option for a Business that sells courses in Dubai? in NVP/SOAP APIs
- Subscription Status Immediately Updates to New Plan Despite Payment Scheduled for Next Billing Cycle in NVP/SOAP APIs