Search code examples
angularjsnode.jspayumoney

Redirecting to AngularJS route after success payment


I am integrating PayUMoney app in my mean stack application.Now after payment is successfully done payumoney calls my success api. Now i need to render the response of this api call to my angularjs view page.

How can i achieve this?


Solution

  • Consider the response returned from the PayUMoney are a few parameters like success=true&transactionId=2342418083&ref=18.

    So when you receive these parameters in your server side code, redirect the user to the Angular page with those as query parameter like:

    // TODO this is a Grails way of redirect, do according to your app
    redirect(uri: "/#/payment/success?success=true&transactionId=2342418083&ref=18")
    

    Now, in the Angular controller of payment/success page, you can use $location service to get those parameters:

    fooApp.controller("PaymentSuccessController", function($scope, $location) {
        var params = $location.search();
        // Now use these paramters
        console.log(params.transactionId == "2342418083");
    });