Last active
January 12, 2018 13:20
-
-
Save oyeb/dba499c6f6d9ae72907b4f5a3aebe325 to your computer and use it in GitHub Desktop.
Development bindings
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
defmodule M do | |
# some handy aliases | |
alias Gringotts.{CreditCard, Response, Money, Gateways.GlobalCollect} | |
# some really, really frequently used bindings! | |
@amount %{value: 4200, currency: "USD"} | |
@card %CreditCard{ | |
number: "4567350000427977", | |
month: 12, | |
year: 18, | |
first_name: "John", | |
last_name: "Doe", | |
verification_code: "123", | |
brand: "VISA" | |
} | |
@auth_info [ | |
secret_api_key: "Qtg9v4Q0G13sLRNcClWhHnvN1kVYWDcy4w9rG8T86XU=", | |
api_key_id: "e5743abfc360ed12", | |
merchant_id: "1226", | |
] | |
@shipping_address %{ | |
street: "Desertroad", | |
houseNumber: "1", | |
additionalInfo: "Suite II", | |
zip: "84536", | |
city: "Monument Valley", | |
state: "Utah", | |
countryCode: "US" | |
} | |
@billing_address %{ | |
street: "Desertroad", | |
houseNumber: "13", | |
additionalInfo: "b", | |
zip: "84536", | |
city: "Monument Valley", | |
state: "Utah", | |
countryCode: "US" | |
} | |
@invoice %{ | |
invoiceNumber: "000000123", | |
invoiceDate: "20180306191500" | |
} | |
@name %{ | |
title: "Miss", | |
firstName: "Road", | |
surname: "Runner" | |
} | |
@opts [ | |
billingAddress: @billing_address, | |
name: @name, | |
email: "[email protected]", | |
description: "Store Purchase 1437598192", | |
currency: "USD", | |
merchantCustomerId: "1234", | |
customer_name: "Harry Potter", | |
dob: "19490917", | |
company: "asma", | |
order_id: "2323", | |
] ++ @auth_info | |
@big_opts [ | |
shippingAddress: @shipping_address, | |
description: "an awesome shirt" | |
] ++ @opts | |
def amount, do: @amount | |
def card, do: @card | |
def auth_info, do: @auth_info | |
def shipping_address, do: @shipping_address | |
def billing_address, do: @billing_address | |
def invoice, do: @invoice | |
def name, do: @name | |
def opts, do: @opts | |
def big_opts, do: @big_opts | |
def authorize(amount \\ @amount, card \\ @card, opts \\ @opts), do: GlobalCollect.authorize(amount, card, opts) | |
def capture(amount \\ @amount, id, opts \\ @opts), do: GlobalCollect.capture(amount, id, opts) | |
def purchase(amount \\ @amount, card \\ @card, opts \\ @opts), do: GlobalCollect.purchase(amount, card, opts) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment