-
Notifications
You must be signed in to change notification settings - Fork 53
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
[monei] Implements optional/extra params #79
Conversation
lib/gringotts/gateways/monei.ex
Outdated
| Key | Remark | Status | | ||
| ---- | --- | ---- | | ||
| `billing` | Address of the customer, which can be used for AVS risk check | **Implemented** | | ||
| `cart` | | Not implemented | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no description for cart, when all other keys have a description?
# MONEI supports payment by card, bank account and even something obscure: virtual account | ||
# opts has the auth keys. | ||
# MONEI supports payment by card, bank account and even something obscure: | ||
# virtual account opts has the auth keys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good if you provide a link to the part of Monei documentation which describes this. The various supported payment methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link added in the real docs.
@@ -389,27 +442,40 @@ defmodule Gringotts.Gateways.Monei do | |||
end | |||
|
|||
# Makes the request to MONEI's network. | |||
@spec commit(atom, String.t(), keyword, map) :: {:ok | :error, Response} | |||
@spec commit(atom, String.t(), keyword, keyword) :: {:ok | :error, Response} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spec for a private method, is it required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't appear in the docs anyways. Dialyzer can use it too.
lib/gringotts/gateways/monei.ex
Outdated
defp verification_result(%{"result" => result} = data) do | ||
{address, zip_code} = @avs_code_translator[result["avsResponse"]] | ||
code = result["code"] | ||
|
||
results = [ | ||
token = data["registrationId"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parsing job in this function can be delegated to a separate private function
you can return a tuple
containing the result and only do verification of the result here.
{token, common,code} = som_priv_function()
d3ba40a
to
fc1c728
Compare
@oyeb could you resolve the conflicts on this PR. |
* Added EUR to the supported currencies.
* Devised a nice way to handle extra params. - This can handle validation and works in a fail-fast manner
* Removed duplicate code that extracted auth_info from opts * Part of the params to Monei are built in the methods, all extra params are built and validated in commit. * Fixed base_url and version
* Added examples of these in docs and integration tests
* Credo complains that expand_params is too complex as there is too much branching in it. I'm opening an issue for it.
* Added tests on register
* All optional params covered * changed markdown link-style to improve plain-text doc flow. * corrected inline examples
* Also stripped whitespace
* MONEI requires all amounts to follow this regex [0-9]{1,8}(\.[0-9]{2})? so we no longer support TND (Tunisian Dollar) as it requires 3 decimal places.
* The inclusion was (partially) implicitly tested in the integration tests, but I moved it to more visible mock tests. * Ran the formatter on implementation and both tests * Fixed a hard to catch typo
218ee33
to
1fbf8e5
Compare
* Validates currency, test for unsupported currency * Added EUR to the supported currencies. * Refactored expansion and validation of extras * Removed duplicate code that extracted auth_info from opts * Part of the params to Monei are built in the methods, all extra params are built and validated in commit. * [extra-params] All optional params covered: billing, shipping and merchant, invoice_id, category, transaction_id, custom, register, customer * Added examples of these in docs and integration tests * The inclusion was (partially) implicitly tested in the integration tests, but I moved it to more visible mock tests.
Closes #36