PAYPAL php SDK v1.0.1,无法设置收款人的电子邮件

问题描述

我正在尝试创建一个网站,该网站出售不同卖家的商品以区别对待人们。我正在使用PHP SDK,无法在请求正文中设置收款人的电子邮件。我已经检查过文档,根据paypal-orders-v2-payee-object-in-checkout-php-sdk-fails-with-amount-error的说法,放置位置有误,因此我进行了相应的修复。但是我的响应(来自创建订单)表明收款人与我设定的不同。

这是createorder.PHP中的请求生成函数,当用户单击“付款”按钮时会调用函数

function buildrequestBody()
{
    return array(
        'intent' => 'CAPTURE','application_context' =>
            array(
                'return_url' => 'https://example.com/return','cancel_url' => 'https://example.com/cancel'
            ),'purchase_units' =>
                array(
                  0 =>
                    array(
                      'amount' =>
                        array(
                          'currency_code' => 'EUR','value' => '221.00'
                        ),array(
                      'payee' =>
                        array(
                          'email_address' => 'sb-qloys3515897@business.example.com'//a business account which I created (sandBox)
                          )
                      )
                  )

                )
            );
 }

这是订单创建返回的内容

{
  "statusCode": 201,"result": {
    "id": "5P300384200963842","intent": "CAPTURE","status": "CREATED","purchase_units": [
      {
        "reference_id": "default","amount": {
          "currency_code": "EUR","value": "221.00"
        },"payee": {
          "email_address": "sb-acw7h3524652@business.example.com",//the email is different (this is actually the sandBox's default business account)
          "merchant_id": "HYDLKKLS2AC9G"
        }
      }
    ],"create_time": "2020-10-22T18:01:17Z","links": [
      {
        "href": "https://api.sandBox.paypal.com/v2/checkout/orders/5P300384200963842","rel": "self","method": "GET"
      },{
        "href": "https://www.sandBox.paypal.com/checkoutNow?token=5P300384200963842","rel": "approve",{
        "href": "https://api.sandBox.paypal.com/v2/checkout/orders/5P300384200963842","rel": "update","method": "PATCH"
      },{
        "href": "https://api.sandBox.paypal.com/v2/checkout/orders/5P300384200963842/capture","rel": "capture","method": "POST"
      }
    ]
  },"headers": {
    "": "","Cache-Control": "max-age=0,no-cache,no-store,must-revalidate","Content-Length": "748","Content-Type": "application/json","Date": "Thu,22 Oct 2020 18","Paypal-Debug-Id": "88a1fa19cd8c9"
  }
}

解决方法

收款人对象数组仍然放置在错误的位置。调整后的样本对您有用吗? (未经测试)

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