'PayPal Patch Payee after approval before capture

In the PayPal documentation they state that you can update the payee email address after an order has been created

https://developer.paypal.com/docs/api/orders/v2/#orders_patch

However, if I try it by sending the following JSON to their API

 {
        "op": "replace",
        "path": "/purchase_units/@reference_id=='default'/payee",
        "value": {
            "email_address": "[email protected]"
        }
    }

I get told that the payee is not patchable

{"name":"UNPROCESSABLE_ENTITY","details":
     [{"field":"path",
       "value":"/purchase_units/0/payee",
       "location":"body",
       "issue":"NOT_PATCHABLE",
       "description":"Cannot be patched."
     }] 
 ... }

After struggling quite a bit with the PayPal integration I'm too invested to give up at this point! Any ideas on how I should go about this? I've also tried changing the parameter name from email_address to email and setting value directly to the email address but neither are working. Do I need to replace the complete purchase_unit or maybe constructed my JSON badly?

Thanks in advance!



Solution 1:[1]

Use standard JSON patch syntax to patch the value directly

[
  {
    "op": "replace",
    "path": "/purchase_units/@reference_id=='default'/payee/email_address",
    "value": "[email protected]"
  }
]

Note that only a payee email_address can be patched; a merchant_id (if set instead) cannot be patched.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Preston PHX