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

[monei] Implements optional/extra params #79

Merged
merged 11 commits into from
Jan 21, 2018
Merged

[monei] Implements optional/extra params #79

merged 11 commits into from
Jan 21, 2018

Conversation

oyeb
Copy link
Contributor

@oyeb oyeb commented Jan 12, 2018

Closes #36

| Key | Remark | Status |
| ---- | --- | ---- |
| `billing` | Address of the customer, which can be used for AVS risk check | **Implemented** |
| `cart` | | Not implemented |
Copy link
Member

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.
Copy link
Member

@arjun289 arjun289 Jan 15, 2018

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.

Copy link
Contributor Author

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}
Copy link
Member

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?

Copy link
Contributor Author

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.

defp verification_result(%{"result" => result} = data) do
{address, zip_code} = @avs_code_translator[result["avsResponse"]]
code = result["code"]

results = [
token = data["registrationId"]
Copy link
Member

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()

@pkrawat1
Copy link
Member

@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.
* 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
@pkrawat1 pkrawat1 merged commit a135692 into dev Jan 21, 2018
@pkrawat1 pkrawat1 deleted the iss36-monei-opts branch January 21, 2018 18:20
pkrawat1 pushed a commit that referenced this pull request Jan 25, 2018
* 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.
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

3 participants