2

I'm trying to get my app to work with the Adyen payment system. At a certain point I redirect the user to Adyen to make a payment. When the user is done, Adyen redirects to the provided return url. Adyen also adds some query parameters to the url, that are useful to use on the return url page.

This is an example of a url that Adyen redirects to after payment: http://my.domain/#/payment/result?authResult=AUTHORISED&merchantReference=000220-16402-1459625180&merchantSig=BjeKwBOp70hcsNRD8GUat3fHn4qXxX4Bb2Nxg9RRa04%3D&paymentMethod=mc&pspReference=8614596253051402&shopperLocale=en_GB&skinCode=wMrD9Eei

Now, I want to use UI-Router to get me to the proper page, and load the right controller. Depending on the value in the query parameter authResult, I want to go to a different state. I have created a state for /payment/result?authResult:

$stateProvider.state('payment.result', {
    url: '/payment/result?authResult',
    templateUrl: IM_APP_DIR + '/views/payment.result.html',
    controller: function($state, $stateParams) {
        switch ($stateParams.authResult) {
            case 'AUTHORISED':
                $state.go('payment.authorised');
                break;
            case 'CANCELLED':
                $state.go('payment.cancelled');
                break;
            etcetera...
        }
    }
});

Example for the authorised state:

.state('payment.authorised', {
    url: '/payment/authorised',
    templateUrl: IM_APP_DIR + '/views/payment.authorised.html,
    controller: 'PaymentCtrl'
})

Now when I test this and the Adyen test environment redirects met to the url mentioned above, the controller for the /payment/result?authResult state is never entered. (I placed a breakpoint at the line where the switch is defined, but Chrome never gets there.) Instead I get a lot of errors from angular in my console. They mainly say I am getting into an infinite digest loop (https://docs.angularjs.org/error/$rootScope/infdig?p0=10&p1=%5B%5D). I guess that has nothing to do with this problem, since this is also what happened when Adyen redirected to the return url and I had not yet defined any state for the redirect path.

Any ideas what may be wrong with the states I defined, taking the redirect url into account?

Thanks a lot in advance for any help!

Martijn
  • 274
  • 1
  • 4
  • 17

1 Answers1

1

Ok, I got it to work eventually. The problem was that I had the parent > child setup in the routing config all wrong. I had also omitted a ui-view directive element in the parent route that the child view could be rendered to.

Martijn
  • 274
  • 1
  • 4
  • 17