alpha_card 0.2.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.travis.yml +1 -5
- data/CHANGELOG.md +54 -0
- data/Gemfile.lock +25 -37
- data/LICENSE +1 -1
- data/README.md +207 -67
- data/ROADMAP.md +12 -0
- data/alpha_card.gemspec +5 -4
- data/lib/alpha_card.rb +11 -6
- data/lib/alpha_card/alpha_card_object.rb +59 -3
- data/lib/alpha_card/alpha_card_response.rb +99 -16
- data/lib/alpha_card/data/avs_responses.yml +20 -0
- data/lib/alpha_card/data/credit_card_codes.yml +1 -1
- data/lib/alpha_card/data/cvv_responses.yml +5 -0
- data/lib/alpha_card/data/response_messages.yml +33 -0
- data/lib/alpha_card/errors/alpha_card_error.rb +1 -1
- data/lib/alpha_card/errors/invalid_object_error.rb +8 -0
- data/lib/alpha_card/objects/account.rb +1 -1
- data/lib/alpha_card/objects/billing.rb +15 -4
- data/lib/alpha_card/objects/capture.rb +51 -0
- data/lib/alpha_card/objects/order.rb +41 -4
- data/lib/alpha_card/objects/refund.rb +20 -0
- data/lib/alpha_card/objects/sale.rb +32 -22
- data/lib/alpha_card/objects/shipping.rb +15 -4
- data/lib/alpha_card/objects/update.rb +54 -0
- data/lib/alpha_card/objects/void.rb +45 -0
- data/lib/alpha_card/version.rb +18 -2
- data/spec/alpha_card/objects/account_spec.rb +20 -0
- data/spec/alpha_card/objects/capture_spec.rb +51 -0
- data/spec/alpha_card/objects/deprecated_methods_spec.rb +32 -0
- data/spec/alpha_card/objects/refund_spec.rb +35 -0
- data/spec/alpha_card/objects/sale_spec.rb +143 -0
- data/spec/alpha_card/objects/update_spec.rb +36 -0
- data/spec/alpha_card/objects/void_spec.rb +48 -0
- data/spec/alpha_card/response_spec.rb +111 -0
- data/spec/spec_helper.rb +7 -2
- metadata +44 -9
- data/spec/alpha_card/alpha_card_account_spec.rb +0 -18
- data/spec/alpha_card/alpha_card_response_spec.rb +0 -63
- data/spec/alpha_card/alpha_card_spec.rb +0 -123
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AlphaCard::Capture do
|
4
|
+
let(:account) { AlphaCard::Account.new('demo', 'password') }
|
5
|
+
|
6
|
+
context 'with invalid attributes' do
|
7
|
+
let(:capture) { AlphaCard::Capture.new(transaction_id: 'Some ID', amount: '10.05') }
|
8
|
+
|
9
|
+
it 'response with error' do
|
10
|
+
expect { capture.create(account) }.to raise_error(AlphaCard::AlphaCardError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'with valid attributes' do
|
15
|
+
let(:capture) { AlphaCard::Capture.new(transaction_id: 'Some ID', amount: '10.05', order_id: '1', shipping_carrier: '2') }
|
16
|
+
|
17
|
+
let(:order) { AlphaCard::Order.new(id: '1', description: 'Test') }
|
18
|
+
let(:card_exp) { "#{'%02d' % Time.now.month}/#{Time.now.year.next}" }
|
19
|
+
let(:sale) { AlphaCard::Sale.new(card_expiration_date: card_exp, card_number: '4111111111111111', amount: '5.00') }
|
20
|
+
|
21
|
+
it 'has valid request params' do
|
22
|
+
expected_params = {
|
23
|
+
transactionid: 'Some ID',
|
24
|
+
type: 'capture',
|
25
|
+
amount: '10.05',
|
26
|
+
shipping_carrier: '2',
|
27
|
+
orderid: '1'
|
28
|
+
}
|
29
|
+
|
30
|
+
expect(capture.attributes_for_request).to eq(expected_params)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'processed successfully' do
|
34
|
+
allow_any_instance_of(AlphaCard::Sale).to receive(:type).and_return('auth')
|
35
|
+
success, response = sale.create(order, account)
|
36
|
+
expect(success).to be_truthy
|
37
|
+
expect(response.transaction_id).not_to be_nil
|
38
|
+
|
39
|
+
success, response = AlphaCard::Capture.new(transaction_id: response.transaction_id, amount: '2.00').create(account)
|
40
|
+
expect(success).to be_truthy
|
41
|
+
expect(response.text).to eq('SUCCESS')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with blank attributes' do
|
46
|
+
it 'raises an InvalidObject error' do
|
47
|
+
expect { AlphaCard::Refund.new.create(account) }.to raise_error(AlphaCard::InvalidObjectError)
|
48
|
+
expect { AlphaCard::Refund.new(amount: '1.05').create(account) }.to raise_error(AlphaCard::InvalidObjectError)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'AlphaCard objects deprecated methods' do
|
4
|
+
def warn_writer(old_method, new_method)
|
5
|
+
"[DEPRECATION] #{old_method}= is deprecated! Please, use #{new_method}= instead\n"
|
6
|
+
end
|
7
|
+
|
8
|
+
def warn_reader(old_method, new_method)
|
9
|
+
"[DEPRECATION] #{old_method} is deprecated! Please, use #{new_method} instead\n"
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'warns with deprecation message for AlphaCard::Sale' do
|
13
|
+
AlphaCard::Sale::ORIGIN_TRANSACTION_VARIABLES.each do |new, old|
|
14
|
+
expect { AlphaCard::Sale.new.send("#{old}=", 'T') }.to output(warn_writer(old, new)).to_stderr
|
15
|
+
expect { AlphaCard::Sale.new.send(old) }.to output(warn_reader(old, new)).to_stderr
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'warns with deprecation message for AlphaCard::Billing' do
|
20
|
+
AlphaCard::Billing::ORIGIN_TRANSACTION_VARIABLES.each do |new, old|
|
21
|
+
expect { AlphaCard::Billing.new.send("#{old}=", 'T') }.to output(warn_writer(old, new)).to_stderr
|
22
|
+
expect { AlphaCard::Billing.new.send(old) }.to output(warn_reader(old, new)).to_stderr
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'warns with deprecation message for AlphaCard::Shipping' do
|
27
|
+
AlphaCard::Shipping::ORIGIN_TRANSACTION_VARIABLES.each do |new, old|
|
28
|
+
expect { AlphaCard::Shipping.new.send("#{old}=", 'T') }.to output(warn_writer(old, new)).to_stderr
|
29
|
+
expect { AlphaCard::Shipping.new.send(old) }.to output(warn_reader(old, new)).to_stderr
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AlphaCard::Refund do
|
4
|
+
let(:account) { AlphaCard::Account.new('demo', 'password') }
|
5
|
+
|
6
|
+
context 'with invalid attributes' do
|
7
|
+
let(:refund) { AlphaCard::Refund.new(transaction_id: 'Some ID', amount: '10.05') }
|
8
|
+
|
9
|
+
it 'response with error' do
|
10
|
+
expect { refund.create(account) }.to raise_error(AlphaCard::AlphaCardError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'with valid attributes' do
|
15
|
+
let(:refund) { AlphaCard::Refund.new(transaction_id: 'Some ID', amount: '10.05') }
|
16
|
+
|
17
|
+
it 'has valid request params' do
|
18
|
+
expected_params = {
|
19
|
+
transactionid: 'Some ID',
|
20
|
+
type: 'refund',
|
21
|
+
amount: '10.05'
|
22
|
+
}
|
23
|
+
|
24
|
+
expect(refund.attributes_for_request).to eq(expected_params)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'with blank attributes' do
|
29
|
+
let(:refund) { AlphaCard::Refund.new }
|
30
|
+
|
31
|
+
it 'raises an InvalidObject error' do
|
32
|
+
expect { refund.create(account) }.to raise_error(AlphaCard::InvalidObjectError)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AlphaCard::Sale do
|
4
|
+
# Shared objects
|
5
|
+
let(:account) { AlphaCard::Account.new('demo', 'password') }
|
6
|
+
let(:billing) { AlphaCard::Billing.new(email: 'test@example.com', address_1: 'N', address_2: 'Y') }
|
7
|
+
let(:shipping) { AlphaCard::Shipping.new(first_name: 'John', last_name: 'Doe', address_1: '22 N str.') }
|
8
|
+
let(:order) { AlphaCard::Order.new(id: '1', description: 'Test', billing: billing, shipping: shipping) }
|
9
|
+
let(:card_exp) { "#{'%02d' % Time.now.month}/#{Time.now.year.next}" }
|
10
|
+
|
11
|
+
context 'with valid attributes' do
|
12
|
+
let(:sale) { AlphaCard::Sale.new(card_expiration_date: card_exp, card_number: '4111111111111111', amount: '5.00') }
|
13
|
+
|
14
|
+
it 'has valid request params' do
|
15
|
+
expected_params = {
|
16
|
+
ccexp: '09/2017',
|
17
|
+
ccnumber: '4111111111111111',
|
18
|
+
amount: '5.00',
|
19
|
+
payment: 'creditcard',
|
20
|
+
type: 'sale',
|
21
|
+
email: 'test@example.com',
|
22
|
+
address1: 'N',
|
23
|
+
address2: 'Y',
|
24
|
+
orderid: '1',
|
25
|
+
orderdescription: 'Test',
|
26
|
+
shipping_address_1: '22 N str.',
|
27
|
+
shipping_first_name: 'John',
|
28
|
+
shipping_last_name: 'Doe'
|
29
|
+
}
|
30
|
+
|
31
|
+
expect(sale.send(:params_for_sale, order)).to eq(expected_params)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'successfully creates the sale' do
|
35
|
+
expect(sale.create(order, account)).to be_truthy
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with invalid Card number' do
|
40
|
+
let(:sale) { AlphaCard::Sale.new(card_expiration_date: card_exp, card_number: 'Invalid', amount: '5.00') }
|
41
|
+
|
42
|
+
it 'raises an AlphaCardError' do
|
43
|
+
expect { sale.create(order, account) }.to raise_error(AlphaCard::AlphaCardError) do |e|
|
44
|
+
expect(e.message).to include('Card number must contain only digits')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'with invalid amount' do
|
50
|
+
let(:sale) { AlphaCard::Sale.new(card_expiration_date: card_exp, card_number: '4111111111111111', amount: '0.00') }
|
51
|
+
|
52
|
+
it 'raises an AlphaCardError' do
|
53
|
+
expect { sale.create(order, account) }.to raise_error(AlphaCard::AlphaCardError) do |e|
|
54
|
+
expect(e.message).to include('Invalid amount')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'with invalid Card expiration date' do
|
60
|
+
let(:sale) { AlphaCard::Sale.new(card_expiration_date: 'Invalid', card_number: '4111111111111111', amount: '5.00') }
|
61
|
+
|
62
|
+
it 'raises an AlphaCardError' do
|
63
|
+
expect { sale.create(order, account) }.to raise_error(AlphaCard::AlphaCardError) do |e|
|
64
|
+
expect(e.message).to include('Card expiration should be in the format')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'with invalid Card CVV' do
|
70
|
+
let(:sale) { AlphaCard::Sale.new(card_expiration_date: card_exp, cvv: 'Invalid', card_number: '4111111111111111', amount: '5.00') }
|
71
|
+
|
72
|
+
it 'raises an AlphaCardError' do
|
73
|
+
expect { sale.create(order, account) }.to raise_error(AlphaCard::AlphaCardError) do |e|
|
74
|
+
expect(e.message).to include('CVV must be')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'with invalid account credentials' do
|
80
|
+
let(:invalid_account) { AlphaCard::Account.new('demo', 'Invalid password') }
|
81
|
+
let(:sale) { AlphaCard::Sale.new(card_expiration_date: card_exp, card_number: '4111111111111111', amount: '5.00') }
|
82
|
+
|
83
|
+
it 'raises an AlphaCardError' do
|
84
|
+
expect { sale.create(order, invalid_account) }.to raise_error(AlphaCard::AlphaCardError) do |e|
|
85
|
+
expect(e.message).to include('Authentication Failed')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'without attributes' do
|
91
|
+
let(:sale) { AlphaCard::Sale.new }
|
92
|
+
|
93
|
+
it 'raises an InvalidObjectError exception' do
|
94
|
+
expect { sale.create(order, account) }.to raise_error(AlphaCard::InvalidObjectError)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'with blank account credentials' do
|
99
|
+
let(:blank_account) { AlphaCard::Account.new(nil, '') }
|
100
|
+
let(:sale) { AlphaCard::Sale.new(card_expiration_date: card_exp, card_number: '4111111111111111', amount: '5.00') }
|
101
|
+
|
102
|
+
it 'raises an AlphaCardError' do
|
103
|
+
expect { sale.create(order, blank_account) }.to raise_error(AlphaCard::AlphaCardError) do |e|
|
104
|
+
expect(e.message).to include('You must set credentials to create the sale')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'with connection errors' do
|
110
|
+
let(:timeout_error) { Timeout::Error.new }
|
111
|
+
let(:socket_error) { SocketError.new }
|
112
|
+
let(:unclassified_error) { StandardError.new('Some error') }
|
113
|
+
|
114
|
+
it 'raises an APIConnectionError if Timeout Error' do
|
115
|
+
expect { AlphaCard.handle_connection_errors(timeout_error) }.to raise_error(AlphaCard::APIConnectionError) do |e|
|
116
|
+
expect(e.message).to include('Could not connect to Alpha Card Gateway')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'raises an APIConnectionError if Socket Error' do
|
121
|
+
expect { AlphaCard.handle_connection_errors(socket_error) }.to raise_error(AlphaCard::APIConnectionError) do |e|
|
122
|
+
expect(e.message).to include('Unexpected error communicating when trying to connect to Alpha Card Gateway')
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'raises an APIConnectionError if Unclassified Error' do
|
127
|
+
expect { AlphaCard.handle_connection_errors(unclassified_error) }.to raise_error(AlphaCard::APIConnectionError) do |e|
|
128
|
+
expect(e.message).to include('Unexpected error communicating with Alpha Card Gateway')
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'with request exception' do
|
133
|
+
let(:sale) { AlphaCard::Sale.new(card_expiration_date: card_exp, card_number: '4111111111111111', amount: '5.00') }
|
134
|
+
|
135
|
+
it 'handles an error' do
|
136
|
+
AlphaCard.api_base = 'https://not-existing.com'
|
137
|
+
expect { sale.create(order, account) }.to raise_error(AlphaCard::APIConnectionError)
|
138
|
+
|
139
|
+
AlphaCard.api_base = 'https://secure.alphacardgateway.com/api/transact.php'
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AlphaCard::Update do
|
4
|
+
let(:account) { AlphaCard::Account.new('demo', 'password') }
|
5
|
+
|
6
|
+
context 'with invalid attributes' do
|
7
|
+
let(:update) { AlphaCard::Update.new(transaction_id: 'Some ID') }
|
8
|
+
|
9
|
+
it 'response with error' do
|
10
|
+
expect { update.create(account) }.to raise_error(AlphaCard::AlphaCardError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'with valid attributes' do
|
15
|
+
let(:update) { AlphaCard::Update.new(transaction_id: 'Some ID', po_number: 'PO1', shipping: 'Test') }
|
16
|
+
|
17
|
+
it 'has valid request params' do
|
18
|
+
expected_params = {
|
19
|
+
transactionid: 'Some ID',
|
20
|
+
type: 'update',
|
21
|
+
ponumber: 'PO1',
|
22
|
+
shipping: 'Test'
|
23
|
+
}
|
24
|
+
|
25
|
+
expect(update.attributes_for_request).to eq(expected_params)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with blank attributes' do
|
30
|
+
let(:update) { AlphaCard::Update.new }
|
31
|
+
|
32
|
+
it 'raises an InvalidObject error' do
|
33
|
+
expect { update.create(account) }.to raise_error(AlphaCard::InvalidObjectError)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AlphaCard::Void do
|
4
|
+
let(:account) { AlphaCard::Account.new('demo', 'password') }
|
5
|
+
|
6
|
+
context 'with invalid attributes' do
|
7
|
+
let(:void) { AlphaCard::Void.new(transaction_id: 'Some ID') }
|
8
|
+
|
9
|
+
it 'response with error' do
|
10
|
+
expect { void.create(account) }.to raise_error(AlphaCard::AlphaCardError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'with valid attributes' do
|
15
|
+
let(:void) { AlphaCard::Void.new(transaction_id: '2303767426') }
|
16
|
+
|
17
|
+
let(:order) { AlphaCard::Order.new(id: '1', description: 'Test') }
|
18
|
+
let(:card_exp) { "#{'%02d' % Time.now.month}/#{Time.now.year.next}" }
|
19
|
+
let(:sale) { AlphaCard::Sale.new(card_expiration_date: card_exp, card_number: '4111111111111111', amount: '5.00') }
|
20
|
+
|
21
|
+
it 'has valid request params' do
|
22
|
+
expected_params = {
|
23
|
+
transactionid: '2303767426',
|
24
|
+
type: 'void'
|
25
|
+
}
|
26
|
+
|
27
|
+
expect(void.attributes_for_request).to eq(expected_params)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'processed successfully' do
|
31
|
+
success, response = sale.create(order, account)
|
32
|
+
expect(success).to be_truthy
|
33
|
+
expect(response.transaction_id).not_to be_nil
|
34
|
+
|
35
|
+
success, response = AlphaCard::Void.new(transaction_id: response.transaction_id).create(account)
|
36
|
+
expect(success).to be_truthy
|
37
|
+
expect(response.text).to eq('Transaction Void Successful')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with blank attributes' do
|
42
|
+
let(:void) { AlphaCard::Void.new }
|
43
|
+
|
44
|
+
it 'raises an InvalidObject error' do
|
45
|
+
expect { void.create(account) }.to raise_error(AlphaCard::InvalidObjectError)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AlphaCard::AlphaCardResponse do
|
4
|
+
let(:successful_response_mock) do
|
5
|
+
'authcode=083319&avsresponse=&cvvresponse=M&orderid=1&response=1&response_code=100&responsetext=AP&transactionid=2303767426&type=sale'
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:declined_response_mock) do
|
9
|
+
'authcode=&avsresponse=&cvvresponse=&orderid=1&response=2&response_code=220&responsetext=INVLD+ACCT&transactionid=2302720045&type=sale'
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:error_response_mock) do
|
13
|
+
'authcode=&avsresponse=U&cvvresponse=&orderid=1&response=3&response_code=220&responsetext=ERROR&transactionid=2302620041&type=sale'
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'successful request' do
|
17
|
+
let(:response) { AlphaCard::AlphaCardResponse.new(successful_response_mock) }
|
18
|
+
|
19
|
+
it '#success? = true' do
|
20
|
+
expect(response.success?).to be_truthy
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns response code' do
|
24
|
+
expect(response.code).to eq('100')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns Transaction ID' do
|
28
|
+
expect(response.transaction_id).to eq('2303767426')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns CVV response message' do
|
32
|
+
expect(response.cvv_response).to eq('CVV2/CVC2 match')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns blank AVS response message' do
|
36
|
+
expect(response.avs_response).to be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns Order ID' do
|
40
|
+
expect(response.order_id).to eq('1')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns response message' do
|
44
|
+
expect(response.message).to eq('Transaction was approved')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns auth code' do
|
48
|
+
expect(response.auth_code).to eq('083319')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'declined request' do
|
53
|
+
let(:response) { AlphaCard::AlphaCardResponse.new(declined_response_mock) }
|
54
|
+
|
55
|
+
it '#declined? = true' do
|
56
|
+
expect(response.declined?).to be_truthy
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns responce code' do
|
60
|
+
expect(response.code).to eq('220')
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns Transaction ID' do
|
64
|
+
expect(response.transaction_id).to eq('2302720045')
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'returns Order ID' do
|
68
|
+
expect(response.order_id).to eq('1')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns response message' do
|
72
|
+
expect(response.message).to eq('Incorrect payment information')
|
73
|
+
end
|
74
|
+
|
75
|
+
it "doesn't returns auth code" do
|
76
|
+
expect(response.auth_code).to be_nil.or(be_empty)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'error request' do
|
81
|
+
let(:response) { AlphaCard::AlphaCardResponse.new(error_response_mock) }
|
82
|
+
|
83
|
+
it '#error? = true' do
|
84
|
+
expect(response.error?).to be_truthy
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'returns responce code' do
|
88
|
+
expect(response.code).to eq('220')
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'returns Transaction ID' do
|
92
|
+
expect(response.transaction_id).to eq('2302620041')
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'returns Order ID' do
|
96
|
+
expect(response.order_id).to eq('1')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'returns AVS response message' do
|
100
|
+
expect(response.avs_response).to eq('Address unavailable')
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'returns response message' do
|
104
|
+
expect(response.message).to eq('Incorrect payment information')
|
105
|
+
end
|
106
|
+
|
107
|
+
it "doesn't returns auth code" do
|
108
|
+
expect(response.auth_code).to be_nil.or(be_empty)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|