vantiv 0.3.0 → 1.0.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/.codeclimate.yml +16 -0
- data/.env.example +4 -2
- data/.rubocop.yml +1157 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +10 -0
- data/README.md +42 -29
- data/bin/console +5 -3
- data/bin/generate_sandbox_fixtures +5 -3
- data/bin/paypage_server +5 -3
- data/cert_fixtures/{L_AU_1.json → ACCOUNT_UPDATER_100.json} +0 -0
- data/cert_fixtures/{L_AU_3.json → ACCOUNT_UPDATER_100A.json} +0 -0
- data/cert_fixtures/{L_AU_7.json → ACCOUNT_UPDATER_100B.json} +1 -1
- data/cert_fixtures/{L_AU_2.json → ACCOUNT_UPDATER_101.json} +0 -0
- data/cert_fixtures/{L_AU_4.json → ACCOUNT_UPDATER_101A.json} +0 -0
- data/cert_fixtures/{L_AU_5.json → ACCOUNT_UPDATER_102.json} +0 -0
- data/cert_fixtures/{L_AU_6.json → ACCOUNT_UPDATER_103.json} +0 -0
- data/cert_fixtures/{L_AC_1.json → AUTH_CAPTURE_1.json} +0 -0
- data/cert_fixtures/AUTH_CAPTURE_1A.json +8 -0
- data/cert_fixtures/{L_AC_2.json → AUTH_CAPTURE_2.json} +0 -0
- data/cert_fixtures/AUTH_CAPTURE_2A.json +8 -0
- data/cert_fixtures/{L_AC_3.json → AUTH_CAPTURE_3.json} +0 -0
- data/cert_fixtures/AUTH_CAPTURE_3A.json +8 -0
- data/cert_fixtures/{L_AC_4.json → AUTH_CAPTURE_4.json} +0 -0
- data/cert_fixtures/AUTH_CAPTURE_4A.json +8 -0
- data/cert_fixtures/{L_AC_5.json → AUTH_CAPTURE_5.json} +0 -0
- data/cert_fixtures/AUTH_CAPTURE_5A.json +8 -0
- data/cert_fixtures/{L_AC_6.json → AUTH_CAPTURE_6.json} +0 -0
- data/cert_fixtures/{L_AC_7.json → AUTH_CAPTURE_7.json} +0 -0
- data/cert_fixtures/{L_AC_8.json → AUTH_CAPTURE_8.json} +0 -0
- data/cert_fixtures/{L_AC_9.json → AUTH_CAPTURE_9.json} +0 -0
- data/cert_fixtures/{L_AR_1.json → AUTH_REVERSAL_32.json} +0 -0
- data/cert_fixtures/{L_AR_1A.json → AUTH_REVERSAL_32A.json} +1 -1
- data/cert_fixtures/AUTH_REVERSAL_32B.json +8 -0
- data/cert_fixtures/{L_AR_2.json → AUTH_REVERSAL_33.json} +0 -0
- data/cert_fixtures/AUTH_REVERSAL_33A.json +8 -0
- data/cert_fixtures/{L_AR_3.json → AUTH_REVERSAL_34.json} +0 -0
- data/cert_fixtures/AUTH_REVERSAL_34A.json +8 -0
- data/cert_fixtures/{L_AR_4.json → AUTH_REVERSAL_35.json} +0 -0
- data/cert_fixtures/{L_AR_4A.json → AUTH_REVERSAL_35A.json} +1 -1
- data/cert_fixtures/{L_AR_4B.json → AUTH_REVERSAL_35B.json} +1 -1
- data/cert_fixtures/{L_AR_5.json → AUTH_REVERSAL_36.json} +0 -0
- data/cert_fixtures/{L_AR_5A.json → AUTH_REVERSAL_36A.json} +1 -1
- data/cert_fixtures/{L_RC_1.json → CREDIT_1.json} +0 -0
- data/cert_fixtures/CREDIT_1A.json +8 -0
- data/cert_fixtures/CREDIT_1B.json +8 -0
- data/cert_fixtures/{L_RC_2.json → CREDIT_2.json} +0 -0
- data/cert_fixtures/CREDIT_2A.json +8 -0
- data/cert_fixtures/CREDIT_2B.json +8 -0
- data/cert_fixtures/{L_RC_3.json → CREDIT_3.json} +0 -0
- data/cert_fixtures/CREDIT_3A.json +8 -0
- data/cert_fixtures/CREDIT_3B.json +8 -0
- data/cert_fixtures/{L_RC_4.json → CREDIT_4.json} +0 -0
- data/cert_fixtures/CREDIT_4A.json +8 -0
- data/cert_fixtures/CREDIT_4B.json +8 -0
- data/cert_fixtures/{L_RC_5.json → CREDIT_5.json} +0 -0
- data/cert_fixtures/CREDIT_5A.json +8 -0
- data/cert_fixtures/CREDIT_5B.json +8 -0
- data/cert_fixtures/{L_RC_6.json → SALE_1.json} +0 -0
- data/cert_fixtures/{L_S_2.json → SALE_2.json} +0 -0
- data/cert_fixtures/{L_S_3.json → SALE_3.json} +0 -0
- data/cert_fixtures/{L_S_4.json → SALE_4.json} +0 -0
- data/cert_fixtures/{L_S_5.json → SALE_5.json} +0 -0
- data/cert_fixtures/{L_S_6.json → SALE_6.json} +0 -0
- data/cert_fixtures/{L_S_7.json → SALE_7.json} +0 -0
- data/cert_fixtures/{L_S_8.json → SALE_8.json} +0 -0
- data/cert_fixtures/{L_S_9.json → SALE_9.json} +0 -0
- data/cert_fixtures/{L_S_1.json → SECURITY_CODE_FILTER_R1.json} +9 -9
- data/cert_fixtures/SECURITY_CODE_FILTER_R2.json +27 -0
- data/cert_fixtures/{L_T_1.json → TOKENIZATION_1.json} +0 -0
- data/cert_fixtures/{L_T_10.json → TOKENIZATION_10.json} +0 -0
- data/cert_fixtures/{L_T_11.json → TOKENIZATION_11.json} +0 -0
- data/cert_fixtures/{L_T_2.json → TOKENIZATION_2.json} +0 -0
- data/cert_fixtures/{L_T_3.json → TOKENIZATION_3.json} +0 -0
- data/cert_fixtures/{L_T_4.json → TOKENIZATION_4.json} +0 -0
- data/cert_fixtures/{L_T_6.json → TOKENIZATION_6.json} +0 -0
- data/cert_fixtures/{L_T_7.json → TOKENIZATION_7.json} +0 -0
- data/cert_fixtures/{L_T_8.json → TOKENIZATION_8.json} +0 -0
- data/cert_fixtures/{L_T_9.json → TOKENIZATION_9.json} +1 -1
- data/cert_fixtures/{L_V_1.json → VOID_1.json} +0 -0
- data/cert_fixtures/VOID_1A.json +8 -0
- data/cert_fixtures/VOID_1B.json +8 -0
- data/cert_fixtures/VOID_1C.json +8 -0
- data/cert_fixtures/{L_V_2.json → VOID_2.json} +0 -0
- data/cert_fixtures/VOID_2A.json +8 -0
- data/cert_fixtures/{L_V_3.json → VOID_3.json} +0 -0
- data/cert_fixtures/VOID_3A.json +8 -0
- data/cert_fixtures/{L_V_4.json → VOID_4.json} +0 -0
- data/cert_fixtures/VOID_4A.json +8 -0
- data/cert_fixtures/{L_EP_1.json → ePROTECT_1.json} +0 -0
- data/cert_fixtures/{L_EP_2.json → ePROTECT_2.json} +0 -0
- data/cert_fixtures/{L_EP_3.json → ePROTECT_3.json} +0 -0
- data/cert_fixtures/{L_EP_4.json → ePROTECT_4.json} +1 -1
- data/cert_fixtures/{L_EP_5.json → ePROTECT_5.json} +1 -1
- data/cert_fixtures/{L_EP_6.json → ePROTECT_6.json} +0 -0
- data/cert_fixtures/{L_EP_7.json → ePROTECT_7.json} +0 -0
- data/exe/vantiv-certify-app +18 -12
- data/lib/monkey_patches/representable/xml.rb +12 -0
- data/lib/vantiv.rb +39 -14
- data/lib/vantiv/api.rb +13 -1
- data/lib/vantiv/api/account_updater_response.rb +24 -29
- data/lib/vantiv/api/address.rb +8 -0
- data/lib/vantiv/api/apple_pay_response.rb +9 -0
- data/lib/vantiv/api/capture_response.rb +1 -1
- data/lib/vantiv/api/card.rb +47 -0
- data/lib/vantiv/api/cardholder_authentication.rb +11 -0
- data/lib/vantiv/api/fraud_result.rb +7 -0
- data/lib/vantiv/api/live_transaction_response.rb +4 -5
- data/lib/vantiv/api/payment_account.rb +11 -0
- data/lib/vantiv/api/request.rb +72 -33
- data/lib/vantiv/api/request_body.rb +100 -97
- data/lib/vantiv/api/request_body_representer.rb +54 -0
- data/lib/vantiv/api/request_body_representer_xml.rb +19 -0
- data/lib/vantiv/api/response.rb +9 -29
- data/lib/vantiv/api/response_body.rb +12 -0
- data/lib/vantiv/api/response_body_representer.rb +23 -0
- data/lib/vantiv/api/response_body_representer_xml.rb +25 -0
- data/lib/vantiv/api/tied_transaction_response.rb +5 -5
- data/lib/vantiv/api/tokenization_response.rb +15 -9
- data/lib/vantiv/api/transaction.rb +42 -0
- data/lib/vantiv/api/transaction_request_representer_xml.rb +57 -0
- data/lib/vantiv/api/transaction_response.rb +9 -0
- data/lib/vantiv/api/transaction_response_representer.rb +64 -0
- data/lib/vantiv/api/transaction_response_representer_xml.rb +54 -0
- data/lib/vantiv/certification/paypage_server.rb +13 -2
- data/lib/vantiv/certification/response_cache.rb +4 -12
- data/lib/vantiv/certification/validation_test_runner.rb +29 -10
- data/lib/vantiv/mocked_sandbox.rb +3 -2
- data/lib/vantiv/mocked_sandbox/api_request.rb +56 -27
- data/lib/vantiv/mocked_sandbox/fixture_generator.rb +56 -50
- data/lib/vantiv/mocked_sandbox/fixtures/{auth--4457000300000007.json.erb → auth--4457000300000007.json} +18 -16
- data/lib/vantiv/mocked_sandbox/fixtures/{auth--4457000301100004.json.erb → auth--4457000301100004.json} +16 -14
- data/lib/vantiv/mocked_sandbox/fixtures/{auth--4457002100000005.json.erb → auth--4457002100000005.json} +10 -10
- data/lib/vantiv/mocked_sandbox/fixtures/{auth--4457010000000009.json.erb → auth--4457010000000009.json} +11 -11
- data/lib/vantiv/mocked_sandbox/fixtures/{auth--5112000101110009.json.erb → auth--5112000101110009.json} +16 -16
- data/lib/vantiv/mocked_sandbox/fixtures/{auth--5112001600000006.json.erb → auth--5112001600000006.json} +10 -10
- data/lib/vantiv/mocked_sandbox/fixtures/{auth--5112001900000003.json.erb → auth--5112001900000003.json} +10 -10
- data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--4457000300000007.json.erb → auth_capture--4457000300000007.json} +18 -16
- data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--4457000301100004.json.erb → auth_capture--4457000301100004.json} +16 -14
- data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--4457002100000005.json.erb → auth_capture--4457002100000005.json} +10 -10
- data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--4457010000000009.json.erb → auth_capture--4457010000000009.json} +11 -11
- data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--5112000101110009.json.erb → auth_capture--5112000101110009.json} +16 -16
- data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--5112001600000006.json.erb → auth_capture--5112001600000006.json} +10 -10
- data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--5112001900000003.json.erb → auth_capture--5112001900000003.json} +10 -10
- data/lib/vantiv/mocked_sandbox/fixtures/auth_reversal.json +21 -0
- data/lib/vantiv/mocked_sandbox/fixtures/capture.json +21 -0
- data/lib/vantiv/mocked_sandbox/fixtures/credit.json +21 -0
- data/lib/vantiv/mocked_sandbox/fixtures/refund--4457000300000007.json +22 -0
- data/lib/vantiv/mocked_sandbox/fixtures/refund--4457000301100004.json +22 -0
- data/lib/vantiv/mocked_sandbox/fixtures/refund--4457002100000005.json +22 -0
- data/lib/vantiv/mocked_sandbox/fixtures/refund--4457010000000009.json +22 -0
- data/lib/vantiv/mocked_sandbox/fixtures/refund--5112000101110009.json +22 -0
- data/lib/vantiv/mocked_sandbox/fixtures/refund--5112001600000006.json +22 -0
- data/lib/vantiv/mocked_sandbox/fixtures/refund--5112001900000003.json +22 -0
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize--RGFQNCt6U1d1M21SeVByVTM4dHlHb1FsVkUrSmpnWXhNY0o5UkMzRlZFanZiUHVnYjN1enJXbG1WSDF4aXlNc.json +17 -0
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize--mocked-valid-temporary-token.json +23 -0
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize--pDZJcmd1VjNlYXNaSlRMTGpocVZQY1NWVXE4Z W5UTko4NU9KK3p1L1p1Vzg4YzVPQVlSUHNITG1 JN2I0Nzl.json +17 -0
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457000300000007.json +23 -0
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457000301100004.json +23 -0
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457002100000005.json +23 -0
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457010000000009.json +23 -0
- data/lib/vantiv/mocked_sandbox/fixtures/{tokenize_by_direct_post--4457010010900010.json.erb → tokenize_by_direct_post--4457010010900010.json} +8 -8
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112000101110009.json +23 -0
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001600000006.json +23 -0
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001900000003.json +23 -0
- data/lib/vantiv/mocked_sandbox/fixtures/void.json +21 -0
- data/lib/vantiv/mocked_sandbox/mocked_response_representer.rb +11 -0
- data/lib/vantiv/paypage.rb +5 -1
- data/lib/vantiv/test_temporary_token.rb +20 -0
- data/lib/vantiv/version.rb +1 -1
- data/vantiv-ruby.gemspec +5 -1
- metadata +191 -129
- data/cert_fixtures/L_AC_1A.json +0 -8
- data/cert_fixtures/L_AC_2A.json +0 -8
- data/cert_fixtures/L_AC_3A.json +0 -8
- data/cert_fixtures/L_AC_4A.json +0 -8
- data/cert_fixtures/L_AC_5A.json +0 -8
- data/cert_fixtures/L_AR_1B.json +0 -8
- data/cert_fixtures/L_AR_2A.json +0 -8
- data/cert_fixtures/L_AR_3A.json +0 -8
- data/cert_fixtures/L_RC_1A.json +0 -8
- data/cert_fixtures/L_RC_1B.json +0 -8
- data/cert_fixtures/L_RC_2A.json +0 -8
- data/cert_fixtures/L_RC_2B.json +0 -8
- data/cert_fixtures/L_RC_3A.json +0 -8
- data/cert_fixtures/L_RC_3B.json +0 -8
- data/cert_fixtures/L_RC_4A.json +0 -8
- data/cert_fixtures/L_RC_4B.json +0 -8
- data/cert_fixtures/L_RC_5A.json +0 -8
- data/cert_fixtures/L_RC_5B.json +0 -8
- data/cert_fixtures/L_RC_6A.json +0 -8
- data/cert_fixtures/L_RC_7.json +0 -26
- data/cert_fixtures/L_RC_7A.json +0 -8
- data/cert_fixtures/L_RC_8.json +0 -18
- data/cert_fixtures/L_V_1A.json +0 -8
- data/cert_fixtures/L_V_1B.json +0 -8
- data/cert_fixtures/L_V_1C.json +0 -8
- data/cert_fixtures/L_V_2A.json +0 -8
- data/cert_fixtures/L_V_3A.json +0 -8
- data/cert_fixtures/L_V_4A.json +0 -8
- data/lib/vantiv/api/request_body_generator.rb +0 -43
- data/lib/vantiv/mocked_sandbox/dynamic_response_body.rb +0 -40
- data/lib/vantiv/mocked_sandbox/fixtures/auth_reversal.json.erb +0 -21
- data/lib/vantiv/mocked_sandbox/fixtures/capture.json.erb +0 -21
- data/lib/vantiv/mocked_sandbox/fixtures/credit.json.erb +0 -21
- data/lib/vantiv/mocked_sandbox/fixtures/refund--4457000300000007.json.erb +0 -22
- data/lib/vantiv/mocked_sandbox/fixtures/refund--4457000301100004.json.erb +0 -22
- data/lib/vantiv/mocked_sandbox/fixtures/refund--4457002100000005.json.erb +0 -22
- data/lib/vantiv/mocked_sandbox/fixtures/refund--4457010000000009.json.erb +0 -22
- data/lib/vantiv/mocked_sandbox/fixtures/refund--5112000101110009.json.erb +0 -22
- data/lib/vantiv/mocked_sandbox/fixtures/refund--5112001600000006.json.erb +0 -22
- data/lib/vantiv/mocked_sandbox/fixtures/refund--5112001900000003.json.erb +0 -22
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457000300000007.json.erb +0 -23
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457000301100004.json.erb +0 -23
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457002100000005.json.erb +0 -23
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457010000000009.json.erb +0 -23
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112000101110009.json.erb +0 -23
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001600000006.json.erb +0 -23
- data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001900000003.json.erb +0 -23
- data/lib/vantiv/mocked_sandbox/fixtures/void.json.erb +0 -21
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'vantiv/api/account_updater_response'
|
2
|
+
require 'vantiv/api/apple_pay_response'
|
3
|
+
|
4
|
+
class TransactionResponseRepresenterXml < Representable::Decorator
|
5
|
+
include Representable::XML
|
6
|
+
|
7
|
+
property :id, as: :id, property: true
|
8
|
+
property :report_group, as: :reportGroup, property: true
|
9
|
+
property :customer_id, as: :customerId, property: true
|
10
|
+
|
11
|
+
property :transaction_id, as: :litleTxnId
|
12
|
+
property :payment_account_id, as: :litleToken
|
13
|
+
property :order_id, as: :orderId
|
14
|
+
property :response_code, as: :response
|
15
|
+
property :response_time, as: :responseTime
|
16
|
+
property :message
|
17
|
+
property :auth_code, as: :authCode
|
18
|
+
property :type, as: :type
|
19
|
+
|
20
|
+
property :account_updater, as: :accountUpdater, class: Vantiv::Api::AccountUpdaterResponse do
|
21
|
+
property :original_card_token_info, as: :originalCardTokenInfo, class: Vantiv::Api::CardTokenInfo do
|
22
|
+
property :payment_account_id, as: :litleToken
|
23
|
+
property :card_type, as: :type
|
24
|
+
property :bin
|
25
|
+
property :expiry_date, as: :expDate
|
26
|
+
end
|
27
|
+
|
28
|
+
property :new_card_token_info, as: :newCardTokenInfo, class: Vantiv::Api::CardTokenInfo do
|
29
|
+
property :payment_account_id, as: :litleToken
|
30
|
+
property :card_type, as: :type
|
31
|
+
property :bin
|
32
|
+
property :expiry_date, as: :expDate
|
33
|
+
end
|
34
|
+
|
35
|
+
property :extended_card_response, as: :extendedCardResponse, class: Vantiv::Api::ExtendedCardResponse do
|
36
|
+
property :code
|
37
|
+
property :message
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
property :fraud_result, as: :fraudResult, class: Vantiv::Api::FraudResult do
|
42
|
+
property :avs_result, as: :avsResult
|
43
|
+
end
|
44
|
+
|
45
|
+
property :token_response, as: :tokenResponse, class: Vantiv::Api::CardTokenInfo do
|
46
|
+
property :payment_account_id, as: :litleToken
|
47
|
+
property :card_type, as: :type
|
48
|
+
property :bin
|
49
|
+
end
|
50
|
+
|
51
|
+
property :apple_pay_response, as: :applepayResponse, class: Vantiv::Api::ApplePayResponse do
|
52
|
+
property :online_payment_cryptogram, as: :onlinePaymentCryptogram
|
53
|
+
end
|
54
|
+
end
|
@@ -13,7 +13,13 @@ module Vantiv
|
|
13
13
|
|
14
14
|
def start
|
15
15
|
if threaded
|
16
|
-
@server_thread = Thread.new
|
16
|
+
@server_thread = Thread.new do
|
17
|
+
compile_template
|
18
|
+
server = WEBrick::HTTPServer.new :Port => port, :DocumentRoot => document_root
|
19
|
+
Thread.current.thread_variable_set(:server, server)
|
20
|
+
trap('INT') { server.shutdown }
|
21
|
+
server.start
|
22
|
+
end
|
17
23
|
else
|
18
24
|
start_server
|
19
25
|
end
|
@@ -24,7 +30,12 @@ module Vantiv
|
|
24
30
|
end
|
25
31
|
|
26
32
|
def stop
|
27
|
-
threaded
|
33
|
+
if threaded
|
34
|
+
server_thread.thread_variable_get(:server).shutdown
|
35
|
+
Thread.kill(server_thread)
|
36
|
+
else
|
37
|
+
stop_server
|
38
|
+
end
|
28
39
|
end
|
29
40
|
|
30
41
|
private
|
@@ -6,22 +6,14 @@ module Vantiv
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def push(cert_name, response)
|
9
|
-
responses[cert_name] = response
|
9
|
+
@responses[cert_name] = response
|
10
10
|
end
|
11
11
|
|
12
12
|
def access_value(values_tree)
|
13
13
|
cert_name = values_tree.shift
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
attr_reader :responses
|
22
|
-
|
23
|
-
def get_value(source, keys)
|
24
|
-
keys.any? ? get_value(source[keys.shift], keys) : source
|
14
|
+
response = @responses[cert_name]
|
15
|
+
method_chain = values_tree.join('.')
|
16
|
+
response.instance_eval(method_chain)
|
25
17
|
end
|
26
18
|
end
|
27
19
|
|
@@ -6,20 +6,30 @@ require 'vantiv/certification/cert_request_body_compiler'
|
|
6
6
|
module Vantiv
|
7
7
|
module Certification
|
8
8
|
class ValidationTestRunner
|
9
|
-
|
10
|
-
|
11
|
-
new(
|
9
|
+
ENDPOINT_RESPONSE_OBJECT = {
|
10
|
+
Api::Endpoints::TOKENIZATION => Api::TokenizationResponse.new,
|
11
|
+
Api::Endpoints::AUTHORIZATION => Api::LiveTransactionResponse.new(:auth),
|
12
|
+
Api::Endpoints::AUTH_REVERSAL => Api::TiedTransactionResponse.new(:auth_reversal),
|
13
|
+
Api::Endpoints::CAPTURE => Api::TiedTransactionResponse.new(:capture),
|
14
|
+
Api::Endpoints::SALE => Api::LiveTransactionResponse.new(:sale),
|
15
|
+
Api::Endpoints::CREDIT => Api::TiedTransactionResponse.new(:credit),
|
16
|
+
Api::Endpoints::RETURN => Api::TiedTransactionResponse.new(:return),
|
17
|
+
Api::Endpoints::VOID => Api::TiedTransactionResponse.new(:void)
|
18
|
+
}
|
19
|
+
|
20
|
+
def self.run(save_to:, filter_by: '')
|
21
|
+
new(save_to: save_to, filter_by: filter_by).run
|
12
22
|
end
|
13
23
|
|
14
|
-
def initialize(filter_by: ''
|
15
|
-
@filter_by = filter_by
|
24
|
+
def initialize(save_to:, filter_by: '')
|
16
25
|
@certs_file = save_to
|
26
|
+
@filter_by = filter_by
|
17
27
|
end
|
18
28
|
|
19
29
|
def run
|
20
30
|
fixtures.each do |file_name|
|
21
31
|
cert_name = get_cert_name(file_name)
|
22
|
-
next if filter_by &&
|
32
|
+
next if filter_by && !/#{filter_by}_\d*/.match(cert_name)
|
23
33
|
|
24
34
|
contents = JSON.parse(File.read(file_name))
|
25
35
|
run_request(
|
@@ -37,7 +47,8 @@ module Vantiv
|
|
37
47
|
|
38
48
|
def create_body(base_body)
|
39
49
|
compiled_base = request_body_compiler.compile(base_body)
|
40
|
-
Vantiv::Api::
|
50
|
+
request_body = Vantiv::Api::RequestBody.new
|
51
|
+
RequestBodyRepresenter.new(request_body).from_json(compiled_base.to_json)
|
41
52
|
end
|
42
53
|
|
43
54
|
def fixtures
|
@@ -92,16 +103,24 @@ module Vantiv
|
|
92
103
|
response = Vantiv::Api::Request.new(
|
93
104
|
endpoint: endpoint,
|
94
105
|
body: body,
|
95
|
-
response_object:
|
106
|
+
response_object: ENDPOINT_RESPONSE_OBJECT.fetch(endpoint)
|
96
107
|
).run
|
97
108
|
|
98
109
|
if response.api_level_failure?
|
99
|
-
error_message = "CERT FAILED: #{cert_name} \n WITH: #{response.
|
110
|
+
error_message = "CERT FAILED: #{cert_name} \n WITH: #{response.raw_body}"
|
100
111
|
raise StandardError.new(error_message)
|
101
112
|
end
|
102
113
|
|
114
|
+
transaction_id = get_transaction_id(response)
|
115
|
+
|
103
116
|
response_cache.push(cert_name, response)
|
104
|
-
results_file << "#{cert_name},#{
|
117
|
+
results_file << "#{cert_name},#{transaction_id}\n"
|
118
|
+
end
|
119
|
+
|
120
|
+
def get_transaction_id(response)
|
121
|
+
transaction_response_name = response.send(:transaction_response_name)
|
122
|
+
transaction_response = response.body.send(transaction_response_name)
|
123
|
+
transaction_response.transaction_id
|
105
124
|
end
|
106
125
|
end
|
107
126
|
end
|
@@ -10,8 +10,9 @@ module Vantiv
|
|
10
10
|
end
|
11
11
|
Vantiv::Api::Request.send(:define_method, :run_request) do
|
12
12
|
Vantiv::MockedSandbox::ApiRequest.run(
|
13
|
-
endpoint: endpoint,
|
14
|
-
body: body
|
13
|
+
endpoint: @endpoint,
|
14
|
+
body: body,
|
15
|
+
response_object: @response_object
|
15
16
|
)
|
16
17
|
end
|
17
18
|
end
|
@@ -1,22 +1,30 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'vantiv/api/response'
|
3
|
+
require 'vantiv/api/live_transaction_response'
|
4
|
+
require 'vantiv/mocked_sandbox/mocked_response_representer'
|
5
|
+
|
1
6
|
module Vantiv
|
2
7
|
module MockedSandbox
|
3
8
|
class ApiRequest
|
4
9
|
class EndpointNotMocked < StandardError; end
|
5
10
|
class FixtureNotFound < StandardError; end
|
6
11
|
|
7
|
-
def self.run(endpoint:, body:)
|
8
|
-
new(endpoint, body).run
|
12
|
+
def self.run(endpoint:, body:, response_object:)
|
13
|
+
new(endpoint, body, response_object).run
|
9
14
|
end
|
10
15
|
|
11
|
-
def initialize(endpoint, request_body)
|
16
|
+
def initialize(endpoint, request_body, response_object)
|
12
17
|
self.endpoint = endpoint
|
13
|
-
self.request_body =
|
18
|
+
self.request_body = request_body
|
19
|
+
self.response_object = response_object
|
14
20
|
end
|
15
21
|
|
16
22
|
def run
|
17
23
|
if endpoint == Api::Endpoints::TOKENIZATION
|
18
24
|
if direct_post?
|
19
25
|
load_fixture("tokenize_by_direct_post", card_number)
|
26
|
+
else
|
27
|
+
load_fixture("tokenize", temporary_token)
|
20
28
|
end
|
21
29
|
elsif endpoint == Api::Endpoints::SALE
|
22
30
|
load_fixture("auth_capture", card_number_from_payment_account_id)
|
@@ -35,46 +43,67 @@ module Vantiv
|
|
35
43
|
else
|
36
44
|
raise EndpointNotMocked.new("#{endpoint} is not mocked!")
|
37
45
|
end
|
38
|
-
{
|
39
|
-
httpok: fixture["httpok"],
|
40
|
-
http_response_code: fixture["http_response_code"],
|
41
|
-
body: JSON.parse(ERB.new(fixture["response_body"]).result(binding))
|
42
|
-
}
|
43
46
|
end
|
44
47
|
|
45
48
|
private
|
46
49
|
|
47
|
-
attr_accessor :endpoint, :request_body, :fixture
|
50
|
+
attr_accessor :endpoint, :request_body, :fixture, :response_object
|
48
51
|
|
49
52
|
def direct_post?
|
50
|
-
|
53
|
+
!card_number.nil?
|
54
|
+
end
|
55
|
+
|
56
|
+
def temporary_token
|
57
|
+
request_body.card.paypage_registration_id
|
51
58
|
end
|
52
59
|
|
53
60
|
def card_number
|
54
|
-
request_body
|
61
|
+
request_body.card.account_number
|
55
62
|
end
|
56
63
|
|
57
64
|
def card_number_from_payment_account_id
|
58
65
|
TestCard.find_by_payment_account_id(
|
59
|
-
request_body
|
66
|
+
request_body.payment_account.id
|
60
67
|
).card_number
|
61
68
|
end
|
62
69
|
|
63
|
-
def load_fixture(api_method,
|
64
|
-
fixture_file_name =
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
def load_fixture(api_method, card_number_or_temporary_token = nil)
|
71
|
+
fixture_file_name = card_number_or_temporary_token ? "#{api_method}--#{card_number_or_temporary_token}" : api_method
|
72
|
+
|
73
|
+
fixtures_path = Pathname.new Vantiv::MockedSandbox.fixtures_directory
|
74
|
+
|
75
|
+
path = fixtures_path.children.detect do |child_path|
|
76
|
+
filename = child_path.basename.to_s.split(child_path.extname).first
|
77
|
+
fixture_file_name.start_with? filename
|
78
|
+
end
|
79
|
+
|
80
|
+
if path.nil?
|
81
|
+
raise FixtureNotFound.new("Fixture not found for api method: #{api_method}, card number or temporary token: #{card_number_or_temporary_token}")
|
82
|
+
end
|
83
|
+
|
84
|
+
self.fixture = path.open do |f|
|
85
|
+
raw_fixture = f.read
|
86
|
+
response = MockedResponseRepresenter.new(response_object).from_json(raw_fixture)
|
87
|
+
|
88
|
+
populated_response = populate_dynamic_response(response)
|
89
|
+
|
90
|
+
populated_response.raw_body = response.body.to_s
|
91
|
+
populated_response
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def populate_dynamic_response(response)
|
96
|
+
dynamic_response = response.dup
|
97
|
+
transaction_response = dynamic_response.send(:litle_transaction_response)
|
98
|
+
|
99
|
+
transaction_response.report_group = Vantiv.default_report_group
|
100
|
+
transaction_response.response_time = Time.now.strftime('%FT%T')
|
101
|
+
transaction_response.transaction_id = rand(10**17).to_s
|
102
|
+
|
103
|
+
if transaction_response.post_date
|
104
|
+
transaction_response.post_date = Time.now.strftime('%F')
|
77
105
|
end
|
106
|
+
dynamic_response
|
78
107
|
end
|
79
108
|
end
|
80
109
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'vantiv/
|
1
|
+
require 'vantiv/certification/paypage_driver'
|
2
|
+
require 'vantiv/mocked_sandbox/mocked_response_representer'
|
2
3
|
|
3
4
|
module Vantiv
|
4
5
|
module MockedSandbox
|
5
6
|
class FixtureGenerator
|
6
|
-
|
7
7
|
def self.generate_all
|
8
8
|
new.run
|
9
9
|
end
|
@@ -11,6 +11,8 @@ module Vantiv
|
|
11
11
|
attr_accessor :card
|
12
12
|
|
13
13
|
def run
|
14
|
+
record_tokenize
|
15
|
+
|
14
16
|
TestCard.all.each do |card|
|
15
17
|
self.card = CardforFixtureGeneration.new(card)
|
16
18
|
|
@@ -30,6 +32,44 @@ module Vantiv
|
|
30
32
|
|
31
33
|
private
|
32
34
|
|
35
|
+
def record_tokenize
|
36
|
+
@paypage_driver = Vantiv::Certification::PaypageDriver.new
|
37
|
+
@paypage_driver.start
|
38
|
+
|
39
|
+
TestTemporaryToken.all.each do |test_temporary_token|
|
40
|
+
if requires_live_paypage_response?(test_temporary_token)
|
41
|
+
test_card = Vantiv::TestCard.valid_account
|
42
|
+
mocked_payment_account_id = test_card.mocked_sandbox_payment_account_id
|
43
|
+
live_temporary_token = @paypage_driver.get_paypage_registration_id(test_card.card_number, test_card.cvv)
|
44
|
+
else
|
45
|
+
mocked_payment_account_id = nil
|
46
|
+
live_temporary_token = test_temporary_token
|
47
|
+
end
|
48
|
+
|
49
|
+
record_tokenize_for_test_token(
|
50
|
+
test_temporary_token: test_temporary_token,
|
51
|
+
live_temporary_token: live_temporary_token,
|
52
|
+
mocked_payment_account_id: mocked_payment_account_id
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
@paypage_driver.stop
|
57
|
+
end
|
58
|
+
|
59
|
+
def record_tokenize_for_test_token(test_temporary_token:, live_temporary_token:, mocked_payment_account_id:)
|
60
|
+
cert_response = Vantiv.tokenize(temporary_token: live_temporary_token)
|
61
|
+
cert_response.body.register_token_response.payment_account_id = mocked_payment_account_id
|
62
|
+
file_name = "tokenize--#{test_temporary_token}"[0..94]
|
63
|
+
write_fixture_to_file(
|
64
|
+
file_name,
|
65
|
+
cert_response
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
def requires_live_paypage_response?(test_temporary_token)
|
70
|
+
test_temporary_token == TestTemporaryToken.valid_temporary_token
|
71
|
+
end
|
72
|
+
|
33
73
|
def record_tokenize_by_direct_post
|
34
74
|
cert_response = Vantiv.tokenize_by_direct_post(
|
35
75
|
card_number: card.card_number,
|
@@ -37,12 +77,8 @@ module Vantiv
|
|
37
77
|
expiry_year: card.expiry_year,
|
38
78
|
cvv: card.cvv
|
39
79
|
)
|
40
|
-
|
41
|
-
|
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)
|
80
|
+
cert_response.body.register_token_response.payment_account_id = card.mocked_sandbox_payment_account_id
|
81
|
+
write_fixture_to_file("tokenize_by_direct_post--#{card.card_number}", cert_response)
|
46
82
|
end
|
47
83
|
|
48
84
|
def record_auth_capture
|
@@ -54,11 +90,7 @@ module Vantiv
|
|
54
90
|
customer_id: "not-dynamic-cust-id",
|
55
91
|
order_id: "not-dynamic-order-id"
|
56
92
|
)
|
57
|
-
|
58
|
-
body: cert_response.body,
|
59
|
-
litle_txn_name: "saleResponse"
|
60
|
-
)
|
61
|
-
write_fixture_to_file("auth_capture--#{card.card_number}", cert_response, dynamic_body)
|
93
|
+
write_fixture_to_file("auth_capture--#{card.card_number}", cert_response)
|
62
94
|
end
|
63
95
|
|
64
96
|
def record_auth
|
@@ -70,11 +102,7 @@ module Vantiv
|
|
70
102
|
customer_id: "not-dynamic-cust-id",
|
71
103
|
order_id: "not-dynamic-order-id"
|
72
104
|
)
|
73
|
-
|
74
|
-
body: cert_response.body,
|
75
|
-
litle_txn_name: "authorizationResponse"
|
76
|
-
)
|
77
|
-
write_fixture_to_file("auth--#{card.card_number}", cert_response, dynamic_body)
|
105
|
+
write_fixture_to_file("auth--#{card.card_number}", cert_response)
|
78
106
|
end
|
79
107
|
|
80
108
|
def record_refund
|
@@ -86,33 +114,21 @@ module Vantiv
|
|
86
114
|
customer_id: "not-dynamic-cust-id",
|
87
115
|
order_id: "not-dynamic-order-id"
|
88
116
|
)
|
89
|
-
|
90
|
-
body: cert_response.body,
|
91
|
-
litle_txn_name: "creditResponse"
|
92
|
-
)
|
93
|
-
write_fixture_to_file("refund--#{card.card_number}", cert_response, dynamic_body)
|
117
|
+
write_fixture_to_file("refund--#{card.card_number}", cert_response)
|
94
118
|
end
|
95
119
|
|
96
120
|
def record_capture
|
97
121
|
cert_response = Vantiv.capture(
|
98
122
|
transaction_id: rand(10**17).to_s
|
99
123
|
)
|
100
|
-
|
101
|
-
body: cert_response.body,
|
102
|
-
litle_txn_name: "captureResponse"
|
103
|
-
)
|
104
|
-
write_fixture_to_file("capture", cert_response, dynamic_body)
|
124
|
+
write_fixture_to_file("capture", cert_response)
|
105
125
|
end
|
106
126
|
|
107
127
|
def record_auth_reversal
|
108
128
|
cert_response = Vantiv.auth_reversal(
|
109
129
|
transaction_id: rand(10**17).to_s
|
110
130
|
)
|
111
|
-
|
112
|
-
body: cert_response.body,
|
113
|
-
litle_txn_name: "authReversalResponse"
|
114
|
-
)
|
115
|
-
write_fixture_to_file("auth_reversal", cert_response, dynamic_body)
|
131
|
+
write_fixture_to_file("auth_reversal", cert_response)
|
116
132
|
end
|
117
133
|
|
118
134
|
def record_credit
|
@@ -120,31 +136,21 @@ module Vantiv
|
|
120
136
|
transaction_id: rand(10**17).to_s,
|
121
137
|
amount: 1010
|
122
138
|
)
|
123
|
-
|
124
|
-
body: cert_response.body,
|
125
|
-
litle_txn_name: "creditResponse"
|
126
|
-
)
|
127
|
-
write_fixture_to_file("credit", cert_response, dynamic_body)
|
139
|
+
write_fixture_to_file("credit", cert_response)
|
128
140
|
end
|
129
141
|
|
130
142
|
def record_void
|
131
143
|
cert_response = Vantiv.void(
|
132
144
|
transaction_id: rand(10**17).to_s
|
133
145
|
)
|
134
|
-
|
135
|
-
body: cert_response.body,
|
136
|
-
litle_txn_name: "voidResponse"
|
137
|
-
)
|
138
|
-
write_fixture_to_file("void", cert_response, dynamic_body)
|
146
|
+
write_fixture_to_file("void", cert_response)
|
139
147
|
end
|
140
148
|
|
141
|
-
def write_fixture_to_file(file_name, response
|
142
|
-
File.open("#{MockedSandbox.fixtures_directory}/#{file_name}.json
|
143
|
-
fixture << JSON.pretty_generate(
|
144
|
-
|
145
|
-
|
146
|
-
response_body: dynamic_body
|
147
|
-
})
|
149
|
+
def write_fixture_to_file(file_name, response)
|
150
|
+
File.open("#{MockedSandbox.fixtures_directory}/#{file_name}.json", 'w') do |fixture|
|
151
|
+
fixture << JSON.pretty_generate(
|
152
|
+
MockedResponseRepresenter.new(response).to_hash
|
153
|
+
)
|
148
154
|
end
|
149
155
|
end
|
150
156
|
end
|