Copied to clipboard

Flag this post as spam?

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


  • Frans Lammers 57 posts 400 karma points c-trib
    Mar 23, 2023 @ 12:14
    Frans Lammers
    0

    Vendr - Is it possible to add a custom property to a paymentmethod

    One of our payment-providers that we use in Vendr calculates the paymentcosts as a percentage of the total order amount, instead of fixed costs. We would like to calculate this ourselves so we can charge these costs to the customer and present the costs before they choose the definitive paymentmethod.

    At the moment paymentproviders only accept an absolute Default Pricing, not a percentage. Is there a way for us to add it ourselves to the paymentmethod and adapt the Vendr backoffice so we can enter a value there?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 23, 2023 @ 14:39
    Matt Brailsford
    100

    Hmm,

    Not exactly. The best I could think to do is just use the price field on the payment method, but use it as a percentage, then override the default IPaymentCalculator to apply it as a percentage rather than a fixed amount.

    https://vendr.net/docs/core/3.0.0/key-concepts/calculators/

    Hope this helps

  • Frans Lammers 57 posts 400 karma points c-trib
    Mar 31, 2023 @ 13:38
    Frans Lammers
    0

    Hi Matt,

    I made a custom IPaymentCalculator with a CalculatePaymentMethodPrice like this:

    public Price CalculatePaymentMethodPrice(PaymentMethodReadOnly paymentMethod, Guid currencyId, Guid? countryId, Guid? regionId, TaxRate taxRate, PaymentCalculatorContext context)
    {
        if (paymentMethod.PaymentProviderAlias == Constants.PaymentProviders.Mollie)
        {
            var mollieSetting = // get my custom setting
            if (mollieSetting != null
                && mollieSetting.UsePercentage
                && mollieSetting.Percentage > 0)
            {
                // make a price of the percentage of the order
                var price = context.Order.SubtotalPrice.Value.WithoutTax / 100 * mollieSetting.Percentage;
                return new Price(price, 0, currencyId);
            }
        }
        // otherwise: use the standard
        return CalculatePaymentMethodPrice(paymentMethod, currencyId, countryId, regionId, taxRate);
    } 
    

    And I can see it used a lot of the time, but not always: on certain views the payment costs are shown on the ordersummary, on other views they are not.

    And the worst problem: the paymentcosts are not passed to Mollie when they are a percentage, only when they are fixed price.

    Did I make a mistake in the calculator, or is it not always called in the right place?

  • Frans Lammers 57 posts 400 karma points c-trib
    Mar 23, 2023 @ 15:18
    Frans Lammers
    0

    Hi Matt,

    I will look into the IPaymentCalculator.

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft