gestpay 0.0.2 → 0.0.3
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/lib/gestpay/result/decrypt.rb +6 -0
- data/lib/gestpay/result/payment.rb +5 -0
- data/lib/gestpay/version.rb +1 -1
- data/spec/lib/gestpay/digest_spec.rb +15 -24
- data/spec/lib/gestpay/gateway_spec.rb +38 -43
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 870c93c0e54e6a987c5ce22a6d4dac61b68bb040
|
4
|
+
data.tar.gz: e651220925bd38013b1ff96f69c5acc8eebcec9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 123c1e5565a02a49b2137fc43aedb8ff022e71528037b64238903e2dcd6c33ca97b2f508a3d863889c9a7eef49a27f3298044545370a76919ad90e5f850080ba
|
7
|
+
data.tar.gz: a68273cb6d13de60e42d6f93e39c21aaeffde42589faa1cca4de716e8389734cad09d1340d0a80854523dbc535b662069566266993356c3c2637b8487963551d
|
@@ -8,6 +8,11 @@ module Gestpay
|
|
8
8
|
def verify_by_visa?
|
9
9
|
error_code == '8006'
|
10
10
|
end
|
11
|
+
|
12
|
+
def visa_encrypted_string
|
13
|
+
verify_by_visa_data = data[:vb_v]
|
14
|
+
verify_by_visa_data[:vb_v_risp] if verify_by_visa? && verify_by_visa_data[:vb_v_buyer] == 'OK'
|
15
|
+
end
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
data/lib/gestpay/version.rb
CHANGED
@@ -5,6 +5,7 @@ require (File.expand_path('../../../spec_helper', __FILE__))
|
|
5
5
|
describe Gestpay::Digest do
|
6
6
|
|
7
7
|
let(:digest) { Gestpay::Digest.new }
|
8
|
+
subject { result }
|
8
9
|
|
9
10
|
after do
|
10
11
|
VCR.eject_cassette
|
@@ -26,46 +27,36 @@ describe Gestpay::Digest do
|
|
26
27
|
}
|
27
28
|
end
|
28
29
|
|
29
|
-
it
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
it "should return a Result with a token" do
|
34
|
-
result.should be_success
|
35
|
-
result.encrypted_string.should == 'i3eUhxjb5HNxldtVSXb4qxaYva_uWKNn6BSQgRXkBUWKjoQvU6IbNgocbJYSr2LZ3FdnsvnpXH8KQ1*lizVn5LmWYMmN7JA0wMpuURkqftlBYPdjzXMmOomRrUenCF1JzE0j1ugNdSIbY7rrrUVxYAtjdvkKmyKrtLOiDuTohJsWaWGuIH4y_KUUa5cWcY3Oqz8eSjVfiWr8RUeAYCVmeA'
|
36
|
-
end
|
30
|
+
it { should respond_to(:success?) }
|
31
|
+
it { should be_success }
|
32
|
+
its(:encrypted_string) { should include('i3eUhxjb5HNxldtVSXb4qxaYva_uWKNn6BSQgRXkBUWKjoQvU6IbNgocbJYSr2LZ3FdnsvnpXH8KQ1') }
|
37
33
|
end
|
38
34
|
|
39
35
|
context "with a wrong data hash" do
|
40
36
|
before { VCR.insert_cassette 'encrypt_ko', :record => :new_episodes }
|
41
37
|
let(:hash) { Hash.new }
|
42
38
|
|
43
|
-
it
|
44
|
-
result.should_not be_success
|
45
|
-
end
|
39
|
+
it { should_not be_success }
|
46
40
|
end
|
47
41
|
end
|
48
42
|
|
49
43
|
describe '#decrypt' do
|
50
44
|
context "with an ok transaction" do
|
51
45
|
before { VCR.insert_cassette 'decrypt_ok', :record => :new_episodes }
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
46
|
+
let(:result ) { digest.decrypt('rxd4jKk3CN8PbPX7gHh9u60ocD8_R85bI0NR_C*SOk1r1y2P8E9fDBgXKmmMnyyhyosyF8X6rvyTs_GCulPAy8TZKJc99tSb57cAWuo36MZ9_OWp2pwgKYLx7jS9XaLBgAqBufiFIoPq*Pwj5SdHY06vUf3ebnKryDvRnC0oldLw1YxpkIxlebYd7YxvNfSGLfSvce2NN8wWcwPfdR2jPKb*_oJpCEVZNO5TVMaH6h1UONEksNLIuDeZPqWfrHRcgbi0MLuoifb7ZBGrTw7HlEqfF6ojKt2oihKtNdn3Y3W5MkBHCsBrWq63TLYlDU8PRaV20jAdqQIJBHopVyumMGtyLoHlMFaH*nXUvgzwmYnTtwQZ*Q1nGCP0cl4YilBcivSTJCOkcrRwUhqYOl*4F1kmT15Nkp_sBB4oJRODYs8') }
|
47
|
+
|
48
|
+
it { should be_success }
|
49
|
+
its(:buyer_name) { should == "Test Customer" }
|
50
|
+
its(:buyer_email) { should == "test@example.com" }
|
51
|
+
its(:shop_transaction_id) { should == '123' }
|
59
52
|
end
|
60
53
|
|
61
54
|
context "with a failed transaction" do
|
62
55
|
before { VCR.insert_cassette 'decrypt_ko', :record => :new_episodes }
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
result.error.should == "Error 74: Autorizzazione negata"
|
68
|
-
end
|
56
|
+
let(:result ) { digest.decrypt('KFzOej9MGr*lXEe*LOB2wzLmHja3ghKAo3iMpR1pG35moFdejWKzAj1Zd*R_e0x8qyOSTQmZVGRXEzJMVzd9xRXS*7tkbQLPOuBZ7qAtoFsX2Fxks5HxY*3YsUeiOInUXNF7*ih1bzkwmYGchDqYnEi31rN8ZYwLHnjwMIEmWJNn7oJHE6RpfUHG*7qohDxZRto*VVTPFdM93CwECq7SdYLebAQ_9EefdcE90QCRcFdGxZp_yAr_t*YRgLcZ5B5j843krtjCvf_m8nS99CroJQ768XsvlXy29McM2G*369mTufGyGMRab5PIvJlpSd3ds6mGi1IoMJAyXVkCu_ygRDDXN5Fk4Hz58LrDIci4ZszyVRcqy56SeYV7eG*kG8LZV40WV2ey8Qeh8XDUZnCV3A') }
|
57
|
+
|
58
|
+
it { should_not be_success }
|
59
|
+
its(:error) { should == "Error 74: Autorizzazione negata" }
|
69
60
|
end
|
70
61
|
end
|
71
62
|
|
@@ -5,16 +5,19 @@ require (File.expand_path('../../../spec_helper', __FILE__))
|
|
5
5
|
describe Gestpay::Gateway do
|
6
6
|
|
7
7
|
let(:gateway) { Gestpay::Gateway.new }
|
8
|
+
subject { result }
|
8
9
|
|
9
10
|
after do
|
10
11
|
VCR.eject_cassette
|
11
12
|
end
|
12
13
|
|
13
14
|
describe '#payment' do
|
15
|
+
let(:result) { gateway.payment(hash) }
|
16
|
+
|
14
17
|
context "with an ok data hash" do
|
15
18
|
before { VCR.insert_cassette 'payment_ok', :record => :new_episodes }
|
16
|
-
|
17
|
-
|
19
|
+
let(:hash) do
|
20
|
+
{
|
18
21
|
:amount => '0.02',
|
19
22
|
:shop_transaction_id => '12',
|
20
23
|
:card_number => '5364000000000987',
|
@@ -28,82 +31,74 @@ describe Gestpay::Gateway do
|
|
28
31
|
:payment_id => 15
|
29
32
|
}
|
30
33
|
}
|
31
|
-
result = gateway.payment(hash)
|
32
|
-
result.should be_success
|
33
|
-
result.amount.should == 0.02
|
34
34
|
end
|
35
|
+
|
36
|
+
it { should be_success }
|
37
|
+
its(:amount) { should == 0.02 }
|
38
|
+
its(:visa_encrypted_string) { should be_nil}
|
35
39
|
end
|
36
40
|
|
37
41
|
context "with a VISA credit card with Verification" do
|
38
42
|
before { VCR.insert_cassette 'payment_visa', :record => :new_episodes }
|
39
|
-
|
40
|
-
|
41
|
-
:card_number => '4556541926187165'
|
42
|
-
}
|
43
|
-
result = gateway.payment(hash)
|
44
|
-
result.should be_verify_by_visa
|
43
|
+
let(:hash) do
|
44
|
+
{ :card_number => '4556541926187165' }
|
45
45
|
end
|
46
|
+
|
47
|
+
it { should be_verify_by_visa }
|
48
|
+
its(:visa_encrypted_string) { should include('mRTLDNghVNbEYcEsmpi5WTNwD5XIrf2NKbO8iVRXYd5we9*K*c8') }
|
46
49
|
end
|
47
50
|
|
48
51
|
context "with an invalid credit card" do
|
49
52
|
before { VCR.insert_cassette 'payment_ko', :record => :new_episodes }
|
50
|
-
|
51
|
-
|
53
|
+
let(:hash) do
|
54
|
+
{
|
52
55
|
:amount => '0.02',
|
53
56
|
:shop_transaction_id => '12',
|
54
57
|
:card_number => '5432123456789012'
|
55
58
|
}
|
56
|
-
result = gateway.payment(hash)
|
57
|
-
result.should_not be_success
|
58
|
-
result.error.should == 'Error 74: Autorizzazione negata'
|
59
59
|
end
|
60
|
+
|
61
|
+
it { should_not be_success }
|
62
|
+
its(:error) { should == 'Error 74: Autorizzazione negata' }
|
60
63
|
end
|
61
64
|
|
62
65
|
context "with a token" do
|
63
66
|
before { VCR.insert_cassette 'payment_token', :record => :new_episodes }
|
64
|
-
|
65
|
-
|
67
|
+
let(:hash) do
|
68
|
+
{
|
66
69
|
:amount => '0.02',
|
67
70
|
:shop_transaction_id => '12',
|
68
71
|
:token_value => '53QWERTYU0I90987'
|
69
72
|
}
|
70
|
-
result = gateway.payment(hash)
|
71
|
-
result.should be_success
|
72
|
-
result.amount.should == 0.02
|
73
73
|
end
|
74
|
+
it { should be_success }
|
75
|
+
its(:amount) { should == 0.02 }
|
74
76
|
end
|
75
77
|
|
76
78
|
end
|
77
79
|
|
78
80
|
describe '#request_token' do
|
81
|
+
let(:hash) do
|
82
|
+
{
|
83
|
+
:card_number => '4556541926187165',
|
84
|
+
:expiry_month => '12',
|
85
|
+
:expiry_year => '20',
|
86
|
+
:cvv => "123",
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
79
90
|
context "with an ok data hash" do
|
80
91
|
before { VCR.insert_cassette 'request_token_ok', :record => :new_episodes }
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
:expiry_month => '12',
|
85
|
-
:expiry_year => '20',
|
86
|
-
:cvv => "123",
|
87
|
-
}
|
88
|
-
# This returned ok as we didn't verify the card with the false parameter
|
89
|
-
result = gateway.request_token(hash, false)
|
90
|
-
result.token.should == "45OGBX64451Y7165"
|
91
|
-
# result[:info] also returned
|
92
|
-
end
|
92
|
+
let(:result) { gateway.request_token(hash, false) }
|
93
|
+
|
94
|
+
its(:token) { should == "45OGBX64451Y7165" }
|
93
95
|
end
|
94
96
|
|
95
97
|
context "with an invalid credit card" do
|
96
98
|
before { VCR.insert_cassette 'request_token_ko', :record => :new_episodes }
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
:expiry_month => '12',
|
101
|
-
:expiry_year => '20',
|
102
|
-
:cvv => "123",
|
103
|
-
}
|
104
|
-
result = gateway.request_token(hash)
|
105
|
-
result.error.should == "Error 405: Autorizzazione negata dai circuiti"
|
106
|
-
end
|
99
|
+
let(:result) { gateway.request_token(hash) }
|
100
|
+
|
101
|
+
its(:error) { should == "Error 405: Autorizzazione negata dai circuiti" }
|
107
102
|
end
|
108
103
|
end
|
109
104
|
|