Please~~~
Can anyone help?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Here is my code where I want to do a redirect after charge finish.
This handler is called when a button is pressed.
However, I found that $router.push cannot be recognised, while all my other $router.push work fine.
this.handler = StripeCheckout.configure({
key: Stripe.key,
image: "https://irp-cdn.multiscreensite.com/af471d46/dms3rep/multi/thumbnail/SUMMIT-LOGO-768x739.png",
locale: 'au',
email: this.email,
token: function(token) {
this.stripeToken = token.id;
this.stripeEmail = token.email;
let formData = {
email : this.email,
stripeToken : token.id,
stripeEmail : token.email
};
let self = this;
axios.post('/api/form/purchase',formData).then(response => {
console.log(self.$router); // this gives undefined warning
self.$router.push({name: 'form'}) // this gives error 'push' of undefined
}).catch(error => {
console.log("errrrrr: ", error); // the error get printed through this statement
})
}
});
},
The above piece of code is called here:
methods:{
buy(){
this.handler.open({
name: 'GCC',
description: 'The online purchase channel',
currency: 'AUD',
amount: 10000
});
}
}
So I'm wondering any one can help on this? How can I make an AJAX redirect after purchase.
It's Laravel 5.5
Alright,
Here is the answer, for those who might feel struggling.
I replaced this with vm, and made this statement just before declaring this.handler, since the shadow effect of this so this is actually not referring the vue instance inside StripeCheckout instance.
Please or to participate in this conversation.