PAYPAL php SDK v1.0.1, 无法设置收款人邮箱
PAYPAL php SDK v1.0.1, cannot set payee's email
我正在尝试制作一个网站,向不同的人销售来自不同卖家的商品。我使用的是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)
)
)
)
)
);
}
创建订单的内容如下returns:
{
"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",
"method": "GET"
},
{
"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'
)
)
)
);
}
我正在尝试制作一个网站,向不同的人销售来自不同卖家的商品。我使用的是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)
)
)
)
)
);
}
创建订单的内容如下returns:
{
"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",
"method": "GET"
},
{
"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'
)
)
)
);
}