Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CAMS] Adds money protocol #89

Merged
merged 10 commits into from
Jan 25, 2018
Merged

[CAMS] Adds money protocol #89

merged 10 commits into from
Jan 25, 2018

Conversation

gopalshimpi
Copy link
Member

@gopalshimpi gopalshimpi commented Jan 19, 2018

Copy link
Contributor

@oyeb oyeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some issues with the examples in docs, the opts list has a :currency key inside. We no longer accept that.
Also, all bindings in the examples should have an iex> in front:

iex> amount = 100

@@ -118,7 +117,7 @@ defmodule Gringotts.Gateways.Cams do

iex> Gringotts.purchase(Gringotts.Gateways.Cams, money, payment, options)
"""
@spec purchase(number, CreditCard.t, Keyword) :: Response
@spec purchase(Money.t, CreditCard.t, Keyword) :: Response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your specs are wrong, this should be:

@spec purchase(Money.t(), CreditCard.t(), keyword) :: {:ok | :error, Response}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oyeb CreditCard.t() why brackets here?

@headers [{"Content-Type", "application/x-www-form-urlencoded"}]
use Gringotts.Gateways.Base
use Gringotts.Adapter,
required_config: [:username, :password, :default_currency]
alias Gringotts.{CreditCard, Response}
alias Gringotts.{CreditCard, Response, Money}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -87,14 +87,13 @@ defmodule Gringotts.Gateways.Cams do
- Refund
"""
@live_url "https://secure.centralams.com/gw/api/transact.php"
@default_currency "USD"
@headers [{"Content-Type", "application/x-www-form-urlencoded"}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention that the unit of amount is not cents, in the "Scope of this module" section on line 52. See how it is done in MONEI docs.

optional arguments for transactions with the CAMS gateway. The following keys
are supported:

| Key | Remark | Status |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fill this table. AFAICS billing_address and order_id are already implemented, but there is no explanation what their schema or types are. Either place a link to the official docs or document the schema somewhere.

[post: fn(_url, _body, _headers) -> MockResponse.failed_purchase_with_bad_money end] do
{:ok, %Response{message: result}} = Gateway.purchase(@bad_money, @payment, @options)
assert String.contains?(result, "Invalid amount")
assert String.contains?(result, "Invalid Credit Card Number")
end
end

test "with invalid currency" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@money does not have currency INR, so this mock test is misleading.

@oyeb
Copy link
Contributor

oyeb commented Jan 23, 2018

This PR can be merged after merging #92.

gopalshimpi and others added 10 commits January 25, 2018 17:57
1. Modified methods according to money protocal.
2. Modified test data as per money protocal.
* Reworded all docs, fixed numerous typos
* Fixed (#) critical bugs in capture and refund (money was not being used)
* Cleaned up bad whitespace
* Added patterns in function clauses on type
* Reduced arity and name of add_invoice -> add_amount
* Corrected HTTPoison.post in commit
* Improved add_address
* Corrected mock tests, no direct calls to module.
* Removed test on bad_amount
@pkrawat1 pkrawat1 merged commit f3c0d58 into dev Jan 25, 2018
@pkrawat1 pkrawat1 deleted the cams-money branch January 25, 2018 13:11
pkrawat1 pushed a commit that referenced this pull request Jan 25, 2018
* Added money protocol for CAMS gateway.

* Modified methods according to money protocol.

* Modified test data as per money protocol.

* Corrected protocol usage, docs and some bugs

* Updated docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants