使用 Android SDK 在 Kotlin 中的 PayPal API 订单请求
PayPal API Order Request in Kotlin using Android SDK
根据 paypal 的文档,您可以支付订单和类似的东西,但我不知道是否可以使用 Android SDK(下面的 link)发送这种请求:
curl -v -X POST https://api.sandbox.paypal.com/v1/checkout/orders \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token" \
-H "PayPal-Partner-Attribution-Id: EXAMPLE_MP" \
-d '{
"purchase_units": [
{
"reference_id": "store_mobile_world_order_1234",
"description": "Mobile World Store order-1234",
"amount": {
"currency": "USD",
"details": {
"subtotal": "1.09",
"shipping": "0.02",
"tax": "0.33"
},
"total": "1.44"
},
"payee": {
"email": "seller@example.com"
},
"items": [
{
"name": "NeoPhone",
"sku": "sku03",
"price": "0.54",
"currency": "USD",
"quantity": "1"
},
{
"name": "Fitness Watch",
"sku": "sku04",
"price": "0.55",
"currency": "USD",
"quantity": "1"
}
],
"shipping_address": {
"line1": "2211 N First Street",
"line2": "Building 17",
"city": "San Jose",
"country_code": "US",
"postal_code": "95131",
"state": "CA",
"phone": "(123) 456-7890"
},
"shipping_method": "United Postal Service",
"partner_fee_details": {
"receiver": {
"email": "partner@example.com"
},
"amount": {
"value": "0.01",
"currency": "USD"
}
},
"payment_linked_group": 1,
"custom": "custom_value_2388",
"invoice_number": "invoice_number_2388",
"payment_descriptor": "Payment Mobile World"
}
],
"redirect_urls": {
"return_url": "https://example.com/return",
"cancel_url": "https://example.com/cancel"
}
}'
Ps。似乎 getStuffToBuy()
(第 83 行)可以提出这个请求,但我不确定是否可以提出
purchase_units: [
{
reference_id: another field,
description: 'Hello World',
amount: {
currency_code: 'MXN',
value: "100.00"
}
}
]
Android SDK:
PayPal 的文档:
https://developer.paypal.com/docs/api/orders/v1/
非常感谢!
Android SDK 已弃用,生命周期将结束 [2020 年 12 月]
原回答
如果您需要用于处理 PayPal 付款的本机 SDK,请使用 Express Checkout via the Braintree SDK
为了进行身份验证,请使用 https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Fapplications on your server, and return a client token to your client. (production access token, https://www.paypal.com/api 底部的沙盒 访问令牌 )
不要创建 Braintree 网关帐户,也不要使用来自 braintreegateway.com 的网关凭据。不要使用标记化密钥。
2021 年 3 月更新
Native Checkout 现在在一些国家/地区可用,尤其是美国和欧洲:https://developer.paypal.com/docs/business/native-checkout/
对于非本地支付,也不应使用您链接到的订单 v1 文档。使用命令 v2,https://developer.paypal.com/docs/checkout/reference/server-integration/
根据 paypal 的文档,您可以支付订单和类似的东西,但我不知道是否可以使用 Android SDK(下面的 link)发送这种请求:
curl -v -X POST https://api.sandbox.paypal.com/v1/checkout/orders \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token" \
-H "PayPal-Partner-Attribution-Id: EXAMPLE_MP" \
-d '{
"purchase_units": [
{
"reference_id": "store_mobile_world_order_1234",
"description": "Mobile World Store order-1234",
"amount": {
"currency": "USD",
"details": {
"subtotal": "1.09",
"shipping": "0.02",
"tax": "0.33"
},
"total": "1.44"
},
"payee": {
"email": "seller@example.com"
},
"items": [
{
"name": "NeoPhone",
"sku": "sku03",
"price": "0.54",
"currency": "USD",
"quantity": "1"
},
{
"name": "Fitness Watch",
"sku": "sku04",
"price": "0.55",
"currency": "USD",
"quantity": "1"
}
],
"shipping_address": {
"line1": "2211 N First Street",
"line2": "Building 17",
"city": "San Jose",
"country_code": "US",
"postal_code": "95131",
"state": "CA",
"phone": "(123) 456-7890"
},
"shipping_method": "United Postal Service",
"partner_fee_details": {
"receiver": {
"email": "partner@example.com"
},
"amount": {
"value": "0.01",
"currency": "USD"
}
},
"payment_linked_group": 1,
"custom": "custom_value_2388",
"invoice_number": "invoice_number_2388",
"payment_descriptor": "Payment Mobile World"
}
],
"redirect_urls": {
"return_url": "https://example.com/return",
"cancel_url": "https://example.com/cancel"
}
}'
Ps。似乎 getStuffToBuy()
(第 83 行)可以提出这个请求,但我不确定是否可以提出
purchase_units: [
{
reference_id: another field,
description: 'Hello World',
amount: {
currency_code: 'MXN',
value: "100.00"
}
}
]
Android SDK:
PayPal 的文档:
https://developer.paypal.com/docs/api/orders/v1/
非常感谢!
Android SDK 已弃用,生命周期将结束 [2020 年 12 月]
原回答
如果您需要用于处理 PayPal 付款的本机 SDK,请使用 Express Checkout via the Braintree SDK
为了进行身份验证,请使用 https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Fapplications on your server, and return a client token to your client. (production access token, https://www.paypal.com/api 底部的沙盒 访问令牌 )
不要创建 Braintree 网关帐户,也不要使用来自 braintreegateway.com 的网关凭据。不要使用标记化密钥。
2021 年 3 月更新
Native Checkout 现在在一些国家/地区可用,尤其是美国和欧洲:https://developer.paypal.com/docs/business/native-checkout/
对于非本地支付,也不应使用您链接到的订单 v1 文档。使用命令 v2,https://developer.paypal.com/docs/checkout/reference/server-integration/