PAYPAL php SDK v1.0.1, 无法设置收款人邮箱
Posted
技术标签:
【中文标题】PAYPAL php SDK v1.0.1, 无法设置收款人邮箱【英文标题】:PAYPAL php SDK v1.0.1, cannot set payee's email 【发布时间】:2021-02-05 19:52:13 【问题描述】:我正在尝试创建一个网站,将来自不同卖家的商品出售给不同的人。我使用的是 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",
"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"
【问题讨论】:
【参考方案1】:收款人对象数组仍然在错误的位置。这个调整后的样本对你有用吗? (未测试)
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'
)
)
)
);
【讨论】:
以上是关于PAYPAL php SDK v1.0.1, 无法设置收款人邮箱的主要内容,如果未能解决你的问题,请参考以下文章
您可以再使用 PayPal Php SDK 进行信用卡直接付款吗?
Paypal SDK 支付 - 无法捕获异常并接收 http 400
paypal-php-sdk 中的 PayPal-Mock-Response