Conversation
Codecov Report
@@ Coverage Diff @@
## dev #165 +/- ##
==========================================
- Coverage 77.33% 68.55% -8.78%
==========================================
Files 14 15 +1
Lines 375 423 +48
==========================================
Hits 290 290
- Misses 85 133 +48
Continue to review full report at Codecov.
|
|
|
||
| { | ||
| :ok, | ||
| Response.success(id: id, message: message, token: token, raw: parsed, status_code: code) |
There was a problem hiding this comment.
Don't use the functions from the Response module, they are deprecated (slated for removal in 1.2.0).
| {:ok, card_token} <- extract_card_token(card_token_response) do | ||
| body = | ||
| Poison.encode!(%{ | ||
| account_id: opts[:account_id], |
There was a problem hiding this comment.
The account_id cannot be fetched like this because it should be part of the required config.
See https://developer.wepay.com/docs/faq/general#how-do-i-find-my-account-id
opts[:config][:account_id]| body = | ||
| Poison.encode!(%{ | ||
| account_id: opts[:account_id], | ||
| short_description: opts[:short_description], |
There was a problem hiding this comment.
- This map is so verbose! Most of the keys are not transformed. Please consider the following style to build this map:
opts |> Keyword.take(@required_or_allowed_keys) |> Enum.into(%{}) |> Map.merge(%{ currency: currency, value: value, payment_method: %{...}, ... })
|
|
||
| body = | ||
| Poison.encode!(%{ | ||
| account_id: opts[:account_id], |
There was a problem hiding this comment.
The maps are very similar in both clauses, please move the common parts into a private function.
| iex> {:ok, void_result} = Gringotts.capture(Gringotts.Gateways.WePay, purchase_result.id, opts) | ||
| ``` | ||
| """ | ||
| @spec void(String.t(), keyword) :: {:ok | :error, Response} |
There was a problem hiding this comment.
The auto_release setting comes into play here, when we cancel a checkout.
If it was true, the funds are auto-released back to the payer.
otherwise, an explicit call to checkout/release/ is needed.
Since we don't have any API call for release, we must hard-code auto_release to true. Hmm... too bad. 😞
| defmodule Gringotts.Integration.Gateways.WePayTest do | ||
| # Integration tests for the WePay | ||
|
|
||
| use ExUnit.Case, async: false |
| refund_reason: "the product was defective", | ||
| cancel_reason: "the product was defective, i don't want", | ||
| config: [ | ||
| access_token: "STAGE_a24e062d0fc2d399412ea0ff1c1e748b04598b341769b3797d3bd207ff8cf6b2" |
| test "[Store] with CreditCard" do | ||
| use_cassette "WePay/store_with_valid_card" do | ||
| assert {:ok, response} = Gateway.store(@good_card, @opts) | ||
| assert response.success == true |
There was a problem hiding this comment.
Please assert that the card ID is received in the :token field
| ] | ||
|
|
||
| describe "store" do | ||
| test "[Store] with CreditCard" do |
There was a problem hiding this comment.
You don't need [Store] in the test name.
| end | ||
| end | ||
|
|
||
| describe "Void" do |
There was a problem hiding this comment.
Can you add a test to check auth -> capture -> void?
Implementation of :
Authorize/3Capture/3Purchase/3void/2refund/3store/2unstore/2and its private functions