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

[PinPayments] Implemented test cases for authorize #139

Open
wants to merge 12 commits into
base: pinpay
Choose a base branch
from
43 changes: 12 additions & 31 deletions test/integration/gateways/pin_pay_test.exs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
defmodule Gringotts.Integration.Gateways.PinpaymentsTest do
defmodule Gringotts.Integration.Gateways.PinPaymentsTest do
# Integration tests for the Pinpayments

use ExUnit.Case, async: true

alias Gringotts.{
CreditCard, Address
CreditCard,
Address
}

alias Gringotts.Gateways.PinPayments, as: Gateway

#@moduletag :integration
@moduletag :integration

@amount Money.new(420, :AUD)

Expand All @@ -23,46 +24,33 @@ defmodule Gringotts.Integration.Gateways.PinpaymentsTest do
brand: "VISA"
}

@bad_card2 %CreditCard{
first_name: "Harry",
last_name: "Potter",
number: "4600000000000006",
year: 2019,
month: 12,
verification_code: "123",
brand: "VISA"
}

@good_card %CreditCard{
first_name: "Harry",
last_name: "Potter",
number: "4200000000000000",
year: 2019,
year: 2029,
month: 12,
verification_code: "123",
brand: "VISA"
}

@add %Address{

street1: "OBH",
street2: "AIT",
city: "PUNE",
region: "Maharashtra",
region: "Maharashtra",
country: "IN",
postal_code: "411015",
phone: "8007810916",

phone: "8007810916"
}

@opts [
description: "hello",
email: "[email protected]",
ip_address: "1.1.1.1",
config: %{apiKey: "c4nxgznanW4XZUaEQhxS6g", pass: ""}
description: "hello",
email: "[email protected]",
ip_address: "1.1.1.1",
config: %{apiKey: "c4nxgznanW4XZUaEQhxS6g"}
] ++ [address: @add]
Copy link
Contributor

Choose a reason for hiding this comment

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

I've already pointed out in an earlier comment that you should not concat lists like this. The second list has only one element, moreover, the first list is being defined right there. You can simply move address: @add inside.


] ++ [address: @add]

test "[authorize] with CreditCard" do
assert {:ok, response} = Gateway.authorize(@amount, @good_card, @opts)
assert response.success == true
Expand All @@ -74,11 +62,4 @@ defmodule Gringotts.Integration.Gateways.PinpaymentsTest do
assert response.success == false
assert response.status_code == 400
end

test "[authorize] with bad CreditCard 2" do
assert {:error, response} = Gateway.authorize(@amount, @bad_card2, @opts)
assert response.success == false
assert response.status_code == 400
end

end