patch transaction amount error

devAcct
Contributor
Contributor


I have a transaction, running through the javascript sdk, that authorizes the payment. That is all working find, and I'm getting an order id, and auth id etc.

I need to update the /amount before doing a capture, this time using the back end (ColdFusion). I'm referencing the docs at https://developer.paypal.com/docs/checkout/integration-features/update-order-details/#2-patch-the-tr... but keep getting invalid request etc

url: https://api.sandbox.paypal.com/v2/checkout/orders/[order id]
auth: access token generation is successful, and allows a 'get' on the same url, returns the correct order details.

body: {

    op: 'replace',

    path: '/purchase_units/@reference_id==\'default\'/amount',

    value: {currency_code: 'USD', value: '500.00'}
}

I'm not using a reference id, but do see the 'default' in the listing. I'm guessing the issue is something in the formatting of the body. I'll get invalid request, with syntax or missing param issues.

Am I missing something?

Login to Me Too
2 REPLIES 2

GreenJesterAt
Member
Member

The patch object is an array of objects, so you can do multiple patches with one request. Makes sense, since sometimes there are some consistency boundaries such as property A + property B must equal property C, so you need to patch A, B and C at the same time.

 

Just put your object in an array, e.g. put [ brackets ] around it.

 

[
  {
    op: 'replace',
    path: '/purchase_units/@reference_id==\'default\'/amount',
    value: {currency_code: 'USD', value: '500.00'}
  }
]
Login to Me Too

MTS_Stefan
Moderator
Moderator

Hey DevAcct,

By default, GreenjesterAt, gave a good suggestion there.
However, I'd like to add:
You can only replace an object that you provided in the order/payment create, so you have to add it if it was not there to begin with. Which is a common enough error people tend to make.

When asking for help in the forum, it's best to show what you sent in full (minus confidential things like client IDs) and the entire return information from us. Our servers reply tend to tell you exactly what you are missing/sent wrong and it is easier for us to point to it, if you provide the tangible data.

Regards,
Stefan

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.