My client would like to be abe to track/log orders that comes back from the payment gateway (SagePay in this case) with an unsuccessful transaction (eg failed or cancelled). They use the information to proactively contact the customer, or so they have the information to hand if the customer then phones them direct.
Currently, SagePay does the callback and then redirects to the site's "Cancel" page, so I guess one option would be to fire off an email from that page. However, it's also possible to just browse directly to the cancel page URL, so I would need to check that this is an *actual* fail, rather than just a direct browse to the page (eg from a search bot).
I thought I would check the HTTP_REFERER, but that seems to be null, even after the redirect from SagePay.
I thought I might check the actual order information, but TransactionInformation.PaymentState is set to "Initialized" before going to SagePay, and continues to show as "Initialized" after coming back from an unsuccessful order, so I can't test for that either. (What is TransactionInformation.PaymentState used for?)
Is there any way of hooking into a failed/cancelled order 'event'?
Sagepay redirects to a magic url in Tea Commerce that then redirects to the cancel url specified at the payment provider settings. You would need to inherit from the Sagepay payment provider and program your own provider that does some magic with sending info in the URL back to the cancel url. The payment providers are open source.
I'm creating a GUID order property when the user initiates the checkout process, and then my custom payment provider is overriding the GetCancelUrl method and appending that GUID value to the cancel URL as a querystring parameter.
Then, when the user is returned to the "Cancel" page, I can check the current order property against the querystring value, and send out an email if they match. I then immediately update the GUID in the order property, so a page refresh doesn't re-send the email.
What to do with cancelled/failed orders?
My client would like to be abe to track/log orders that comes back from the payment gateway (SagePay in this case) with an unsuccessful transaction (eg failed or cancelled). They use the information to proactively contact the customer, or so they have the information to hand if the customer then phones them direct.
Currently, SagePay does the callback and then redirects to the site's "Cancel" page, so I guess one option would be to fire off an email from that page. However, it's also possible to just browse directly to the cancel page URL, so I would need to check that this is an *actual* fail, rather than just a direct browse to the page (eg from a search bot).
I thought I would check the HTTP_REFERER, but that seems to be null, even after the redirect from SagePay.
I thought I might check the actual order information, but TransactionInformation.PaymentState is set to "Initialized" before going to SagePay, and continues to show as "Initialized" after coming back from an unsuccessful order, so I can't test for that either. (What is TransactionInformation.PaymentState used for?)
Is there any way of hooking into a failed/cancelled order 'event'?
Mike
Hi Mike
Sagepay redirects to a magic url in Tea Commerce that then redirects to the cancel url specified at the payment provider settings. You would need to inherit from the Sagepay payment provider and program your own provider that does some magic with sending info in the URL back to the cancel url. The payment providers are open source.
Kind regards
Anders
Hi Anders,
That seems to work.
I'm creating a GUID order property when the user initiates the checkout process, and then my custom payment provider is overriding the GetCancelUrl method and appending that GUID value to the cancel URL as a querystring parameter.
Then, when the user is returned to the "Cancel" page, I can check the current order property against the querystring value, and send out an email if they match. I then immediately update the GUID in the order property, so a page refresh doesn't re-send the email.
Works like a charm.
Cheers,
Mike
is working on a reply...