我正在尝试将 Stripe 支付网关放到我的项目中。如果客户成功完成付款,我想调用 API 函数“orderStatusUpdate”调用。任何人都可以帮助我。
loadStripe() {
if(!window.document.getElementById('stripe-script')) {
var s = window.document.createElement("script");
s.id = "stripe-script";
s.type = "text/javascript";
s.src = "https://checkout.stripe.com/checkout.js";
window.document.body.appendChild(s);
}
}
pay(amount) {
var handler = (<any>window).StripeCheckout.configure({
key: 'Publishable key',
locale: 'auto',
token: async function (token: any) {
console.log(token)
//IN HERE i try to put function ("this.orderStatusUpdate"), but it will give error.
}
});
this.orderStatusUpdate()
handler.open({
name: 'Project',
description: 'Online payment API',
amount: amount * 100,
currency : '$'
});
}
orderStatusUpdate() {
alert("Testing")
}
最佳答案
This为我工作,将其更改为箭头函数:token: function (token: any) {
至 token: (token: any) => {
关于javascript - 如果 strip 支付成功,如何调用函数?在 Angular ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59616384/