Copied to clipboard

Flag this post as spam?

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


  • Fabio Milheiro 74 posts 136 karma points
    Oct 29, 2012 @ 15:34
    Fabio Milheiro
    0

    uCommerce: How to customise notification URL?

     

    We need to customise the notification url in uCommerce in order to use to test it locally. Sys guys suggested that I use one of our servers as the notification URL (e.g. the ourserver.com/notification-url will redirect the request to local.mylocalhost.com/notification-url).
    This seems nice, but how do I find the notification path?

     

  • Søren Spelling Lund 1797 posts 2786 karma points
    Oct 31, 2012 @ 17:54
    Søren Spelling Lund
    0

    Hi Fabio, 

    You can override the notification URL in the SagePay.config to anything you want. Ultimately though you'll have to hit the PaymentProcessor.axd, end point with proper parameter to ensure that the payment is updated with the correct status and the Basket converted to an Order. 

  • Fabio Milheiro 74 posts 136 karma points
    Nov 01, 2012 @ 19:42
    Fabio Milheiro
    0

    Yes Søren, I can see that now. And I have found that we need to put two parameters in the URL /{paymentMethodId}/{paymentId}/PaymentProcessor.axd.

    Then how can we configure this parameters? I could hardcode the paymentMethodId for testing purposes but not the paymentId that changes everytime.

    I managed to sort the problem with Portfusion and binding my site to the same URL of the server that redirects to the requests to my machine. But if we have an option (auto) in notificationURL I wonder if there exists somewhere documentation about how to actually customise it without hardcoding values to it.

    Does it exist some I haven't found?

     

    Thanks!

  • Søren Spelling Lund 1797 posts 2786 karma points
    Nov 02, 2012 @ 10:05
    Søren Spelling Lund
    0

    It's possible, but it's undocumented.

    You can actually implement a secondary interface, which lets you take over how payment information is extracted from the callback and thus which information you can support.

    You can inherit the default SagePay provider, implement this interface, and completely take over how the payment is located.

        /// <summary>
        /// Extracts a <see cref="Payment"/> from HTTP request.
        /// </summary>
        /// <remarks>
        /// The extractor is typically used when dealing with a callback or IPNs from a remote payment gateway,
        /// which does not support dynamic URLs in the form of /#PaymentMethodId#/#PaymentId#/PaymentProcessor.axd.
        /// The extractor will find the unique payment id or reference id in the HTTP request and load up the appropriate
        /// payment.
        /// </remarks>
        public interface IHttpPaymentExtractor
        {
            Payment Extract(HttpRequest httpRequest);
        }

    Here's an example of how we use it to find the proper payment for Amazon:

        /// <summary>
        /// Responsible for extracting payment from Amazon IPN requests.
        /// </summary>
        public class AmazonHttpPaymentExtractor : IHttpPaymentExtractor
        {
            /// <summary>
            /// Extracts the specified HTTP request.
            /// </summary>
            /// <param name="httpRequest">The HTTP request.</param>
            /// <returns></returns>
            public Payment Extract(HttpRequest httpRequest)
            {
                var callerReference = httpRequest["callerReference"];
    
                if (string.IsNullOrEmpty(callerReference))
                    throw new NullReferenceException(string.Format("'callerReference' not posted to the extractor. Query string: {0}.", httpRequest.QueryString));
    
                Payment payment = Payment.All().SingleOrDefault(x => x.ReferenceId == callerReference);
    
                if (payment == null)
                    throw new NullReferenceException(string.Format("Could not find a payment with 'callerReference': {0}.", callerReference));
    
                return payment;
            }
        }

    Hope this helps.

  • Fabio Milheiro 74 posts 136 karma points
    Nov 22, 2012 @ 13:26
    Fabio Milheiro
    0

    Sorry I didn't reply to this. I had implemented without customising the notification URL.

    But certainly this will be helpful in the future!

    Thanks,

    Fabio

Please Sign in or register to post replies

Write your reply to:

Draft