Skip to content

Instantly share code, notes, and snippets.

@imbolc
Created September 18, 2018 03:06
Show Gist options
  • Save imbolc/b1b21143479a8730b7fc1129ba6bbed7 to your computer and use it in GitHub Desktop.
Save imbolc/b1b21143479a8730b7fc1129ba6bbed7 to your computer and use it in GitHub Desktop.
Restrict shopify payment method to be shown only in particular countries
def allow_in(gateway, allowed)
if Input.cart.shipping_address and allowed.include?(Input.cart.shipping_address.country_code)
Output.payment_gateways = Input.payment_gateways
else
Output.payment_gateways = Input.payment_gateways.delete_if do |payment_gateway|
payment_gateway.name == gateway
end
end
end
allow_in('American Express', ['US', 'CA'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment