Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Receive Json Response in angular controller from a 3rd Party #2201


User avatar
0
george created

Hi there,

We are using a 3rd party service for developing an Online Payment application. The work flow of our application is as follows.

Step 1) We submit the amount and other details to a URL given by our online payment service provider through an AppService. Step 2) After submitting the data to the URL, we can get a response in the angular controller via the same appservice. Step 3) If the response returns 'success' we've to redirect the page to a 'redirectURL' which will be included in the response. Step 4) The 'redirectURL' will open the payment gateway page. Here the user can choose the payment methode and make the payment. Step 5) After making the payment, the payment gateway page will send a response to a URL which we provide. Here is the problem exists

We have to receive the response from the payment gateway in another page which will show the details from the payment response.

In this case, how can i receive the response sent from the payment gateway to my angular page?

The payment request is not initiated from our page. In that case I could use $http.post to send the request and get the response in my angular page itself. Here, it's happening from the payment gateway page. That's why we have to provide a callbackURL(responseURL) in the first request itself(mentioned in step-2).

So, I need to create a callbackURL page to receive the JSON response from an external URL.

Please help me.. I'm Stuck here..


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can do it like this,

    First create a seperate controller like PaymentController and create a Success, Error Actions for this controller. Give those urls to payment gateway for callbackUrl. If it does not require a cancellation url you can use only the success action.

    After a successfull payment, payment gateway will call your PaymentController's Success action, you can get the response from payment gateway here. Then you need to save it to a database table and get id of this record. You need to create a seperate table for this entity. You can call it PaymentResults or whatever you like :).

    Then create a view in your single page app to show this PaymentResult record. And redirect user to this url in your PaymentController's Success action after saving paymentResult to database.

    The link will be something like this.

    http://yourwebsiteaddress/Application#/paymentresults/5

    I hope this helps.