hps 2.3.2 → 2.4.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/Gemfile +4 -4
- data/Gemfile.lock +59 -0
- data/LICENSE.md +264 -264
- data/PRIVACY.txt +65 -65
- data/README.md +213 -213
- data/Rakefile +15 -15
- data/examples/sinatra-verify-only/Gemfile +4 -4
- data/examples/sinatra-verify-only/app.rb +32 -32
- data/examples/sinatra-verify-only/views/index.erb +478 -478
- data/examples/sinatra-verify-only/views/result.erb +39 -39
- data/hps.gemspec +28 -27
- data/lib/hps/configuration.rb +17 -17
- data/lib/hps/entities/hps_account_verify.rb +8 -8
- data/lib/hps/entities/hps_address.rb +6 -6
- data/lib/hps/entities/hps_authorization.rb +12 -12
- data/lib/hps/entities/hps_batch.rb +6 -6
- data/lib/hps/entities/hps_cardholder.rb +6 -6
- data/lib/hps/entities/hps_charge.rb +8 -8
- data/lib/hps/entities/hps_charge_exceptions.rb +6 -6
- data/lib/hps/entities/hps_check.rb +18 -18
- data/lib/hps/entities/hps_check_holder.rb +10 -10
- data/lib/hps/entities/hps_check_response.rb +45 -45
- data/lib/hps/entities/hps_check_response_details.rb +9 -9
- data/lib/hps/entities/hps_credit_card.rb +34 -34
- data/lib/hps/entities/hps_direct_market_data.rb +5 -5
- data/lib/hps/entities/hps_encryption_data.rb +6 -6
- data/lib/hps/entities/hps_gift_card.rb +133 -133
- data/lib/hps/entities/hps_manage_tokens.rb +8 -8
- data/lib/hps/entities/hps_refund.rb +8 -8
- data/lib/hps/entities/hps_report_transaction_details.rb +10 -10
- data/lib/hps/entities/hps_report_transaction_summary.rb +6 -6
- data/lib/hps/entities/hps_reversal.rb +10 -10
- data/lib/hps/entities/hps_token_data.rb +10 -10
- data/lib/hps/entities/hps_track_data.rb +5 -5
- data/lib/hps/entities/hps_transaction.rb +161 -161
- data/lib/hps/entities/hps_transaction_details.rb +6 -6
- data/lib/hps/entities/hps_transaction_header.rb +8 -8
- data/lib/hps/entities/hps_transaction_type.rb +16 -16
- data/lib/hps/entities/hps_void.rb +8 -8
- data/lib/hps/infrastructure/api_connection_exception.rb +11 -11
- data/lib/hps/infrastructure/authentication_exception.rb +11 -11
- data/lib/hps/infrastructure/card_exception.rb +15 -15
- data/lib/hps/infrastructure/exceptions.json +547 -547
- data/lib/hps/infrastructure/hps_account_type.rb +11 -11
- data/lib/hps/infrastructure/hps_check_exception.rb +13 -13
- data/lib/hps/infrastructure/hps_check_type.rb +11 -11
- data/lib/hps/infrastructure/hps_data_entry_mode.rb +11 -11
- data/lib/hps/infrastructure/hps_exception.rb +25 -25
- data/lib/hps/infrastructure/hps_exception_mapper.rb +145 -145
- data/lib/hps/infrastructure/hps_gateway_response_validation.rb +20 -20
- data/lib/hps/infrastructure/hps_input_validation.rb +13 -13
- data/lib/hps/infrastructure/hps_sdk_codes.rb +48 -48
- data/lib/hps/infrastructure/hps_sec_code.rb +27 -27
- data/lib/hps/infrastructure/hps_track_data_method.rb +6 -6
- data/lib/hps/infrastructure/invalid_request_exception.rb +15 -15
- data/lib/hps/services/hps_batch_service.rb +29 -29
- data/lib/hps/services/hps_charge_service.rb +773 -773
- data/lib/hps/services/hps_check_service.rb +110 -110
- data/lib/hps/services/hps_gift_card_service.rb +301 -301
- data/lib/hps/services/hps_service.rb +141 -136
- data/lib/hps/version.rb +3 -3
- data/lib/hps.rb +63 -63
- data/tests/amex_tests.rb +292 -292
- data/tests/cert_tests.rb +80 -80
- data/tests/certification/card_present_spec.rb +320 -320
- data/tests/certification/gift_card_certification_test.rb +106 -106
- data/tests/certification/gift_card_certification_tests.rb +107 -107
- data/tests/check_tests.rb +50 -50
- data/tests/discover_tests.rb +386 -386
- data/tests/exception_mapper_tests.rb +311 -311
- data/tests/general_tests.rb +140 -140
- data/tests/giftcard_tests.rb +212 -212
- data/tests/hps_token_service.rb +56 -56
- data/tests/mastercard_tests.rb +387 -387
- data/tests/secret_key.rb +11 -11
- data/tests/test_check.rb +77 -77
- data/tests/test_data.rb +138 -138
- data/tests/test_helper.rb +179 -179
- data/tests/token_tests.rb +512 -512
- data/tests/visa_tests.rb +445 -445
- metadata +31 -11
@@ -1,110 +1,110 @@
|
|
1
|
-
module Hps
|
2
|
-
class HpsCheckService < HpsService
|
3
|
-
def sale(check, amount, client_txn_id = nil)
|
4
|
-
build_transaction('SALE', check, amount, client_txn_id)
|
5
|
-
end
|
6
|
-
|
7
|
-
def void(transaction_id = nil, client_txn_id = nil)
|
8
|
-
if (transaction_id == nil && client_txn_id == nil) ||
|
9
|
-
(transaction_id != nil && client_txn_id != nil)
|
10
|
-
raise Error, 'Please provide either a transaction ID or a client transaction ID'
|
11
|
-
end
|
12
|
-
|
13
|
-
xml = Builder::XmlMarkup.new
|
14
|
-
xml.hps :Transaction do
|
15
|
-
xml.hps :CheckVoid do
|
16
|
-
xml.hps :Block1 do
|
17
|
-
xml.hps :GatewayTxnId, transaction_id if transaction_id
|
18
|
-
xml.hps :ClientTxnId, client_txn_id if client_txn_id
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
submit_transaction(xml.target!, :CheckVoid)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def build_transaction(action, check, amount, client_txn_id)
|
29
|
-
amount = HpsInputValidation::check_amount(amount)
|
30
|
-
|
31
|
-
if check.sec_code == HpsSECCode.ccd &&
|
32
|
-
(check.check_holder == nil || check.check_holder.check_name == nil)
|
33
|
-
raise Error, 'For SEC code CCD, the check name is require', 'check_name'
|
34
|
-
end
|
35
|
-
|
36
|
-
xml = Builder::XmlMarkup.new
|
37
|
-
xml.hps :Transaction do
|
38
|
-
xml.hps :CheckSale do
|
39
|
-
xml.hps :Block1 do
|
40
|
-
xml.hps :Amt, amount
|
41
|
-
xml << hydrate_check_data(check)
|
42
|
-
xml.hps :CheckAction, action
|
43
|
-
xml.hps :SECCode, check.sec_code
|
44
|
-
xml.hps :CheckType, check.check_type if check.check_type
|
45
|
-
xml << hydrate_consumer_info(check.check_holder) if check.check_holder
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
submit_transaction(xml.target!, :CheckSale, client_txn_id)
|
51
|
-
end
|
52
|
-
|
53
|
-
def hydrate_check_data(check)
|
54
|
-
xml = Builder::XmlMarkup.new
|
55
|
-
xml.hps :AccountInfo do
|
56
|
-
xml.hps :AccountNumber, check.account_number if check.account_number
|
57
|
-
xml.hps :CheckNumber, check.check_number if check.check_number
|
58
|
-
xml.hps :MICRData, check.micr_number if check.micr_number
|
59
|
-
xml.hps :RoutingNumber, check.routing_number if check.routing_number
|
60
|
-
xml.hps :AccountType, check.account_type if check.account_type
|
61
|
-
end
|
62
|
-
xml.target!
|
63
|
-
end
|
64
|
-
|
65
|
-
def hydrate_consumer_info(check_holder)
|
66
|
-
xml = Builder::XmlMarkup.new
|
67
|
-
xml.hps :ConsumerInfo do
|
68
|
-
if check_holder.address
|
69
|
-
xml.hps :Address1, check_holder.address.address if check_holder.address.address
|
70
|
-
xml.hps :City, check_holder.address.city if check_holder.address.city
|
71
|
-
xml.hps :State, check_holder.address.state if check_holder.address.state
|
72
|
-
xml.hps :Zip, check_holder.address.zip if check_holder.address.zip
|
73
|
-
end
|
74
|
-
|
75
|
-
xml.hps :CheckName, check_holder.check_name if check_holder.check_name
|
76
|
-
xml.hps :CourtesyCard, check_holder.courtesy_card if check_holder.courtesy_card
|
77
|
-
xml.hps :DLNumber, check_holder.dl_number if check_holder.dl_number
|
78
|
-
xml.hps :DLState, check_holder.dl_state if check_holder.dl_state
|
79
|
-
xml.hps :EmailAddress, check_holder.email if check_holder.email_address
|
80
|
-
xml.hps :FirstName, check_holder.first_name if check_holder.first_name
|
81
|
-
xml.hps :LastName, check_holder.last_name if check_holder.last_name
|
82
|
-
xml.hps :PhoneNumber, check_holder.phone if check_holder.phone
|
83
|
-
|
84
|
-
if check_holder.ssl4 || check_holder.dob_year
|
85
|
-
xml.hps :IdentityInfo do
|
86
|
-
xml.hps :SSNL4, check_holder.ssl4 if check_holder.ssl4
|
87
|
-
xml.hps :DOBYear, check_holder.dob_year if check_holder.dob_year
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
xml.target!
|
93
|
-
end
|
94
|
-
|
95
|
-
def submit_transaction(xml, txn_type, client_txn_id = nil)
|
96
|
-
response = doTransaction(xml, client_txn_id)
|
97
|
-
HpsGatewayResponseValidation::check_response(response, txn_type)
|
98
|
-
response = HpsCheckResponse::from_hash(response, txn_type)
|
99
|
-
|
100
|
-
return response if response.response_code == '0'
|
101
|
-
|
102
|
-
raise HpsCheckException.new(
|
103
|
-
response.transaction_id,
|
104
|
-
response.details,
|
105
|
-
response.response_code,
|
106
|
-
response.response_text
|
107
|
-
)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
1
|
+
module Hps
|
2
|
+
class HpsCheckService < HpsService
|
3
|
+
def sale(check, amount, client_txn_id = nil)
|
4
|
+
build_transaction('SALE', check, amount, client_txn_id)
|
5
|
+
end
|
6
|
+
|
7
|
+
def void(transaction_id = nil, client_txn_id = nil)
|
8
|
+
if (transaction_id == nil && client_txn_id == nil) ||
|
9
|
+
(transaction_id != nil && client_txn_id != nil)
|
10
|
+
raise Error, 'Please provide either a transaction ID or a client transaction ID'
|
11
|
+
end
|
12
|
+
|
13
|
+
xml = Builder::XmlMarkup.new
|
14
|
+
xml.hps :Transaction do
|
15
|
+
xml.hps :CheckVoid do
|
16
|
+
xml.hps :Block1 do
|
17
|
+
xml.hps :GatewayTxnId, transaction_id if transaction_id
|
18
|
+
xml.hps :ClientTxnId, client_txn_id if client_txn_id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
submit_transaction(xml.target!, :CheckVoid)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def build_transaction(action, check, amount, client_txn_id)
|
29
|
+
amount = HpsInputValidation::check_amount(amount)
|
30
|
+
|
31
|
+
if check.sec_code == HpsSECCode.ccd &&
|
32
|
+
(check.check_holder == nil || check.check_holder.check_name == nil)
|
33
|
+
raise Error, 'For SEC code CCD, the check name is require', 'check_name'
|
34
|
+
end
|
35
|
+
|
36
|
+
xml = Builder::XmlMarkup.new
|
37
|
+
xml.hps :Transaction do
|
38
|
+
xml.hps :CheckSale do
|
39
|
+
xml.hps :Block1 do
|
40
|
+
xml.hps :Amt, amount
|
41
|
+
xml << hydrate_check_data(check)
|
42
|
+
xml.hps :CheckAction, action
|
43
|
+
xml.hps :SECCode, check.sec_code
|
44
|
+
xml.hps :CheckType, check.check_type if check.check_type
|
45
|
+
xml << hydrate_consumer_info(check.check_holder) if check.check_holder
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
submit_transaction(xml.target!, :CheckSale, client_txn_id)
|
51
|
+
end
|
52
|
+
|
53
|
+
def hydrate_check_data(check)
|
54
|
+
xml = Builder::XmlMarkup.new
|
55
|
+
xml.hps :AccountInfo do
|
56
|
+
xml.hps :AccountNumber, check.account_number if check.account_number
|
57
|
+
xml.hps :CheckNumber, check.check_number if check.check_number
|
58
|
+
xml.hps :MICRData, check.micr_number if check.micr_number
|
59
|
+
xml.hps :RoutingNumber, check.routing_number if check.routing_number
|
60
|
+
xml.hps :AccountType, check.account_type if check.account_type
|
61
|
+
end
|
62
|
+
xml.target!
|
63
|
+
end
|
64
|
+
|
65
|
+
def hydrate_consumer_info(check_holder)
|
66
|
+
xml = Builder::XmlMarkup.new
|
67
|
+
xml.hps :ConsumerInfo do
|
68
|
+
if check_holder.address
|
69
|
+
xml.hps :Address1, check_holder.address.address if check_holder.address.address
|
70
|
+
xml.hps :City, check_holder.address.city if check_holder.address.city
|
71
|
+
xml.hps :State, check_holder.address.state if check_holder.address.state
|
72
|
+
xml.hps :Zip, check_holder.address.zip if check_holder.address.zip
|
73
|
+
end
|
74
|
+
|
75
|
+
xml.hps :CheckName, check_holder.check_name if check_holder.check_name
|
76
|
+
xml.hps :CourtesyCard, check_holder.courtesy_card if check_holder.courtesy_card
|
77
|
+
xml.hps :DLNumber, check_holder.dl_number if check_holder.dl_number
|
78
|
+
xml.hps :DLState, check_holder.dl_state if check_holder.dl_state
|
79
|
+
xml.hps :EmailAddress, check_holder.email if check_holder.email_address
|
80
|
+
xml.hps :FirstName, check_holder.first_name if check_holder.first_name
|
81
|
+
xml.hps :LastName, check_holder.last_name if check_holder.last_name
|
82
|
+
xml.hps :PhoneNumber, check_holder.phone if check_holder.phone
|
83
|
+
|
84
|
+
if check_holder.ssl4 || check_holder.dob_year
|
85
|
+
xml.hps :IdentityInfo do
|
86
|
+
xml.hps :SSNL4, check_holder.ssl4 if check_holder.ssl4
|
87
|
+
xml.hps :DOBYear, check_holder.dob_year if check_holder.dob_year
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
xml.target!
|
93
|
+
end
|
94
|
+
|
95
|
+
def submit_transaction(xml, txn_type, client_txn_id = nil)
|
96
|
+
response = doTransaction(xml, client_txn_id)
|
97
|
+
HpsGatewayResponseValidation::check_response(response, txn_type)
|
98
|
+
response = HpsCheckResponse::from_hash(response, txn_type)
|
99
|
+
|
100
|
+
return response if response.response_code == '0'
|
101
|
+
|
102
|
+
raise HpsCheckException.new(
|
103
|
+
response.transaction_id,
|
104
|
+
response.details,
|
105
|
+
response.response_code,
|
106
|
+
response.response_text
|
107
|
+
)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|