vantiv 0.1.0 → 0.2.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/CHANGELOG.md +64 -0
- data/README.md +20 -4
- data/cert_fixtures/L_EP_1.json +3 -1
- data/cert_fixtures/L_EP_2.json +3 -1
- data/cert_fixtures/L_EP_3.json +3 -1
- data/cert_fixtures/L_EP_4.json +4 -0
- data/cert_fixtures/L_EP_5.json +4 -0
- data/cert_fixtures/L_EP_6.json +3 -1
- data/cert_fixtures/L_EP_7.json +3 -1
- data/exe/vantiv-certify-app +1 -0
- data/lib/vantiv.rb +13 -7
- data/lib/vantiv/api/live_transaction_response.rb +3 -1
- data/lib/vantiv/api/request_body.rb +28 -8
- data/lib/vantiv/api/response.rb +16 -5
- data/lib/vantiv/api/tokenization_response.rb +4 -0
- data/lib/vantiv/mocked_sandbox/api_request.rb +31 -3
- data/lib/vantiv/mocked_sandbox/dynamic_response_body.rb +40 -0
- data/lib/vantiv/mocked_sandbox/fixture_generator.rb +171 -19
- data/lib/vantiv/mocked_sandbox/fixtures/auth--4457002100000005.json.erb +26 -0
- data/lib/vantiv/mocked_sandbox/fixtures/auth--4457010000000009.json.erb +27 -0
- data/lib/vantiv/mocked_sandbox/fixtures/auth--5112001600000006.json.erb +26 -0
- data/lib/vantiv/mocked_sandbox/fixtures/auth--5112001900000003.json.erb +26 -0
- data/lib/vantiv/mocked_sandbox/fixtures/auth_capture--4457002100000005.json.erb +26 -0
- data/lib/vantiv/mocked_sandbox/fixtures/auth_capture--4457010000000009.json.erb +27 -0
- data/lib/vantiv/mocked_sandbox/fixtures/auth_capture--5112001600000006.json.erb +26 -0
- data/lib/vantiv/mocked_sandbox/fixtures/auth_capture--5112001900000003.json.erb +26 -0
- data/lib/vantiv/mocked_sandbox/fixtures/auth_reversal.json.erb +21 -0
- data/lib/vantiv/mocked_sandbox/fixtures/capture.json.erb +21 -0
- data/lib/vantiv/mocked_sandbox/fixtures/credit.json.erb +21 -0
- data/lib/vantiv/mocked_sandbox/fixtures/refund--4457002100000005.json.erb +22 -0
- data/lib/vantiv/mocked_sandbox/fixtures/refund--4457010000000009.json.erb +22 -0
- data/lib/vantiv/mocked_sandbox/fixtures/refund--5112001600000006.json.erb +22 -0
- data/lib/vantiv/mocked_sandbox/fixtures/refund--5112001900000003.json.erb +22 -0
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457002100000005.json.erb +4 -4
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457010000000009.json.erb +2 -2
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457010010900010.json.erb +3 -4
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001600000006.json.erb +4 -4
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001900000003.json.erb +2 -2
- data/lib/vantiv/mocked_sandbox/fixtures/void.json.erb +21 -0
- data/lib/vantiv/test_card.rb +25 -1
- data/lib/vantiv/version.rb +1 -1
- metadata +20 -2
@@ -0,0 +1,40 @@
|
|
1
|
+
module Vantiv
|
2
|
+
module MockedSandbox
|
3
|
+
class DynamicResponseBody
|
4
|
+
def self.generate(body:, litle_txn_name:, mocked_payment_account_id: nil)
|
5
|
+
new(body, litle_txn_name, mocked_payment_account_id).run
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(body, litle_txn_name, mocked_payment_account_id)
|
9
|
+
@body = body
|
10
|
+
@litle_txn_name = litle_txn_name
|
11
|
+
@mocked_payment_account_id = mocked_payment_account_id
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
litle_transaction_response["@reportGroup"] = "<%= Vantiv.default_report_group %>"
|
16
|
+
litle_transaction_response["responseTime"] = "<%= Time.now.strftime('%FT%T') %>"
|
17
|
+
litle_transaction_response["TransactionID"] = "<%= rand(10**17) %>"
|
18
|
+
if litle_transaction_response["PaymentAccountID"]
|
19
|
+
litle_transaction_response["PaymentAccountID"] = mocked_payment_account_id
|
20
|
+
end
|
21
|
+
if litle_transaction_response["postDate"]
|
22
|
+
litle_transaction_response["postDate"] = "<%= Time.now.strftime('%F') %>"
|
23
|
+
end
|
24
|
+
dynamic_body
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :body, :litle_txn_name, :mocked_payment_account_id
|
30
|
+
|
31
|
+
def litle_transaction_response
|
32
|
+
dynamic_body["litleOnlineResponse"][litle_txn_name]
|
33
|
+
end
|
34
|
+
|
35
|
+
def dynamic_body
|
36
|
+
@dynamic_body ||= body.dup
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,20 +1,31 @@
|
|
1
|
+
require 'vantiv/mocked_sandbox/dynamic_response_body'
|
2
|
+
|
1
3
|
module Vantiv
|
2
4
|
module MockedSandbox
|
3
5
|
class FixtureGenerator
|
6
|
+
|
4
7
|
def self.generate_all
|
5
|
-
|
6
|
-
new(card: card).run
|
7
|
-
end
|
8
|
+
new.run
|
8
9
|
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
def initialize(card:)
|
13
|
-
@card = card
|
14
|
-
end
|
11
|
+
attr_accessor :card
|
15
12
|
|
16
13
|
def run
|
17
|
-
|
14
|
+
TestCard.all.each do |card|
|
15
|
+
self.card = CardforFixtureGeneration.new(card)
|
16
|
+
|
17
|
+
record_tokenize_by_direct_post
|
18
|
+
if card.tokenizable?
|
19
|
+
record_auth_capture
|
20
|
+
record_auth
|
21
|
+
record_refund
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
record_capture
|
26
|
+
record_auth_reversal
|
27
|
+
record_credit
|
28
|
+
record_void
|
18
29
|
end
|
19
30
|
|
20
31
|
private
|
@@ -26,23 +37,164 @@ module Vantiv
|
|
26
37
|
expiry_year: card.expiry_year,
|
27
38
|
cvv: card.cvv
|
28
39
|
)
|
29
|
-
dynamic_body =
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
write_fixture_to_file("tokenize_by_direct_post", cert_response, dynamic_body)
|
40
|
+
dynamic_body = DynamicResponseBody.generate(
|
41
|
+
body: cert_response.body,
|
42
|
+
litle_txn_name: "registerTokenResponse",
|
43
|
+
mocked_payment_account_id: card.mocked_sandbox_payment_account_id
|
44
|
+
)
|
45
|
+
write_fixture_to_file("tokenize_by_direct_post--#{card.card_number}", cert_response, dynamic_body)
|
46
|
+
end
|
47
|
+
|
48
|
+
def record_auth_capture
|
49
|
+
cert_response = Vantiv.auth_capture(
|
50
|
+
amount: 10901,
|
51
|
+
payment_account_id: card.payment_account_id,
|
52
|
+
customer_id: "not-dynamic-cust-id",
|
53
|
+
order_id: "not-dynamic-order-id"
|
54
|
+
)
|
55
|
+
dynamic_body = DynamicResponseBody.generate(
|
56
|
+
body: cert_response.body,
|
57
|
+
litle_txn_name: "saleResponse"
|
58
|
+
)
|
59
|
+
write_fixture_to_file("auth_capture--#{card.card_number}", cert_response, dynamic_body)
|
60
|
+
end
|
61
|
+
|
62
|
+
def record_auth
|
63
|
+
cert_response = Vantiv.auth(
|
64
|
+
amount: 10901,
|
65
|
+
payment_account_id: card.payment_account_id,
|
66
|
+
customer_id: "not-dynamic-cust-id",
|
67
|
+
order_id: "not-dynamic-order-id"
|
68
|
+
)
|
69
|
+
dynamic_body = DynamicResponseBody.generate(
|
70
|
+
body: cert_response.body,
|
71
|
+
litle_txn_name: "authorizationResponse"
|
72
|
+
)
|
73
|
+
write_fixture_to_file("auth--#{card.card_number}", cert_response, dynamic_body)
|
74
|
+
end
|
75
|
+
|
76
|
+
def record_refund
|
77
|
+
cert_response = Vantiv.refund(
|
78
|
+
amount: 10901,
|
79
|
+
payment_account_id: card.payment_account_id,
|
80
|
+
customer_id: "not-dynamic-cust-id",
|
81
|
+
order_id: "not-dynamic-order-id"
|
82
|
+
)
|
83
|
+
dynamic_body = DynamicResponseBody.generate(
|
84
|
+
body: cert_response.body,
|
85
|
+
litle_txn_name: "creditResponse"
|
86
|
+
)
|
87
|
+
write_fixture_to_file("refund--#{card.card_number}", cert_response, dynamic_body)
|
88
|
+
end
|
89
|
+
|
90
|
+
def record_capture
|
91
|
+
cert_response = Vantiv.capture(
|
92
|
+
transaction_id: rand(10**17).to_s
|
93
|
+
)
|
94
|
+
dynamic_body = DynamicResponseBody.generate(
|
95
|
+
body: cert_response.body,
|
96
|
+
litle_txn_name: "captureResponse"
|
97
|
+
)
|
98
|
+
write_fixture_to_file("capture", cert_response, dynamic_body)
|
99
|
+
end
|
100
|
+
|
101
|
+
def record_auth_reversal
|
102
|
+
cert_response = Vantiv.auth_reversal(
|
103
|
+
transaction_id: rand(10**17).to_s
|
104
|
+
)
|
105
|
+
dynamic_body = DynamicResponseBody.generate(
|
106
|
+
body: cert_response.body,
|
107
|
+
litle_txn_name: "authReversalResponse"
|
108
|
+
)
|
109
|
+
write_fixture_to_file("auth_reversal", cert_response, dynamic_body)
|
110
|
+
end
|
111
|
+
|
112
|
+
def record_credit
|
113
|
+
cert_response = Vantiv.credit(
|
114
|
+
transaction_id: rand(10**17).to_s,
|
115
|
+
amount: 1010
|
116
|
+
)
|
117
|
+
dynamic_body = DynamicResponseBody.generate(
|
118
|
+
body: cert_response.body,
|
119
|
+
litle_txn_name: "creditResponse"
|
120
|
+
)
|
121
|
+
write_fixture_to_file("credit", cert_response, dynamic_body)
|
35
122
|
end
|
36
123
|
|
37
|
-
def
|
38
|
-
|
124
|
+
def record_void
|
125
|
+
cert_response = Vantiv.void(
|
126
|
+
transaction_id: rand(10**17).to_s
|
127
|
+
)
|
128
|
+
dynamic_body = DynamicResponseBody.generate(
|
129
|
+
body: cert_response.body,
|
130
|
+
litle_txn_name: "voidResponse"
|
131
|
+
)
|
132
|
+
write_fixture_to_file("void", cert_response, dynamic_body)
|
133
|
+
end
|
134
|
+
|
135
|
+
def write_fixture_to_file(file_name, response, dynamic_body)
|
136
|
+
File.open("#{MockedSandbox.fixtures_directory}/#{file_name}.json.erb", 'w') do |fixture|
|
39
137
|
fixture << JSON.pretty_generate({
|
40
|
-
httpok:
|
41
|
-
http_response_code:
|
138
|
+
httpok: response.httpok,
|
139
|
+
http_response_code: response.http_response_code,
|
42
140
|
response_body: dynamic_body
|
43
141
|
})
|
44
142
|
end
|
45
143
|
end
|
46
144
|
end
|
145
|
+
|
146
|
+
# The similarities between this and Vantiv::TestAccount are too great.
|
147
|
+
# They ought to be cleaned up and merged
|
148
|
+
class CardforFixtureGeneration
|
149
|
+
|
150
|
+
def initialize(card)
|
151
|
+
@card = card
|
152
|
+
end
|
153
|
+
|
154
|
+
def payment_account_id
|
155
|
+
@payment_account_id ||= get_payment_account_id
|
156
|
+
end
|
157
|
+
|
158
|
+
def card_number
|
159
|
+
card.card_number
|
160
|
+
end
|
161
|
+
|
162
|
+
def expiry_month
|
163
|
+
card.expiry_month
|
164
|
+
end
|
165
|
+
|
166
|
+
def expiry_year
|
167
|
+
card.expiry_year
|
168
|
+
end
|
169
|
+
|
170
|
+
def cvv
|
171
|
+
card.cvv
|
172
|
+
end
|
173
|
+
|
174
|
+
def mocked_sandbox_payment_account_id
|
175
|
+
card.mocked_sandbox_payment_account_id
|
176
|
+
end
|
177
|
+
|
178
|
+
private
|
179
|
+
|
180
|
+
attr_reader :card
|
181
|
+
|
182
|
+
def get_payment_account_id(attempts=0)
|
183
|
+
tokenization = Vantiv.tokenize_by_direct_post(
|
184
|
+
card_number: card.card_number,
|
185
|
+
expiry_month: card.expiry_month,
|
186
|
+
expiry_year: card.expiry_year,
|
187
|
+
cvv: card.cvv
|
188
|
+
)
|
189
|
+
if tokenization.success?
|
190
|
+
tokenization.payment_account_id
|
191
|
+
elsif attempts < 3
|
192
|
+
attempts += 1
|
193
|
+
get_payment_account_id(attempts)
|
194
|
+
else
|
195
|
+
raise "Tried and failed to get payment account id"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
47
199
|
end
|
48
200
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"httpok": true,
|
3
|
+
"http_response_code": "200",
|
4
|
+
"response_body": {
|
5
|
+
"litleOnlineResponse": {
|
6
|
+
"@version": "10.2",
|
7
|
+
"@response": "0",
|
8
|
+
"@message": "Valid Format",
|
9
|
+
"authorizationResponse": {
|
10
|
+
"@id": "ea04b651ada69e392e75b71b",
|
11
|
+
"@reportGroup": "<%= Vantiv.default_report_group %>",
|
12
|
+
"@customerId": "not-dynamic-cust-id",
|
13
|
+
"orderId": "not-dynamic-order-id",
|
14
|
+
"response": "110",
|
15
|
+
"responseTime": "<%= Time.now.strftime('%FT%T') %>",
|
16
|
+
"postDate": "<%= Time.now.strftime('%F') %>",
|
17
|
+
"message": "Insufficient Funds",
|
18
|
+
"fraudResult": {
|
19
|
+
"avsResult": "00"
|
20
|
+
},
|
21
|
+
"TransactionID": "<%= rand(10**17) %>"
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"RequestID": "10e05325-1f13-45a7-fdba-74e221be962a"
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"httpok": true,
|
3
|
+
"http_response_code": "200",
|
4
|
+
"response_body": {
|
5
|
+
"litleOnlineResponse": {
|
6
|
+
"@version": "10.2",
|
7
|
+
"@response": "0",
|
8
|
+
"@message": "Valid Format",
|
9
|
+
"authorizationResponse": {
|
10
|
+
"@id": "c9ce8150c1fdaae6b6ae6e97",
|
11
|
+
"@reportGroup": "<%= Vantiv.default_report_group %>",
|
12
|
+
"@customerId": "not-dynamic-cust-id",
|
13
|
+
"orderId": "not-dynamic-order-id",
|
14
|
+
"response": "000",
|
15
|
+
"responseTime": "<%= Time.now.strftime('%FT%T') %>",
|
16
|
+
"postDate": "<%= Time.now.strftime('%F') %>",
|
17
|
+
"message": "Approved",
|
18
|
+
"authCode": "11111 ",
|
19
|
+
"fraudResult": {
|
20
|
+
"avsResult": "34"
|
21
|
+
},
|
22
|
+
"TransactionID": "<%= rand(10**17) %>"
|
23
|
+
}
|
24
|
+
},
|
25
|
+
"RequestID": "beba5767-a3b2-4623-92be-db51a300a22f"
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"httpok": true,
|
3
|
+
"http_response_code": "200",
|
4
|
+
"response_body": {
|
5
|
+
"litleOnlineResponse": {
|
6
|
+
"@version": "10.2",
|
7
|
+
"@response": "0",
|
8
|
+
"@message": "Valid Format",
|
9
|
+
"authorizationResponse": {
|
10
|
+
"@id": "cf0c933b3ade43bda28faa3c",
|
11
|
+
"@reportGroup": "<%= Vantiv.default_report_group %>",
|
12
|
+
"@customerId": "not-dynamic-cust-id",
|
13
|
+
"orderId": "not-dynamic-order-id",
|
14
|
+
"response": "301",
|
15
|
+
"responseTime": "<%= Time.now.strftime('%FT%T') %>",
|
16
|
+
"postDate": "<%= Time.now.strftime('%F') %>",
|
17
|
+
"message": "Invalid Account Number",
|
18
|
+
"fraudResult": {
|
19
|
+
"avsResult": "00"
|
20
|
+
},
|
21
|
+
"TransactionID": "<%= rand(10**17) %>"
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"RequestID": "7c88df5b-8e7d-49fc-eb45-b024f9981e66"
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"httpok": true,
|
3
|
+
"http_response_code": "200",
|
4
|
+
"response_body": {
|
5
|
+
"litleOnlineResponse": {
|
6
|
+
"@version": "10.2",
|
7
|
+
"@response": "0",
|
8
|
+
"@message": "Valid Format",
|
9
|
+
"authorizationResponse": {
|
10
|
+
"@id": "bffbf3e3a1b7006a1610fbc4",
|
11
|
+
"@reportGroup": "<%= Vantiv.default_report_group %>",
|
12
|
+
"@customerId": "not-dynamic-cust-id",
|
13
|
+
"orderId": "not-dynamic-order-id",
|
14
|
+
"response": "305",
|
15
|
+
"responseTime": "<%= Time.now.strftime('%FT%T') %>",
|
16
|
+
"postDate": "<%= Time.now.strftime('%F') %>",
|
17
|
+
"message": "Expired Card",
|
18
|
+
"fraudResult": {
|
19
|
+
"avsResult": "00"
|
20
|
+
},
|
21
|
+
"TransactionID": "<%= rand(10**17) %>"
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"RequestID": "e6401ee3-e9f0-469d-f3d1-15942d410a1f"
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"httpok": true,
|
3
|
+
"http_response_code": "200",
|
4
|
+
"response_body": {
|
5
|
+
"litleOnlineResponse": {
|
6
|
+
"@version": "10.2",
|
7
|
+
"@response": "0",
|
8
|
+
"@message": "Valid Format",
|
9
|
+
"saleResponse": {
|
10
|
+
"@id": "8d1073fac5595701f5a0920c",
|
11
|
+
"@reportGroup": "<%= Vantiv.default_report_group %>",
|
12
|
+
"@customerId": "not-dynamic-cust-id",
|
13
|
+
"orderId": "not-dynamic-order-id",
|
14
|
+
"response": "110",
|
15
|
+
"responseTime": "<%= Time.now.strftime('%FT%T') %>",
|
16
|
+
"postDate": "<%= Time.now.strftime('%F') %>",
|
17
|
+
"message": "Insufficient Funds",
|
18
|
+
"fraudResult": {
|
19
|
+
"avsResult": "00"
|
20
|
+
},
|
21
|
+
"TransactionID": "<%= rand(10**17) %>"
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"RequestID": "1f58cbb6-53bb-44ba-8585-e8e1e9cb2a70"
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"httpok": true,
|
3
|
+
"http_response_code": "200",
|
4
|
+
"response_body": {
|
5
|
+
"litleOnlineResponse": {
|
6
|
+
"@version": "10.2",
|
7
|
+
"@response": "0",
|
8
|
+
"@message": "Valid Format",
|
9
|
+
"saleResponse": {
|
10
|
+
"@id": "e5d40f311477f7deb3db7a07",
|
11
|
+
"@reportGroup": "<%= Vantiv.default_report_group %>",
|
12
|
+
"@customerId": "not-dynamic-cust-id",
|
13
|
+
"orderId": "not-dynamic-order-id",
|
14
|
+
"response": "000",
|
15
|
+
"responseTime": "<%= Time.now.strftime('%FT%T') %>",
|
16
|
+
"postDate": "<%= Time.now.strftime('%F') %>",
|
17
|
+
"message": "Approved",
|
18
|
+
"authCode": "11111 ",
|
19
|
+
"fraudResult": {
|
20
|
+
"avsResult": "34"
|
21
|
+
},
|
22
|
+
"TransactionID": "<%= rand(10**17) %>"
|
23
|
+
}
|
24
|
+
},
|
25
|
+
"RequestID": "afcaf5cb-a2f0-422f-b9d7-e837518943fc"
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"httpok": true,
|
3
|
+
"http_response_code": "200",
|
4
|
+
"response_body": {
|
5
|
+
"litleOnlineResponse": {
|
6
|
+
"@version": "10.2",
|
7
|
+
"@response": "0",
|
8
|
+
"@message": "Valid Format",
|
9
|
+
"saleResponse": {
|
10
|
+
"@id": "25f3df1cbed24704f371fe8d",
|
11
|
+
"@reportGroup": "<%= Vantiv.default_report_group %>",
|
12
|
+
"@customerId": "not-dynamic-cust-id",
|
13
|
+
"orderId": "not-dynamic-order-id",
|
14
|
+
"response": "301",
|
15
|
+
"responseTime": "<%= Time.now.strftime('%FT%T') %>",
|
16
|
+
"postDate": "<%= Time.now.strftime('%F') %>",
|
17
|
+
"message": "Invalid Account Number",
|
18
|
+
"fraudResult": {
|
19
|
+
"avsResult": "00"
|
20
|
+
},
|
21
|
+
"TransactionID": "<%= rand(10**17) %>"
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"RequestID": "0d7a1748-3521-42b2-d647-02dfdf3cf52d"
|
25
|
+
}
|
26
|
+
}
|