Copied to clipboard

Flag this post as spam?

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


  • Gordon Saxby 1461 posts 1883 karma points
    Jun 09, 2022 @ 08:49
    Gordon Saxby
    0

    Default values for a PaymentProvider

    Just looking at creating a custom PaymentProvider and want to provide default values for some of the settings.

    In the TeaCommerce system, I did it using

        public override IDictionary<string, string> DefaultSettings
        {
            get
            {
                return new Dictionary<string, string> {
                    { "form_url", "" },
                    { "continue_url", "" },
                    { "cancel_url", "" },
                    { "capture", "false" },
                    { "environment", "sandbox" },
                    { "payment_processor", "ProcessingPartners"}
                };
            }
        }
    

    Is this still the correct / best way to do it?

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 09, 2022 @ 08:57
    Matt Brailsford
    0

    Hey Gordon,

    Good question. I've just looked and we do have a DefaultSettings property on payment providers, but it looks like I may not actually be using it anywhere 🤦‍♂️

    I guess it must have got missed when we set this up but nobody has used it till now, which is pretty impressive.

    I'll add it to our issue tracker, but I think I'm going to have to say it's currently unsupported.

    Thanks for bringing this up, but appologies this isn't the ideal answer

  • Gordon Saxby 1461 posts 1883 karma points
    Jun 09, 2022 @ 09:03
    Gordon Saxby
    0

    OK, well at least asking the question saved me time trying to figure out why it didn't work ;-)

    Could I add code to my payment provider "settings" class (in the "Get")? The defaults will be in our app settings JSON file, so would want to retrieve them from there.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 09, 2022 @ 09:59
    Matt Brailsford
    0

    Ok, so if you don't mind running on an unreleased build, I think I've just implemented this.

    I've made it so that you can define default values on your settings POCO and Vendr will automatically apply these when a payment providers is being created (if you deleted the value then save it, it won't try to set the default value again).

    public class InvoicingSettings
    {
        [PaymentProviderSetting(Name = "Continue URL", Description = "The URL to continue to after this provider has done processing. eg: /continue/")]
        public string ContinueUrl { get; set; } = "/continue";
    }
    

    or if you want to do it within your constructor

    public class InvoicingSettings
    {
        [PaymentProviderSetting(Name = "Continue URL", Description = "The URL to continue to after this provider has done processing. eg: /continue/")]
        public string ContinueUrl { get; set; }
    
        public InvoicingSettings()
        {
            ContinueUrl = "/continue";
        }
    }
    

    If you want to try this, there will be a 2.3.0-beta00041 available on our unstable NuGet feed at https://nuget.outfield.digital/unstable/vendr/v3/index.json shortly.

    There is no launch date for this version yet as this also the version that supports v10 so we need to wait till that is launched, but that shouldn't stop it being used on v9 for now.

  • Gordon Saxby 1461 posts 1883 karma points
    Jun 09, 2022 @ 10:05
    Gordon Saxby
    0

    OK, thanks Matt.

    I'll take a look at that later. We are still at an early stage in development, so I suspect v10 will be out before we are finished!

Please Sign in or register to post replies

Write your reply to:

Draft