Created
September 18, 2018 03:06
-
-
Save imbolc/b1b21143479a8730b7fc1129ba6bbed7 to your computer and use it in GitHub Desktop.
Restrict shopify payment method to be shown only in particular countries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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