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

[Mercadopago] Add support for mercadopago gateway. #185

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

mandarvaze
Copy link
Collaborator

@mandarvaze mandarvaze commented Apr 14, 2020

Why?

  • Introduced new gateway Mercadopago.
  • Added Unit tests.
  • Added Integration tests.

Manually picked up code from various branches/PRs related to mercadopago
The branches/PRs are couple years old, and messy.
@mandarvaze
Copy link
Collaborator Author

Once this PR is merged, I'll close other mercadopago related PRs, mentioning this PR.

@SagarKarwande
Copy link
Member

SagarKarwande commented Apr 15, 2020

@mandarvaze Can you sync the branch with latest devbranch. Travis build is failing.
Commit that has travis changes on the dev branch are not included in the branch.

@mandarvaze
Copy link
Collaborator Author

@mandarvaze Can sync the branch with latest devbranch. Travis build is failing.
Commit that has travis changes on the dev branch are not included in the branch.

Done.

SagarKarwande
SagarKarwande previously approved these changes Apr 17, 2020
@codecov
Copy link

codecov bot commented Apr 18, 2020

Codecov Report

Merging #185 into dev will increase coverage by 3.30%.
The diff coverage is 95.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #185      +/-   ##
==========================================
+ Coverage   77.39%   80.70%   +3.30%     
==========================================
  Files          14       16       +2     
  Lines         376      456      +80     
==========================================
+ Hits          291      368      +77     
- Misses         85       88       +3     
Impacted Files Coverage Δ
lib/gringotts/gateways/mercadopago.ex 95.45% <95.45%> (ø)
lib/gringotts/gateways/openpay.ex 97.22% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 957cffe...6e68bdd. Read the comment docs.

@SagarKarwande
Copy link
Member

@mandarvaze Also check if the docs are generating properly.

lib/gringotts/gateways/mercadopago.ex Show resolved Hide resolved
| `customer_id` | Unique customer id issued by the gateway. For new customer it must skipped. Type- string|
| `order_type` | `"mercadopago"` or `"mercadolibre"` as per the order. Type- string |
| `installments` | No of installments for payment. Type- integer |

Copy link
Member

Choose a reason for hiding this comment

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

"For eg. https://www.mercadopago.com.ar/developers/en/reference/payments/_payments/post/"

check the documentation to get how mercadopago accepts the params.

Copy link
Member

@ashish173 ashish173 Apr 22, 2020

Choose a reason for hiding this comment

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

@mandarvaze Add PCI and Non PCI section and implementation with info.


### I'm not PCI-DSS compliant
  No worries, both `authorize/3` and `purchase/3` accept a
  "payment-source-identifier" (a `string`) instead of a `CreditCard.t`
  struct. You'll have to generate this identifier using [Stripe.js and
  Elements][stripe-js] client-side.
### I'm PCI-DSS compliant
  In that case, you need not use [Stripe.js or Elements][stripe-js] and can
  directly accept the client's card info and pass the `CreditCard.t` struct to
  this module's functions.

lib/gringotts/gateways/mercadopago.ex Show resolved Hide resolved
lib/gringotts/gateways/mercadopago.ex Show resolved Hide resolved
lib/gringotts/gateways/mercadopago.ex Show resolved Hide resolved
lib/gringotts/gateways/mercadopago.ex Show resolved Hide resolved
lib/gringotts/gateways/mercadopago.ex Show resolved Hide resolved
"""
@spec void(String.t(), keyword) :: {:ok | :error, Response}
def void(payment_id, opts) do
# url = "#{@base_url}/v1/payments/#{payment_id}?access_token=#{opts[:config][:access_token]}"
Copy link
Member

Choose a reason for hiding this comment

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

@mandarvaze remove this commented code.

defp respond({:ok, %HTTPoison.Response{body: body, status_code: status_code}}, opts) do
body = body |> Poison.decode!()

case body["cause"] do
Copy link
Member

Choose a reason for hiding this comment

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

@mandarvaze success and failure should be mocked.

def bad_card_purchase_response do
{:error,
%HTTPoison.Error{
reason: "Bad Card for Purchase",
Copy link
Member

Choose a reason for hiding this comment

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

@mandarvaze this should capture the real bad response from the gateway.

@ashish173
Copy link
Member

@mandarvaze update the README file with the addition of this new gateway.

@mandarvaze
Copy link
Collaborator Author

@mandarvaze update the README file with the addition of this new gateway.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants