我正在尝试设置一个paypal Express实例并将网站上的订单号传递给paypal交易,因此客户有一个参考。这就是他们以前的系统如何使用express,但现在我们已经从头开始重建网站,没有从Paypal上找到有关自定义值的任何有用文档,甚至没有传递描述。
我尝试了PayPal Express Checkout.js - send custom parameters,这两个解决方案对我的PayPal Sandbox都没有任何作用。 paypal提供的通知仅包括帐户信息和付款金额,显然这不对吗?
我一直在关注这些文档:https://developer.paypal.com/demo/checkout/#/pattern/client
这是vanilla checkout.js客户端结帐:
<!DOCTYPE html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
</head>
<body>
<div id="paypal-button-container"></div>
<script>
paypal.Button.render({
env: 'sandbox', // sandbox | production
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: 'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R',
production: '<insert production client id>'
},
// Show the buyer a 'Pay Now' button in the checkout flow
commit: true,
// payment() is called when the button is clicked
payment: function(data, actions) {
// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '0.01', currency: 'USD' }
}
]
}
});
},
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions) {
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function() {
window.alert('Payment Complete!');
});
}
}, '#paypal-button-container');
</script>
</body>
我已尝试形成data
对象并将其传入,但它要么无法正常工作,要么根本不会发生任何事情。我还尝试添加到付款阵列,但PayPal沙盒端没有任何事情发生。
如何填写红圈?我需要用户刚购买的产品说明,还需要将我的订单号从网站传递到PayPal吗?我确实无法在paypal文档上找到任何有助于此的内容。
有人能够如此善良地引导我朝着正确的方向前进吗?我觉得我错过了一些简单的事情
答案 0 :(得分:0)
我和paypal谈过,他们实际上没有直接的文档,他们仍然在为很多功能创建文档。
您可以在paypal提供的cURL调用示例中使用JSON数组
-d'{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "30.11",
"currency": "USD",
"details": {
"subtotal": "30.00",
"tax": "0.07",
"shipping": "0.03",
"handling_fee": "1.00",
"shipping_discount": "-1.00",
"insurance": "0.01"
}
},
"description": "This is the payment transaction description.",
"custom": "EBAY_EMS_90048630024435",
"invoice_number": "48787589673",
"payment_options": {
"allowed_payment_method": "INSTANT_FUNDING_SOURCE"
},
"soft_descriptor": "ECHI5786786",
"item_list": {
"items": [
{
"name": "hat",
"description": "Brown color hat",
"quantity": "5",
"price": "3",
"tax": "0.01",
"sku": "1",
"currency": "USD"
},
{
"name": "handbag",
"description": "Black color hand bag",
"quantity": "1",
"price": "15",
"tax": "0.02",
"sku": "product34",
"currency": "USD"
}
],
"shipping_address": {
"recipient_name": "Hello World",
"line1": "4thFloor",
"line2": "unit#34",
"city": "SAn Jose",
"country_code": "US",
"postal_code": "95131",
"phone": "011862212345678",
"state": "CA"
}
}
}
],
"note_to_payer": "Contact us for any questions on your order.",
"redirect_urls": {
"return_url": "https://example.com",
"cancel_url": "https://example.com"
}
}'
对于"description": "Brown color hat",
transactions: [
{
amount: { total: $paying, currency: 'CAD' },
description: 'This is a test description',
}
]
我不知道为什么PayPal Express Checkout.js - send custom parameters中提供的解决方案对我不起作用,可能是我的语法问题或缓存问题,但它今天正在运行! (当然......)