Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mike Taylor 155 posts 353 karma points
    Dec 04, 2014 @ 13:04
    Mike Taylor
    0

    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

  • Anders Burla 2560 posts 8256 karma points
    Dec 05, 2014 @ 09:01
    Anders Burla
    100

    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

  • Mike Taylor 155 posts 353 karma points
    Dec 05, 2014 @ 11:51
    Mike Taylor
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft