英文:
How to call function if success stripe payment? In Angular
问题
I'm try to put Stripe payment gateway to my project. I want to call API function "orderStatusUpdate" call if payment successfully done by customer. Can anyone to help me.
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 = (
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");
}
英文:
I'm try to put Stripe payment gateway to my project. I want to call API function "orderStatusUpdate" call if payment successfully done by customer. Can anyone to help me.
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")
}
答案1
得分: 1
这个 对我有用,将它改为箭头函数:
token: function (token: any) {
改为 token: (token: any) => {
英文:
This worked for me, change it to an arrow function:
token: function (token: any) {
to token: (token: any) => {
答案2
得分: 0
let that = this;
var handler = (<any>window).StripeCheckout.configure({
key: '可发布的密钥',
locale: '自动',
token: async function (token: any) {
console.log(token)
//在此处尝试放置函数("that.orderStatusUpdate")
}
英文:
let that = this;
var handler = (<any>window).StripeCheckout.configure({
key: 'Publishable key',
locale: 'auto',
token: async function (token: any) {
console.log(token)
//IN HERE try to put function (" that.orderStatusUpdate")
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论