How to update purchase units of order subscription?

Temp20230331z
Contributor
Contributor

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' } ] }

 

 

 

 

 

Login to Me Too
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.