在我的网页上,我试图使用JavaScript按照手册实现PayPal结账:https://developer.paypal.com/docs/checkout/
一切都与标准选项配合得很好。例如,这工作就好:
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
currency_code: 'EUR',
value: '120.16'
},
description: 'Purchase Unit test description',
custom_id: '64735',
}]
})
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' +
details.payer.name.given_name)
// Call your server to save the transaction
return fetch('/api/paypal-transaction-complete', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID: data.orderID
})
})
})
}
}).render('#paypal-button-container')
但当我试图更具体地了解订单细节时,它会给我一个错误:
Error: "Order Api response error:
{
"name": "INVALID_REQUEST",
"message": "Request is not well-formed, syntactically incorrect, or violates schema.",
"debug_id": "1ed03d18530c1",
"details": [
{
"location": "body",
"issue": "INVALID_SYNTAX",
"description": "Cannot deserialize instance of `com.paypal.api.platform.checkout.orders.v2.model.AmountBreakdown` out of START_ARRAY token line: 1, column: 82"
}
],
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_SYNTAX", "rel": "information_link", "encType": "application/json"
}
]
}"
}
这是我的代码:
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
currency_code: 'EUR',
value: '120.16',
breakdown: [{
item_total: {
unit_amount: 7,
currency_code: 'EUR',
value: '120.16'
}
}]
},
description: 'Purchase Unit test description',
custom_id: '64735',
items: [{
name: 'Test item 1',
unit_amount: {
currency_code: 'EUR',
value: '60.12'
},
quantity: 2,
description: 'Uaua item 1 description'
}, {
name: 'Test item 2',
unit_amount: {
currency_code: 'EUR',
value: '60.00'
},
quantity: 5,
description: 'Test item 2 description'
}]
}]
})
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' +
details.payer.name.given_name)
// Call your server to save the transaction
return fetch('/api/paypal-transaction-complete', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID: data.orderID
})
})
})
}
}).render('#paypal-button-container')
有人知道问题出在哪里吗?PayPal留档不是很翔实...
经过进一步的挖掘,我找到了正确的格式:
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [
{
reference_id: "PUHF",
description: "Some description",
custom_id: "Something7364",
soft_descriptor: "Great description 1",
amount: {
currency_code: "EUR",
value: "200.00",
breakdown: {
item_total: {
currency_code: "EUR",
value: "200.00"
}
}
},
items: [
{
name: "Item 1",
description: "The best item ever",
sku: "xyz-2654",
unit_amount: {
currency_code: "EUR",
value: "100.00"
},
quantity: "1"
},
{
name: "Item 2",
description: "Not bad too",
sku: "zdc-3942",
unit_amount: {
currency_code: "EUR",
value: "50.00"
},
quantity: "2"
}
],
}
]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name);
// Call your server to save the transaction
return fetch('/api/paypal-transaction-complete', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID: data.orderID
})
});
});
}
}).render('#paypal-button-container');
这是一个完整选项集的示例:
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
reference_id: "PUHF",
description: "Sporting Goods",
custom_id: "CUST-HighFashions",
soft_descriptor: "HighFashions",
amount: {
currency_code: "USD",
value: "230.00",
breakdown: {
item_total: {
currency_code: "USD",
value: "180.00"
},
shipping: {
currency_code: "USD",
value: "30.00"
},
handling: {
currency_code: "USD",
value: "10.00"
},
tax_total: {
currency_code: "USD",
value: "20.00"
},
shipping_discount: {
currency_code: "USD",
value: "10"
}
}
},
items: [{
name: "T-Shirt",
description: "Green XL",
sku: "sku01",
unit_amount: {
currency_code: "USD",
value: "90.00"
},
tax: {
currency_code: "USD",
value: "10.00"
},
quantity: "1",
category: "PHYSICAL_GOODS"
},
{
name: "Shoes",
description: "Running, Size 10.5",
sku: "sku02",
unit_amount: {
currency_code: "USD",
value: "45.00"
},
tax: {
currency_code: "USD",
value: "5.00"
},
quantity: "2",
category: "PHYSICAL_GOODS"
}
],
shipping: {
method: "United States Postal Service",
address: {
name: {
full_name: "John",
surname: "Doe"
},
address_line_1: "123 Townsend St",
address_line_2: "Floor 6",
admin_area_2: "San Francisco",
admin_area_1: "CA",
postal_code: "94107",
country_code: "US"
}
}
}]
})
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name)
// Call your server to save the transaction
return fetch('/api/paypal-transaction-complete', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID: data.orderID
})
})
})
}
}).render('#paypal-button-container')
是否可以使用新的paypal结账(请参阅:https://developer.paypal.com/docs/checkout/)使用自定义付款按钮(不带智能付款按钮),如以下实现屏幕截图所示? 有人可以告诉我一些指南或代码,如何做新的贝宝结账没有智能支付按钮? 原因:我们不想用paypal按钮破坏我们的设计,但我们想为用户提供相同的按钮,用于他选择的任何付款方式。
我正在实施贝宝结账。 我有以下javascript代码paypal.button.render({ 弹出(上图)出现时,我点击贝宝按钮,我可以填写信用卡细节等,如图像。它在沙箱所以我使用测试卡号。当我单击“立即付款”按钮时,它会显示“正在处理”,并一遍又一遍地返回到相同的表单。我现在可以在控制台或回调中看到信息 I.W希望看到我的警报 onauthorize:函数(数据,操作){
PayPal Checkout按钮点击本身打开PayPal安全窗口,其余工作正常。当客户点击第一个单选按钮时,我想再次打开PayPal安全窗口,即触发点击PayPal结账按钮。如果按钮本身出现在iframe中,而我无法触发该按钮跨域的单击事件,我该怎么做?有没有办法触发签出按钮的点击? 这里是超文本标记语言代码: 和Javascript代码: 编辑:作为一个工作的例子,我会建议这个网站,但这是有点
null 谢谢
PayPal Express Checkout for Payflow文档表示,可以通过将“useraction=commit”添加到将用户重定向到PayPal的URL来跳过获取Express Checkout Details步骤。但是,它还表示返回PAYERID参数以响应Get Express Checkout Details并执行Do Express Checkout支付。 当我测试没有PAY
我试图集成PayPal智能按钮在我的Laravel 8网站。这些是我使用的留档:https://developer.paypal.com/docs/checkout/integrate/ https://developer.paypal.com/docs/checkout/reference/server-integration/set-up-transaction/ https://github