Last active
April 9, 2018 06:31
-
-
Save oyeb/a2e2ac5986cc90a12a6136f6bf1357e5 to your computer and use it in GitHub Desktop.
Some frequently used bindings for MONEI
This file contains 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
# Handy bindings when developing the MONEI gateway integration. | |
# Most of the bindings are for the `opts` | |
# Instructions | |
# Just rename this file to `.iex.exs` and save it in either, | |
# 1. the gringotts root directory | |
# 2. your applications root directory | |
# essentially the place where you launch your `iex` sessions via `iex -S mix`. | |
alias Gringotts.{CreditCard, Response, Address} | |
alias Gringotts.Gateways.Monei | |
card = %CreditCard{ | |
first_name: "Harry", | |
last_name: "Potter", | |
number: "4200000000000000", | |
year: 2099, | |
month: 12, | |
verification_code: "123", | |
brand: "VISA"} | |
customer = %{"givenName": "Harry", | |
"surname": "Potter", | |
"merchantCustomerId": "the_boy_who_lived", | |
"sex": "M", | |
"birthDate": "1980-07-31", | |
"mobile": "+15252525252", | |
"email": "masterofdeath@ministryofmagic.gov", | |
"ip": "1.1.1", | |
"status": "NEW"} | |
merchant = %{"name": "Ollivanders", | |
"city": "South Side", | |
"street": "Diagon Alley", | |
"state": "London", | |
"country": "GB", | |
"submerchantId": "Makers of Fine Wands since 382 B.C."} | |
billing = %{"street1": "301, Gryffindor", | |
"street2": "Hogwarts School of Witchcraft and Wizardry, Hogwarts Castle", | |
"city": "Highlands", | |
"state": "Scotland", | |
"country": "GB"} | |
shipping = Map.merge( | |
%{"method": "SAME_DAY_SERVICE", | |
"comment": "For our valued customer, Mr. Potter"}, | |
billing) | |
extra_opts = [customer: customer, | |
merchant: merchant, | |
billing: billing, | |
shipping: shipping, | |
category: "EC", | |
custom: %{"voldemort": "he who must not be named"}] | |
auth = [config: [userId: "8a829417539edb400153c1eae83932ac", password: "6XqRtMGS2N", entityId: "8a829417539edb400153c1eae6de325e"]] | |
ids = [ | |
invoice_id: Base.encode16(:crypto.hash(:md5, :crypto.strong_rand_bytes(32))), | |
transaction_id: Base.encode16(:crypto.hash(:md5, :crypto.strong_rand_bytes(32))), | |
category: "EC"] | |
opts_basic = auth ++ ids | |
opts_custom = opts_basic ++ [custom: %{voldemort: "he who must not be named"}] | |
opts_all = opts_custom ++ [ | |
customer: customer, | |
merchant: merchant, | |
billing: billing, | |
shipping: shipping, | |
shipping_customer: customer] | |
amount = Money.new(100.2, :EUR) | |
# Monei.authorize amount, card, opts_all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment