gpt4 book ai didi

dart - Paypal 订单 v2 : the approveurl of the order ("checkoutnow?token..") returns 302 redirect

转载 作者:行者123 更新时间:2023-12-03 04:20:24 24 4
gpt4 key购买 nike

我正在努力使用 Orders v2 PayPal API 创建订单。
我有 token ,我使用这些 header 发出请求以创建订单:

{
"intent": "CAPTURE",
"purchase_units": [{
"description": "Payment",
"amount": {
"value": 'X',
"currency_code": "EUR",
"breakdown": {
"item_total": {
"currency_code": "EUR",
"value": 'X'
},
}
},
"items": [{
"unit_amount": {
"currency_code": "EUR",
"value": 'X'
},
"quantity": "1",
"name": 'item name',
}]
}],
"application_context": {
"brand_name": "My brand name",
"locale": "it-IT",
"return_url": 'my-return-url',
}
}
订单已创建,我得到 approveurl让用户付费。
approveurl我打这个电话:
try {
var response = await http.post(approveurl, body: jsonEncode({"payer_id": payerId}), headers: {
"content-type": "application/json",
'Authorization': 'Bearer ' + accessToken
});

final body = jsonDecode(response.body);
if (response.statusCode == 200) {
return body;
}
return null;
} catch (e) {
rethrow;
}
但我得到了这个回应:
url = "https://www.sandbox.paypal.com/checkoutnow?token=..."
payerId = "..."
accessToken = "..."
response = {Response}
request = {Request} POST https://www.sandbox.paypal.com/checkoutnow?token=...
statusCode = 302
reasonPhrase = "Found"
contentLength = 61
headers = {_InternalLinkedHashMap} size = 9
0 = {map entry} "paypal-debug-id" -> "95934918777a1"
1 = {map entry} "cache-control" -> "max-age=0, no-cache, no-store, must-revalidate"
2 = {map entry} "location" -> "/webapps/hermes?token=..."
3 = {map entry} "set-cookie" -> "X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D880%26app%3Dhermesnodeweb%26TIME%3D1595167415%26..."
4 = {map entry} "date" -> "Sun, 19 Jul 2020 14:03:35 GMT"
5 = {map entry} "vary" -> "Accept"
6 = {map entry} "strict-transport-security" -> "max-age=63072000"
7 = {map entry} "content-length" -> "61"
8 = {map entry} "content-type" -> "text/plain; charset=utf-8"
isRedirect = false
persistentConnection = true
response.body是:
Found. Redirecting to /webapps/hermes?token=...

最佳答案

With the approvalurl I do this call:


批准 URL 不适合您调用。它是一个 Web URL,而不是 API URL。付款客户需要登录并批准付款。
但是,将他们重定向到它会是一个糟糕的网络体验。对于现代网页设计,您应该提供“在上下文中”批准,您的网站仍然在后台加载。操作方法如下: https://developer.paypal.com/demo/checkout/#/pattern/server
通过此集成,您无需自己阅读approval_url,只需在从createOrder 获取时返回Order id。

关于dart - Paypal 订单 v2 : the approveurl of the order ("checkoutnow?token..") returns 302 redirect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62981710/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com