简体   繁体   中英

PayPal Orders V2 payee object in Checkout-PHP-SDK fails with amount error

I am integrating PayPal Checkout which works nicely unless I include a custom payee in the order body. I tried the PayPal PHP example at https://developer.paypal.com/docs/checkout/integration-features/custom-payee/ that looks like this:

  return array(
    'intent' => 'AUTHORIZE',
    'purchase_units' =>
      array(
        0 =>
          array(
            'amount' =>
              array(
                'currency_code' => 'USD',
                'value' => '220.00'
              )
          ),
          array(
            'payee' =>
              array(
                'email_address' => 'payee@email.com'
              )
          )
      )
  );

Trying to create an order will lead to this error message (which seems to be completely wrong as it complaints about fields that are neither there nor needed):

{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"65a47f1e8defd","details":[{"field":"/purchase_units/1/amount","value":"","location":"body","issue":"MISSING_REQUIRED_PARAMETER","description":"A required field / parameter is missing."}],"links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-MISSING_REQUIRED_PARAMETER","rel":"information_link","encType":"application/json"}]} [/var/www/web15/htdocs/retroplace/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php:215]

If I remove the portion with the payee, everything works fine. But I need the payee in the order...

Do you have PHP errors/warnings enabled ? that looks like it might be bad PHP syntax

Try putting:

        'payee' =>
          array(
            'email_address' => 'payee@email.com'
          )

Within the array above (second key, in the same array as 'amount')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM