Hiding payment method by country with Shopify Scripts (redux)

A quick Shopify script to show or hide payment methods based on the customer’s country. An extension of [this previous ]

You should be able to copy and paste this into the Shopify Script editor after clicking “Create script” and then choosing a blank “Payment gateways” script. You may have to tweak the value for PAYMENT_METHOD depending on the gateway you’re using.

  'Credit Card' => ['US'],
  'Paypal' => ['']

if Input.cart.shipping_address and ELIGIBLE_COUNTRY_CODES.include?(Input.cart.shipping_address.country_code)
  Output.payment_gateways = Input.payment_gateways
  Output.payment_gateways = Input.payment_gateways.delete_if do |payment_gateway|
    payment_gateway.name == PAYMENT_METHOD