PAYPAL php SDK1.0.1,如何设置NO_SHIPPING
PAYPAL php SDK1.0.1, how to set NO_SHIPPING
我正在制作一个电子商务网站,该网站只销售数字产品(不送货)。所以我试图在请求创建中将“shipping_preferences”键设置为“NO_SHIPPING”,但它似乎不起作用(它没有给出任何错误)。我正在关注文档 here.
PHP代码(buildRequestBody):
function buildRequestBody()
{
return array(
'intent' => 'CAPTURE',
'purchase_units' =>
array(
0 =>
array(
'amount' =>
array(
'currency_code' => 'EUR',
'value' => '150.00'
),
'payee' =>
array(
'email_address' => 'sb-qloys3515897@business.example.com'
)
)
),
'order_application_context' =>
array(
'shipping_preferences' => 'NO_SHIPPING'
)
);
}
这是退回的json,(没有任何与运费相关的东西,所以在结帐时它仍然要求提供地址)
{
"statusCode": 201,
"result": {
"id": "23K326254X491844S",
"intent": "CAPTURE",
"status": "CREATED",
"purchase_units": [
{
"reference_id": "default",
"amount": {
"currency_code": "EUR",
"value": "150.00"
},
"payee": {
"email_address": "sb-qloys3515897@business.example.com"
}
}
],
"create_time": "2020-10-23T19:52:24Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/23K326254X491844S",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/checkoutnow?token=23K326254X491844S",
"rel": "approve",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/23K326254X491844S",
"rel": "update",
"method": "PATCH"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/23K326254X491844S/capture",
"rel": "capture",
"method": "POST"
}
]
},
"headers": {
"": "",
"Cache-Control": "max-age=0, no-cache, no-store, must-revalidate",
"Content-Length": "718",
"Content-Type": "application/json",
"Date": "Fri, 23 Oct 2020 19",
"Paypal-Debug-Id": "cc5deeef2624d"
}
}
我也试过'application_context'而不是'order_application_context',但结果是一样的(结账时要求送货地址,json和之前一样)
这是修改后的 PHP 代码:
return array(
'intent' => 'CAPTURE',
'application_context' =>
array(
'shipping_preferences' => 'NO_SHIPPING'
//'user_action' => 'PAY_NOW'
),
'purchase_units' =>
array(
0 =>
array(
'amount' =>
array(
'currency_code' => 'EUR',
'value' => '150.00'
),
'payee' =>
array(
'email_address' => 'sb-qloys3515897@business.example.com'
)
)
)
);
您链接到对象的定义,而不是文档中告诉您它在请求正文中的键名应该是什么的部分:https://developer.paypal.com/docs/api/orders/v2/#orders-create-request-body
也就是application_context
我正在制作一个电子商务网站,该网站只销售数字产品(不送货)。所以我试图在请求创建中将“shipping_preferences”键设置为“NO_SHIPPING”,但它似乎不起作用(它没有给出任何错误)。我正在关注文档 here.
PHP代码(buildRequestBody):
function buildRequestBody()
{
return array(
'intent' => 'CAPTURE',
'purchase_units' =>
array(
0 =>
array(
'amount' =>
array(
'currency_code' => 'EUR',
'value' => '150.00'
),
'payee' =>
array(
'email_address' => 'sb-qloys3515897@business.example.com'
)
)
),
'order_application_context' =>
array(
'shipping_preferences' => 'NO_SHIPPING'
)
);
}
这是退回的json,(没有任何与运费相关的东西,所以在结帐时它仍然要求提供地址)
{
"statusCode": 201,
"result": {
"id": "23K326254X491844S",
"intent": "CAPTURE",
"status": "CREATED",
"purchase_units": [
{
"reference_id": "default",
"amount": {
"currency_code": "EUR",
"value": "150.00"
},
"payee": {
"email_address": "sb-qloys3515897@business.example.com"
}
}
],
"create_time": "2020-10-23T19:52:24Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/23K326254X491844S",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/checkoutnow?token=23K326254X491844S",
"rel": "approve",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/23K326254X491844S",
"rel": "update",
"method": "PATCH"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/23K326254X491844S/capture",
"rel": "capture",
"method": "POST"
}
]
},
"headers": {
"": "",
"Cache-Control": "max-age=0, no-cache, no-store, must-revalidate",
"Content-Length": "718",
"Content-Type": "application/json",
"Date": "Fri, 23 Oct 2020 19",
"Paypal-Debug-Id": "cc5deeef2624d"
}
}
我也试过'application_context'而不是'order_application_context',但结果是一样的(结账时要求送货地址,json和之前一样)
这是修改后的 PHP 代码:
return array(
'intent' => 'CAPTURE',
'application_context' =>
array(
'shipping_preferences' => 'NO_SHIPPING'
//'user_action' => 'PAY_NOW'
),
'purchase_units' =>
array(
0 =>
array(
'amount' =>
array(
'currency_code' => 'EUR',
'value' => '150.00'
),
'payee' =>
array(
'email_address' => 'sb-qloys3515897@business.example.com'
)
)
)
);
您链接到对象的定义,而不是文档中告诉您它在请求正文中的键名应该是什么的部分:https://developer.paypal.com/docs/api/orders/v2/#orders-create-request-body
也就是application_context