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

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-11 13:41:21

问题


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...


回答1:


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')



来源:https://stackoverflow.com/questions/62828839/paypal-orders-v2-payee-object-in-checkout-php-sdk-fails-with-amount-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!