• Resolved ryanothelo

    (@ryanothelo)


    Hi. I need help once again. My E-commerce site uses multiple Braintree Merchant accounts. How do I disable a payment method and/or remove the error message on top?

    My site uses the WooCommerce geolocation or the customer’s shipping country, if it’s available, to determine customer location. Once the customer’s location is determined, the currency for that zone is applied. I have different Braintree Merchant Account for each currency, as it is required. The situation may have started when I have some of the payment method disabled for some merchants and I for some I haven’t fully setup some of the payment method. I have an example below for my setup.

    ex.
    Currency/Merchant Account => Payment Method Available
    SGD => CC, Paypal, Google Pay, Apple Pay
    PHP => CC, Google
    AUD => CC, Paypal, Google Pay, Apple Pay

    So I would like to ask for help on how to:
    1. disable a payment method and hide error message if it’s not available on the current braintree merchant/ currency used (e.g. hide paypal and applepay on PHP merchant above)?
    2. disable a payment method and hide error message if payment method is not available due to some errors in setting up (e.g. paypal is not setup properly)?

    Thanks in advance!

    The page I need help with: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @ryanothelo,

    Thank you for contacting us. Is the error message you’re referring to the one where it says “there is no merchant account for the selected currency?”

    I want to make sure I understand the error message before I outline a way to restrict payment methods based on currency and country.

    Kind Regards,

    Thread Starter ryanothelo

    (@ryanothelo)

    Hi @mrclayton

    There are actually several, but primarily these are the errors that I want to handle now:

    “Please link your PayPal account in the Braintree control panel in order to use PayPal.”

    “There was an error loading the PayPal SDK. Please provide the following details to your plugin developer.PayPal config …”

    “Apple Pay is not enabled for this merchant”

    – instead of these showing up, how do i hide/disable the payment method(s) during execution that are not properly configured, not enabled for the merchant, or that returns an error for that specific merchant(currency)?

    The one that you’ve mentioned: “there is no merchant account for the selected currency?” is essential, although, i still want to be able to add to its handling.

    Best Regards,

    • This reply was modified 3 years, 1 month ago by ryanothelo.
    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @ryanothelo,

    Some of those error messages are there to inform you that your integration is not yet finished. For example, Apple Pay is not enabled for this merchant means you haven’t finished setting up Apple Pay in the Braintree account. Follow our documentation guide on how to do that.

    https://docs.paymentplugins.com/wc-braintree/config/#/braintree_applepay

    Please link your PayPal account in the Braintree control panel in order to use PayPal. means you haven’t linked your PayPal business account to the Braintree account. The docs also show you how to do that.

    https://docs.paymentplugins.com/wc-braintree/config/#/braintree_paypal

    Once you get those sorted out reply back and I will show you how to hide the payment options based on currency and country.

    Kind Regards,

    Thread Starter ryanothelo

    (@ryanothelo)

    hi @mrclayton,

    I’ve checked it again.

    1. Apple Pay
    For Apple Pay, I don’t have a dev account and I can’t have it yet. I can temporarily disable it in the admin, but in the future, we will only have selected support for each currency. I might as well know how to handle it in the future if a selected currency doesn’t support apple pay.

    2. Paypal
    I have 2 PHP merchant in my braintree sandbox, one has paypal and the other one doesn’t. I just found out that the one linked to the plugin was the one which doesn’t have the support for paypal. It’s already working now. Thanks!
    Although, the same with Apple Pay, there is also a possibility that we’ll only support some currencies.

    3. Just an additional background and issue, My site uses the following currencies: SGD, CNY, AUD, HKD, MYR, IDR, PHP. Currently, my Braintree sandbox holds 5 merchants/currencies: SGD, AUD, HKD, MYR, PHP. It doesn’t have CNY and IDR, well it doesn’t have those 2 currencies in the sandbox. Thus, it’s showing the “.. No Braintree merchant account…” error message. I would also like to disable or hide all the payment method in the checkout that is related to braintree if the merchant is not available for that currency.

    I don’t know if these are possible.
    if (merchant doesn’t support payment method) {//disable and hide methods}
    if (configuration has errors) {//disable and hide methods}
    if (no merchant is not in braintree) {//disable and hide methods}

    I’m thinking it’s a part of this.

    Once you get those sorted out reply back and I will show you how to hide the payment options based on currency and country.

    Thanks for understanding!

    Kind Regards,

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @ryanothelo,

    Have you investigated using a currency switcher plugin? They allow you to restrict payment gateways by currency which should give you the desired functionality.

    I am taking a look at the code to see what you would need to change if using a currency switcher doesn’t give you what you need.

    Kind Regards,

    Thread Starter ryanothelo

    (@ryanothelo)

    Hi @mrclayton,

    Have you investigated using a currency switcher plugin? They allow you to restrict payment gateways by currency which should give you the desired functionality.

    I am actually using https://wordpress.org/plugins/woocommerce-product-price-based-on-countries/ ‘s currency switching functionality. The plugin itself doesn’t have the functionality to restrict the payment gateway or disable the payment method dynamically.

    I am taking a look at the code to see what you would need to change if using a currency switcher doesn’t give you what you need.

    Alright, looking forward to it.

    Best Regards,

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @ryanothelo,

    I am having to give this request some more consideration. This is a very nuanced request for the following reasons:

    1. The plugin should only show Braintree payment methods when store currency matches their accepted currencies in Braintree. But, merchants may think something is wrong if payment methods disappear on checkout page when the currency changes.

    2. Some currency switchers rely on a page refresh while others use an ajax request on the checkout page. Hiding or showing gateways under both conditions while ensuring all scripts are loaded requires some investigation.

    I am not sure yet how that would look if I added that functionality to the core plugin.

    Kind Regards,

    Thread Starter ryanothelo

    (@ryanothelo)

    Hi @mrclayton

    I’m already grateful to you for giving my request some consideration.

    I’ll wait for it. Thank you in advance.

    Best Regards,

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @ryanothelo,

    I have been researching this request and here is what I have so far.

    I’m not sure I like the idea of hiding the gateways if the store currency does not match any of the configured merchant accounts. In my experience that will cause confusion for merchants because they won’t understand why the gateway is not showing on the checkout page, leading them to believe it’s a plugin issue.

    I think I will add a filter to the WC_Braintree_Payment_Gateway::is_available function so developers can add custom logic. Using that filter, you could make the gateways unavailable by comparing the store currency to the list of configured merchant accounts.

    Kind Regards,

    Thread Starter ryanothelo

    (@ryanothelo)

    hi @mrclayton,

    Thank you for giving your time and effort for this.

    What you’re saying is reasonable. Although personally, we’d want it to show, let’s say, only on “debug mode”. We don’t want our customers to see those errors and still have the option to choose the method with errors (may it be currency related or technical related) or for the least we’d want a way to handle it differently.

    I think I will add a filter to the WC_Braintree_Payment_Gateway::is_available function so developers can add custom logic. Using that filter, you could make the gateways unavailable by comparing the store currency to the list of configured merchant accounts.

    Looking forward to this. 🙂

    Thank you thank you so much!

    Best Regards,

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @ryanothelo,

    Version 3.2.19 includes as new filter wc_braintree_gateway_is_available which you can use to determine availability based on custom conditions. My recommendation is to use this filter to compare the configured merchant account currencies to the store’s currency to determine if the payment method should be displayed.

    https://docs.paymentplugins.com/wc-braintree/api/source-class-WC_Braintree_Payment_Gateway.html#223

    Example:

    add_filter('wc_braintree_gateway_is_available', function($is_available, $gateway){
        $currency = get_woocommerce_currency();
        $merchant_account = wc_braintree_get_merchant_account($currency);
        if(!$merchant_account){
            $is_available = false;
        }
        return $is_available;
    }, 10, 2);

    Kind Regards,

    Thread Starter ryanothelo

    (@ryanothelo)

    Hi @mrclayton,

    Thank you for this! Will update you as soon as I add it to my site.

    I’ll update you as soon as possible.

    Many thanks!!!

    Best Regards,

    Thread Starter ryanothelo

    (@ryanothelo)

    Hi @mrclayton,

    This is awesome. it’s working as imagined! thank you so much!

    Just a heads up though, that maybe your code snippet is necessary for all with currency switchers with selective payment method support?

    add_filter('wc_braintree_gateway_is_available', function($is_available, $gateway){
        $currency = get_woocommerce_currency();
        $merchant_account = wc_braintree_get_merchant_account($currency);
        if(!$merchant_account){
            $is_available = false;
        }
        return $is_available;
    }, 10, 2);

    Before I added the code, I tried using CNY currency in my test, but CNY is not in my Braintree Acct. The transaction pushed through but it registered as SGD (default shop currency) in braintree without converting the value.

    After I added the code the payment methods were just hidden, which is what I wanted/expected. Sorry for the trouble. Thanks once again!

    Best Regards

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Disable Method or Handle Errors For Multiple Merchant And Currency’ is closed to new replies.