Copied to clipboard

Flag this post as spam?

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


  • Graham Carr 43 posts 263 karma points c-trib
    Nov 04, 2020 @ 07:27
    Graham Carr
    0

    Opayo query

    Hi Matt,

    The client has just sent a message as follows "we have noticed that on the SagePay site, when looking at new bookings, the basket items appear with a GUID code that correlates to the course an individual has booked on to, however previously, it had the data and name of the course so we could easily see which course the booking was made for"

    Do you know if there is any easy way of sending through the actual name of the item being purchased for each basket item through to Opayo rather than the GUID of the basket item?

    Thanks,

    Graham

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Nov 09, 2020 @ 15:10
    Matt Brailsford
    0

    Hi Graham,

    Sorry for the late reply on this, I messed up the notifications in my email so wasn't noticing them coming through 🤦‍♂️

    The Opayo provider was originally contributed by a community member so it's not one I'm currently 100% with. Looking at the code though at https://github.com/vendrhub/vendr-payment-provider-opayo/blob/dev/src/Vendr.PaymentProviders.Opayo/Helpers/OpayoInputLoader.cs#L69 I see we do pass the order lines, but just with the productReference and not the product name. We'd need to look into what else can be passed with the order lines and whether we can pass the product name along too.

    What does the client mean in terms of "data" was sent through too? Only issue here could be if it's very specific to the client, we couldn't make that change as we need the provider to work for everyone, but if it's something that can be done in a generic way that helps others, we can make that change.

    Matt

  • Graham Carr 43 posts 263 karma points c-trib
    Nov 09, 2020 @ 15:17
    Graham Carr
    0

    Hey Matt,

    No worries, not a problem.

    It is essentially the product name that needs passing and showing, I have got a snapshot decorator setup that changes the product name as follows:

        public class CompositeNameUmbracoProductSnapshotDecorator : ProductSnapshotBase
    {
        private readonly UmbracoProductSnapshot _snapshot;
    
        public CompositeNameUmbracoProductSnapshotDecorator(UmbracoProductSnapshot snapshot)
        {
            _snapshot = snapshot;
        }
    
        public override string Name => _snapshot.Content.ContentType.Alias == "courseDate"
            ? $"{_snapshot.Content.Parent.Parent.Parent.Name} - {_snapshot.Name}"
            : $"{_snapshot.Content.Parent.Name} - {_snapshot.Name}";
    
        #region Passthrough
    
        public override Guid StoreId => _snapshot.StoreId;
    
        public override string ProductReference => _snapshot.ProductReference;
    
        public override string Sku => _snapshot.Sku;
    
        public override Guid? TaxClassId => _snapshot.TaxClassId;
    
        public override IEnumerable<ProductPrice> Prices => _snapshot.Prices;
    
        public override IDictionary<string, string> Properties => _snapshot.Properties;
    
        public override bool IsGiftCard => _snapshot.IsGiftCard;
    
        #endregion
    }
    

    That is what they are referring to when they saying data, it is the new name that I have associated with products as above.

    If it isn't something that you deem to be generic then I can look to make the change myself, just let me know.

    Thanks,

    Graham

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Nov 09, 2020 @ 15:31
    Matt Brailsford
    0

    Hi Graham,

    Then in that case the only things that need to be worked out is how to pass the order line Name through as name generated from the snapshot is copied to the order line so I think any change that needs to be made should be perfectly generic enough to be useful for others.

    Really appreciate you taking a look. Do let me know if there is anything you need my help with.

    Matt

  • Nik 1612 posts 7258 karma points MVP 7x c-trib
    Nov 09, 2020 @ 17:36
    Nik
    0

    Hey Graham,

    Following on from what Matt said, if you want to update it to handle Basket details more than the bare minimum I've set it up with you can find the details of what Opayo expects here:

    https://www.opayo.co.uk/file/12246/download-document/SERVERIntegrationandProtocolGuidelines_010814.pdf?token=zlCqBGKB7BlA503YTOOtRsBXWKcI4aVrqNSETHDIspk

    I think the reason that this wasn't implemented fully was the number of "Settings" that would be needed in order to map all the data. There are lots of things that can potentially be sent over and it can get quite overwhelming :-)

  • Graham Carr 43 posts 263 karma points c-trib
    Nov 09, 2020 @ 19:07
    Graham Carr
    0

    Hi Nik,

    Thanks for the reply, and yeah I can imagine with all the data that Opayo can receive then the settings would get quite overwhelming.

    As it is, I think the issue is where Matt highlights on this line https://github.com/vendrhub/vendr-payment-provider-opayo/blob/dev/src/Vendr.PaymentProviders.Opayo/Helpers/OpayoInputLoader.cs#L69

    Looking at the Opayo integration guide, the first field it expects for an order line is the item description, currently the provider is sending through the product reference which is just a GUID which is not very descriptive, the change I propose is to pass through the item name instead which would match what Opayo is expecting in that field.

    I will create a PR for the very minor change (minor but very important for my client!

    :D

    enter image description here

  • Nik 1612 posts 7258 karma points MVP 7x c-trib
    Nov 09, 2020 @ 19:11
    Nik
    0

    Would it be worth passing through a "setting" that could a combination of properties? That would allow people to pass through the Product Name and the Product Code in a single entry?

    Also, there are 2 different ways of passing the basket through. If you look at the XML approach (which I think is the newer approach) it has separate fields for Product Name, Description, and Code. IIRC.

  • Graham Carr 43 posts 263 karma points c-trib
    Nov 09, 2020 @ 19:19
    Graham Carr
    0

    Unfortunately I don't currently have the time to rebuild the provider to use the Basket XML method and the client want's a fix for tomorrow so for now the easiest option for me is to change the order line properties to suit what I require.

    Let me know if you still want a PR for the small tweak, if not I will just create a custom NuGet package and use that for my client's implementation.

    If I manage to get some spare time then I will look to change it to the Basket XML method utilising a setting to specify what order line properties to pass through.

  • Nik 1612 posts 7258 karma points MVP 7x c-trib
    Nov 09, 2020 @ 19:34
    Nik
    0

    I think a PR would be good, but maybe make it use a setting so it users of it can pull in what ever property on the order line they want to use? That would give the most flexibility in ease? Don't know what you think about that idea? If the property is left blank, then maybe fall back to a string in the format of:

    ProductName (ProductSKU) as that is probably the most useful information?

    But it's Matt's call really :-D

  • Graham Carr 43 posts 263 karma points c-trib
    Nov 09, 2020 @ 20:16
    Graham Carr
    100

    Yeah, good idea, adding a setting with the fallback option seemed to be the best way forwards for now, would be good at some point to refactor to use the Basket XML method, one for another day though!

    I have done the changes anyway and created the following PR for Matt's attention, also has a screenshot with the fallback working in action.

    https://github.com/vendrhub/vendr-payment-provider-opayo/pull/2

    Thanks for all your help, much appreciated! :D

Please Sign in or register to post replies

Write your reply to:

Draft