简体   繁体   中英

redirect to different page with success message after payment - Vue JS

I have a payment modal that opens up, once the user fills it out, and if the payment is successful, I want to redirect to a different page, with a success message. Im using Laravel 5.3 and Vue JS.

Right now, this is how it looks like, and I got it to redirect to a different page, but how would I attach some sort of success message?

this.$http.post('/cropkit/public/subscriptions', this.$data).then(
    window.location.replace('/cropkit/public/profile/dashboard'),
    response => this.status = response.body.status
);

/******** EDIT *********/

Here is the solution to check if is successful, or error occurred:

swal is a alert message plugin

                    this.$http.post('/mysite/subscriptions', this.$data).then((response) => {
                        swal({
                           title: "Success!",
                           text: "Payment has been processed!",
                           type: "success",
                           showConfirmButton: false,
                           allowEscapeKey: false,
                           allowOutsideClick: false,
                           timer: 5000,
                        }),
                        setTimeout(function(){
                            window.location.replace('/mysite/profile/dashboard');
                        }, 4000)
                    }, (response) => {
                        this.status = response.body.status
                    });

You could use the error callback.

return this.$http.post(url, data).then((response) => {
    // success, do success logic
}, (response) => {
    // redirect to error view
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM