沙盒中未触发 Paypal webhook 事件
Posted
技术标签:
【中文标题】沙盒中未触发 Paypal webhook 事件【英文标题】:Paypal webhooks events are not triggered in sandbox 【发布时间】:2017-12-04 00:22:50 【问题描述】:您好,我正在使用以下设置
已创建 paypal 商家和客户沙盒帐户 已配置的 paypal REST API 应用程序 向我的服务器添加了一个 webhook url,并已验证它可以使用 webhook simulator 使用了 here 找到的 Express Checkout javascript 实现在沙盒中查看通知时,我可以成功付款,但从未触发任何 webhook ???
以下是我使用的 javascript 实现示例,请不要将它嵌入到 Coldfusion 脚本文件中,因此使用主题标签。
`
var items = #paypalItems#;
// Render the PayPal button
paypal.Button.render(
env: '#application.config.paypal.bSandbox ? "sandbox" : "production"#', // sandbox | production
commit: true,
//style the button
style:
label: 'pay'
,
// PayPal Client IDs - replace with your own
client:
sandbox: '#application.config.paypal.sandbox_key#',
production: '#application.config.paypal.live_key#'
,
// Wait for the PayPal button to be clicked
payment: function(data, actions)
// Make a client-side call to the REST api to create the payment
return actions.payment.create(
payment:
transactions: [
amount:
total: #trim(numberFormat( application.oCart.getTotal(bDiscount=1,bShipping=1) , "99999999.99" ))#,
currency: "AUD",
details:
subtotal: #trim(numberFormat( application.oCart.getTotal() - application.oCart.getAmountGST( amount=application.oCart.getTotal(bDiscount=1), addGST=false ), "99999999.99" ))#,
tax: #trim(numberFormat(application.oCart.getAmountGST( amount=application.oCart.getTotal(bDiscount=1), addGST=false ), "99999999.99" ))#,
shipping: #trim(numberFormat( application.oCart.oShipping.getCartShippingAmount(country=session.fcbshoppingCart.order.shippingCountry), "99999999.99" ))#
,
invoice_number: "#orderNumber#",
item_list:
items: items,
shipping_address:
recipient_name: "#session.fcbshoppingCart.customer.firstName# #session.fcbshoppingCart.customer.lastName#",
line1: "#session.fcbshoppingCart.order.shippingAddress1#",
line2: "#session.fcbshoppingCart.order.shippingAddress2#",
city: "#session.fcbshoppingCart.order.shippingSuburb#",
country_code: "#paypalCountryCode#",
postal_code: "#session.fcbshoppingCart.order.shippingPostCode#",
state: "#session.fcbshoppingCart.order.shippingState#"
]
);
,
// Wait for the payment to be authorized by the customer
onAuthorize: function(data, actions)
console.log( "Paypal Authorize:", data );
// Execute the payment
return actions.payment.execute().then(function(payment)
console.log( "Paypal Response:", payment );
//payment has been accepted so we can now generate an order
$.ajax(
type: "get",
url: "/apps/paypal/createOrder.cfm",
data:
transactionNumber: "#orderNumber#",
payPalPaymentId: data.paymentID
,
dataType: "json",
success: function( res )
console.log('edharry create order data', res);
if( res.BPAYMENTPROCEED )
$('##paypal-message').addClass("show success").text('Payment Successfully Complete!');
//lets redirect to the checkout success page.
window.location.href = window.location.origin + '/shop/checkout/confirmation?productOrder=' + res.PRODUCTORDER.OBJECTID;
else
//need to handle a failed transaction
$('##paypal-message').addClass("show failure").text('Payment did not complete on server!');
,
error: function()
//lets show an error
$('##paypal-message').addClass("show failure").text('Payment did not complete on server!');
)
$('##paypal-message').addClass("show success").text('Payment Successfully Complete!');
);
,
onCancel: function(data)
console.log('The payment was cancelled!');
, '##paypal-button-container');`
【问题讨论】:
【参考方案1】:这是 Paypal 的一个持续问题。他们知道这个问题,目前正在努力解决这个问题。
【讨论】:
以上是关于沙盒中未触发 Paypal webhook 事件的主要内容,如果未能解决你的问题,请参考以下文章
无法在沙盒中测试付款撤销 webhook 事件。贝宝 REST API
Paypal 争议沙盒测试,触发 CUSTOMER.DISPUTE.RESOLVED 事件