agms 0.1.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 +15 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +51 -0
- data/Rakefile +40 -0
- data/agms.gemspec +29 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/example/hpp.rb +18 -0
- data/example/invoicing.rb +23 -0
- data/example/recurring.rb +23 -0
- data/example/report.rb +16 -0
- data/example/safe.rb +17 -0
- data/example/transaction.rb +17 -0
- data/init.yml +9 -0
- data/lib/agms.rb +59 -0
- data/lib/agms/agms.rb +109 -0
- data/lib/agms/configuration.rb +71 -0
- data/lib/agms/connect.rb +176 -0
- data/lib/agms/error/agms_error.rb +9 -0
- data/lib/agms/error/authentication_error.rb +7 -0
- data/lib/agms/error/authorization_error.rb +7 -0
- data/lib/agms/error/client_error_error.rb +7 -0
- data/lib/agms/error/configuation_error.rb +7 -0
- data/lib/agms/error/down_for_maintenance_error.rb +7 -0
- data/lib/agms/error/forged_query_String_error.rb +7 -0
- data/lib/agms/error/invalid_parameter_error.rb +7 -0
- data/lib/agms/error/invalid_request_error.rb +7 -0
- data/lib/agms/error/invalid_signature_error.rb +7 -0
- data/lib/agms/error/not_found_error.rb +7 -0
- data/lib/agms/error/request_validation_error.rb +7 -0
- data/lib/agms/error/response_error.rb +7 -0
- data/lib/agms/error/server_error_error.rb +7 -0
- data/lib/agms/error/ssl_certificate_error.rb +7 -0
- data/lib/agms/error/unexpected_error.rb +7 -0
- data/lib/agms/error/upgrade_required_error.rb +7 -0
- data/lib/agms/hpp.rb +65 -0
- data/lib/agms/invoicing.rb +63 -0
- data/lib/agms/recurring.rb +76 -0
- data/lib/agms/report.rb +53 -0
- data/lib/agms/request/hpp_request.rb +181 -0
- data/lib/agms/request/invoicing_request.rb +8 -0
- data/lib/agms/request/recurring_request.rb +115 -0
- data/lib/agms/request/report_request.rb +106 -0
- data/lib/agms/request/request.rb +455 -0
- data/lib/agms/request/safe_request.rb +211 -0
- data/lib/agms/request/transaction_request.rb +217 -0
- data/lib/agms/response/hpp_response.rb +39 -0
- data/lib/agms/response/invoicing_response.rb +10 -0
- data/lib/agms/response/recurring_response.rb +28 -0
- data/lib/agms/response/report_response.rb +141 -0
- data/lib/agms/response/response.rb +48 -0
- data/lib/agms/response/safe_response.rb +51 -0
- data/lib/agms/response/transaction_response.rb +50 -0
- data/lib/agms/safe.rb +66 -0
- data/lib/agms/transaction.rb +37 -0
- data/lib/agms/version.rb +3 -0
- metadata +156 -0
@@ -0,0 +1,211 @@
|
|
1
|
+
module Agms
|
2
|
+
class SAFERequest < Request
|
3
|
+
# A class representing AGMS SAFE Request objects.
|
4
|
+
|
5
|
+
alias AgmsAutoValidate autoValidate
|
6
|
+
|
7
|
+
def initialize(op)
|
8
|
+
super(op)
|
9
|
+
@fields = {
|
10
|
+
:TransactionType => {:setting => '', :value => ''},
|
11
|
+
:PaymentType => {:setting => '', :value => 'creditcard'},
|
12
|
+
:Amount => {:setting => '', :value => ''}, # Required for sale or auth
|
13
|
+
:TipAmount => {:setting => '', :value => ''}, # Required for Adjustment
|
14
|
+
:Tax => {:setting => '', :value => ''},
|
15
|
+
:Shipping => {:setting => '', :value => ''},
|
16
|
+
:OrderDescription => {:setting => '', :value => ''},
|
17
|
+
:OrderID => {:setting => '', :value => ''},
|
18
|
+
:PONumber => {:setting => '', :value => ''},
|
19
|
+
:CCNumber => {:setting => '', :value => ''}, # Required for sale and auth if payment type = creditcard without safe id
|
20
|
+
:CCExpDate => {:setting => '', :value => ''}, # Required for sale and auth if payment type = creditcard without safe id
|
21
|
+
:CVV => {:setting => '', :value => ''},
|
22
|
+
:CheckName => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
23
|
+
:CheckABA => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
24
|
+
:CheckAccount => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
25
|
+
:AccountHolderType => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
26
|
+
:AccountType => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
27
|
+
:SecCode => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
28
|
+
:FirstName => {:setting => '', :value => ''},
|
29
|
+
:LastName => {:setting => '', :value => ''},
|
30
|
+
:Company => {:setting => '', :value => ''},
|
31
|
+
:Address1 => {:setting => '', :value => ''},
|
32
|
+
:Address2 => {:setting => '', :value => ''},
|
33
|
+
:City => {:setting => '', :value => ''},
|
34
|
+
:State => {:setting => '', :value => ''},
|
35
|
+
:Zip => {:setting => '', :value => ''},
|
36
|
+
:Country => {:setting => '', :value => ''},
|
37
|
+
:Phone => {:setting => '', :value => ''},
|
38
|
+
:Fax => {:setting => '', :value => ''},
|
39
|
+
:EMail => {:setting => '', :value => ''},
|
40
|
+
:Website => {:setting => '', :value => ''},
|
41
|
+
:ShippingFirstName => {:setting => '', :value => ''},
|
42
|
+
:ShippingLastName => {:setting => '', :value => ''},
|
43
|
+
:ShippingCompany => {:setting => '', :value => ''},
|
44
|
+
:ShippingAddress1 => {:setting => '', :value => ''},
|
45
|
+
:ShippingAddress2 => {:setting => '', :value => ''},
|
46
|
+
:ShippingCity => {:setting => '', :value => ''},
|
47
|
+
:ShippingState => {:setting => '', :value => ''},
|
48
|
+
:ShippingZip => {:setting => '', :value => ''},
|
49
|
+
:ShippingCountry => {:setting => '', :value => ''},
|
50
|
+
:ShippingEmail => {:setting => '', :value => ''},
|
51
|
+
:ProcessorID => {:setting => '', :value => ''},
|
52
|
+
:TransactionID => {:setting => '', :value => ''},
|
53
|
+
:Tracking_Number => {:setting => '', :value => ''},
|
54
|
+
:Shipping_Carrier => {:setting => '', :value => ''},
|
55
|
+
:IPAddress => {:setting => '', :value => ''},
|
56
|
+
:Track1 => {:setting => '', :value => ''},
|
57
|
+
:Track2 => {:setting => '', :value => ''},
|
58
|
+
:Track3 => {:setting => '', :value => ''},
|
59
|
+
:Custom_Field_1 => {:setting => '', :value => ''},
|
60
|
+
:Custom_Field_2 => {:setting => '', :value => ''},
|
61
|
+
:Custom_Field_3 => {:setting => '', :value => ''},
|
62
|
+
:Custom_Field_4 => {:setting => '', :value => ''},
|
63
|
+
:Custom_Field_5 => {:setting => '', :value => ''},
|
64
|
+
:Custom_Field_6 => {:setting => '', :value => ''},
|
65
|
+
:Custom_Field_7 => {:setting => '', :value => ''},
|
66
|
+
:Custom_Field_8 => {:setting => '', :value => ''},
|
67
|
+
:Custom_Field_9 => {:setting => '', :value => ''},
|
68
|
+
:Custom_Field_10 => {:setting => '', :value => ''},
|
69
|
+
:SAFE_Action => {:setting => '', :value => ''},
|
70
|
+
:SAFE_ID => {:setting => '', :value => ''},
|
71
|
+
:ReceiptType => {:setting => '', :value => ''},
|
72
|
+
:MagData => {:setting => '', :value => ''},
|
73
|
+
:MagHardware => {:setting => '', :value => ''},
|
74
|
+
}
|
75
|
+
|
76
|
+
@numeric = %w(Amount Tax Shipping ProcessorID TransactionID CheckABA CheckAccount CCNumber CCExpDate)
|
77
|
+
|
78
|
+
@enums = {
|
79
|
+
:TransactionType => %w(sale auth safe\ only capture void refund update adjustment),
|
80
|
+
:SAFE_Action => %w(add_safe update_safe delete_safe),
|
81
|
+
:PaymentType => %w(creditcard check),
|
82
|
+
:SecCode => %w(PPD WEB TEL CCD),
|
83
|
+
:AccountHolderType => %w(business personal),
|
84
|
+
:AccountType => %w(checking savings),
|
85
|
+
:MagHardware => %w(MAGTEK IDTECH),
|
86
|
+
:Shipping_Carrier => %w(ups fedex dhl usps UPS Fedex DHL USPS),
|
87
|
+
}
|
88
|
+
|
89
|
+
@date = %w(StartDate EndDate)
|
90
|
+
|
91
|
+
@digit_2 = %w(State ShippingState)
|
92
|
+
|
93
|
+
@amount = %w(Amount TipAmount Tax Shipping)
|
94
|
+
|
95
|
+
# Override mapping with api-specific field maps
|
96
|
+
@mapping[:shipping_tracking_number] = :Tracking_Number
|
97
|
+
@mapping[:shipping_carrier] = :Shipping_Carrier
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
def validate
|
102
|
+
@required = Array.new
|
103
|
+
|
104
|
+
# If no transaction type, require a Safe Action
|
105
|
+
if @fields[:TransactionType][:value] == ''
|
106
|
+
@required.push(:SAFE_Action)
|
107
|
+
end
|
108
|
+
|
109
|
+
# All sales and auths require an amount
|
110
|
+
if ( @fields[:TransactionType][:value] == 'sale' or
|
111
|
+
@fields[:TransactionType][:value] == 'auth' )
|
112
|
+
@required.push(:Amount)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Captures, refunds, voids, updates, adjustments need a Transaction ID
|
116
|
+
if ( @fields[:TransactionType][:value] == 'capture' or
|
117
|
+
@fields[:TransactionType][:value] == 'refund' or
|
118
|
+
@fields[:TransactionType][:value] == 'void' or
|
119
|
+
@fields[:TransactionType][:value] == 'adjustment' )
|
120
|
+
@required.push(:TransactionID)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Require TipAmount for Tip Adjustment transactions
|
124
|
+
if @fields[:TransactionType][:value] == 'adjustment'
|
125
|
+
@required.push(:TipAmount)
|
126
|
+
end
|
127
|
+
|
128
|
+
# All safe updates and deletes require a safe id
|
129
|
+
if ( @fields[:SAFE_Action][:value] == 'update' or
|
130
|
+
@fields[:SAFE_Action][:value] == 'delete' )
|
131
|
+
@required.push(:SAFE_ID)
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
if @fields[:PaymentType][:value] == 'check'
|
136
|
+
# Cheque transaction
|
137
|
+
if @fields[:SAFE_ID][:value] == ''
|
138
|
+
# If no Safe ID we need all the check info
|
139
|
+
@required.push(:CheckName)
|
140
|
+
@required.push(:CheckABA)
|
141
|
+
@required.push(:CheckAccount)
|
142
|
+
if ( @fields[:TransactionType][:value] == 'sale' or
|
143
|
+
@fields[:TransactionType][:value] == 'auth' )
|
144
|
+
@required.push(:SecCode)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
else
|
148
|
+
# Credit card transaction
|
149
|
+
# If no SAFE ID and its a sale or auth
|
150
|
+
if ( @fields[:SAFE_ID][:value] == '' and
|
151
|
+
( @fields[:TransactionType][:value] == 'sale' or
|
152
|
+
@fields[:TransactionType][:value] == 'auth' ) )
|
153
|
+
# If no Safe ID we need the card info
|
154
|
+
# If no MagData then we need keyed info
|
155
|
+
if @fields[:MagData][:value] == ''
|
156
|
+
@required.push(:CCNumber)
|
157
|
+
@required.push(:CCExpDate)
|
158
|
+
else
|
159
|
+
@required.push(:MagHardware)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
error_array = AgmsAutoValidate();
|
165
|
+
|
166
|
+
errors = error_array['errors'];
|
167
|
+
messages = error_array['messages'];
|
168
|
+
|
169
|
+
# ExpDate MMYY
|
170
|
+
if ( @fields[:CCExpDate][:value] != '' and
|
171
|
+
( @fields[:CCExpDate][:value].length != 4 or
|
172
|
+
not /(0[1-9]|1[0-2])([0-9][0-9])/.match(@fields[:CCExpDate][:value]) ) )
|
173
|
+
errors += 1
|
174
|
+
messages.push('CCExpDate (credit card expiration date) must be MMYY.')
|
175
|
+
end
|
176
|
+
|
177
|
+
# CCNumber length
|
178
|
+
if ( @fields[:CCNumber][:value] != '' and
|
179
|
+
@fields[:CCNumber][:value].length != 16 and
|
180
|
+
@fields[:CCNumber][:value].length != 15 )
|
181
|
+
errors += 1
|
182
|
+
messages.push('CCNumber (credit card number) must be 15-16 digits long.')
|
183
|
+
end
|
184
|
+
|
185
|
+
# ABA length
|
186
|
+
if ( @fields[:CheckABA][:value] != '' and
|
187
|
+
@fields[:CheckABA][:value].length != 9)
|
188
|
+
errors += 1
|
189
|
+
messages.push('CheckABA (routing number) must be 9 digits long.')
|
190
|
+
end
|
191
|
+
|
192
|
+
@validate_errors = errors;
|
193
|
+
@validate_messages = messages;
|
194
|
+
|
195
|
+
if errors == 0
|
196
|
+
return {'errors' => errors, 'messages' => messages}
|
197
|
+
else
|
198
|
+
raise RequestValidationError, "Request validation failed with #{messages.join(' ')}."
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
def getFields
|
204
|
+
return getFieldArray
|
205
|
+
end
|
206
|
+
|
207
|
+
def getParams(request)
|
208
|
+
return {:vParameter => request}
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
module Agms
|
2
|
+
class TransactionRequest < Request
|
3
|
+
# A class representing AGMS Transaction Request objects.
|
4
|
+
|
5
|
+
alias AgmsAutoValidate autoValidate
|
6
|
+
|
7
|
+
def initialize(op)
|
8
|
+
super(op)
|
9
|
+
@fields = {
|
10
|
+
:TransactionType => {:setting => '', :value => ''},
|
11
|
+
:PaymentType => {:setting => '', :value => 'creditcard'},
|
12
|
+
:Amount => {:setting => '', :value => ''}, # Required for sale or auth
|
13
|
+
:TipAmount => {:setting => '', :value => ''}, # Required for Adjustment
|
14
|
+
:Tax => {:setting => '', :value => ''},
|
15
|
+
:Shipping => {:setting => '', :value => ''},
|
16
|
+
:OrderDescription => {:setting => '', :value => ''},
|
17
|
+
:OrderID => {:setting => '', :value => ''},
|
18
|
+
:ClerkID => {:setting => '', :value => ''},
|
19
|
+
:PONumber => {:setting => '', :value => ''},
|
20
|
+
:CCNumber => {:setting => '', :value => ''}, # Required for sale and auth if payment type = creditcard without safe id
|
21
|
+
:CCExpDate => {:setting => '', :value => ''}, # Required for sale and auth if payment type = creditcard without safe id
|
22
|
+
:CVV => {:setting => '', :value => ''},
|
23
|
+
:CheckName => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
24
|
+
:CheckABA => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
25
|
+
:CheckAccount => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
26
|
+
:AccountHolderType => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
27
|
+
:AccountType => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
28
|
+
:SecCode => {:setting => '', :value => ''}, # Required for sale and auth if payment type = check without safe id
|
29
|
+
:FirstName => {:setting => '', :value => ''},
|
30
|
+
:LastName => {:setting => '', :value => ''},
|
31
|
+
:Company => {:setting => '', :value => ''},
|
32
|
+
:Address1 => {:setting => '', :value => ''},
|
33
|
+
:Address2 => {:setting => '', :value => ''},
|
34
|
+
:City => {:setting => '', :value => ''},
|
35
|
+
:State => {:setting => '', :value => ''},
|
36
|
+
:Zip => {:setting => '', :value => ''},
|
37
|
+
:Country => {:setting => '', :value => ''},
|
38
|
+
:Phone => {:setting => '', :value => ''},
|
39
|
+
:Fax => {:setting => '', :value => ''},
|
40
|
+
:EMail => {:setting => '', :value => ''},
|
41
|
+
:Website => {:setting => '', :value => ''},
|
42
|
+
:ShippingFirstName => {:setting => '', :value => ''},
|
43
|
+
:ShippingLastName => {:setting => '', :value => ''},
|
44
|
+
:ShippingCompany => {:setting => '', :value => ''},
|
45
|
+
:ShippingAddress1 => {:setting => '', :value => ''},
|
46
|
+
:ShippingAddress2 => {:setting => '', :value => ''},
|
47
|
+
:ShippingCity => {:setting => '', :value => ''},
|
48
|
+
:ShippingState => {:setting => '', :value => ''},
|
49
|
+
:ShippingZip => {:setting => '', :value => ''},
|
50
|
+
:ShippingCountry => {:setting => '', :value => ''},
|
51
|
+
:ShippingEmail => {:setting => '', :value => ''},
|
52
|
+
:ShippingPhone => {:setting => '', :value => ''},
|
53
|
+
:ShippingFax => {:setting => '', :value => ''},
|
54
|
+
:ProcessorID => {:setting => '', :value => ''},
|
55
|
+
:TransactionID => {:setting => '', :value => ''},
|
56
|
+
:Tracking_Number => {:setting => '', :value => ''},
|
57
|
+
:Shipping_Carrier => {:setting => '', :value => ''},
|
58
|
+
:IPAddress => {:setting => '', :value => ''},
|
59
|
+
:Track1 => {:setting => '', :value => ''},
|
60
|
+
:Track2 => {:setting => '', :value => ''},
|
61
|
+
:Track3 => {:setting => '', :value => ''},
|
62
|
+
:Custom_Field_1 => {:setting => '', :value => ''},
|
63
|
+
:Custom_Field_2 => {:setting => '', :value => ''},
|
64
|
+
:Custom_Field_3 => {:setting => '', :value => ''},
|
65
|
+
:Custom_Field_4 => {:setting => '', :value => ''},
|
66
|
+
:Custom_Field_5 => {:setting => '', :value => ''},
|
67
|
+
:Custom_Field_6 => {:setting => '', :value => ''},
|
68
|
+
:Custom_Field_7 => {:setting => '', :value => ''},
|
69
|
+
:Custom_Field_8 => {:setting => '', :value => ''},
|
70
|
+
:Custom_Field_9 => {:setting => '', :value => ''},
|
71
|
+
:Custom_Field_10 => {:setting => '', :value => ''},
|
72
|
+
:SAFE_Action => {:setting => '', :value => ''},
|
73
|
+
:SAFE_ID => {:setting => '', :value => ''},
|
74
|
+
:ReceiptType => {:setting => '', :value => ''},
|
75
|
+
:MagData => {:setting => '', :value => ''},
|
76
|
+
:MagHardware => {:setting => '', :value => ''},
|
77
|
+
}
|
78
|
+
|
79
|
+
@numeric = %w(Amount Tax Shipping ProcessorID TransactionID CheckABA CheckAccount CCNumber CCExpDate)
|
80
|
+
|
81
|
+
@enums = {
|
82
|
+
:TransactionType => %w(sale auth safe\ only capture void refund update adjustment),
|
83
|
+
:SAFE_Action => %w(add_safe update_safe delete_safe),
|
84
|
+
:PaymentType => %w(creditcard check),
|
85
|
+
:SecCode => %w(PPD WEB TEL CCD),
|
86
|
+
:AccountHolderType => %w(business personal),
|
87
|
+
:AccountType => %w(checking savings),
|
88
|
+
:MagHardware => %w(MAGTEK IDTECH),
|
89
|
+
:Shipping_Carrier => %w(ups fedex dhl usps UPS Fedex DHL USPS),
|
90
|
+
}
|
91
|
+
|
92
|
+
@digit_2 = %w(State ShippingState)
|
93
|
+
|
94
|
+
@amount = %w(Amount TipAmount Tax Shipping)
|
95
|
+
|
96
|
+
# Override mapping with api-specific field maps
|
97
|
+
@mapping[:shipping_tracking_number] = :Tracking_Number
|
98
|
+
@mapping[:shipping_carrier] = :Shipping_Carrier
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
def validate
|
103
|
+
@required = Array.new
|
104
|
+
|
105
|
+
# Unless this is a safe action only request, require a transaction type
|
106
|
+
if @fields[:SAFE_Action][:value] == ''
|
107
|
+
@required.push(:TransactionType)
|
108
|
+
end
|
109
|
+
|
110
|
+
# If no transaction type, require a Safe Action
|
111
|
+
if @fields[:TransactionType][:value] == ''
|
112
|
+
@required.push(:SAFE_Action)
|
113
|
+
end
|
114
|
+
|
115
|
+
# All sales and auths require an amount
|
116
|
+
if ( @fields[:TransactionType][:value] == 'sale' or
|
117
|
+
@fields[:TransactionType][:value] == 'auth' )
|
118
|
+
@required.push(:Amount)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Captures, refunds, voids, updates, adjustments need a Transaction ID
|
122
|
+
if ( @fields[:TransactionType][:value] == 'capture' or
|
123
|
+
@fields[:TransactionType][:value] == 'refund' or
|
124
|
+
@fields[:TransactionType][:value] == 'void' or
|
125
|
+
@fields[:TransactionType][:value] == 'adjustment' )
|
126
|
+
@required.push(:TransactionID)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Require TipAmount for Tip Adjustment transactions
|
130
|
+
if @fields[:TransactionType][:value] == 'adjustment'
|
131
|
+
@required.push(:TipAmount)
|
132
|
+
end
|
133
|
+
|
134
|
+
# All safe updates and deletes require a safe id
|
135
|
+
if ( @fields[:SAFE_Action][:value] == 'update' or
|
136
|
+
@fields[:SAFE_Action][:value] == 'delete' )
|
137
|
+
@required.push(:SAFE_ID)
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
if @fields[:PaymentType][:value] == 'check'
|
142
|
+
# Cheque transaction
|
143
|
+
if @fields[:SAFE_ID][:value] == ''
|
144
|
+
# If no Safe ID we need all the check info
|
145
|
+
@required.push(:CheckName)
|
146
|
+
@required.push(:CheckABA)
|
147
|
+
@required.push(:CheckAccount)
|
148
|
+
if ( @fields[:TransactionType][:value] == 'sale' or
|
149
|
+
@fields[:TransactionType][:value] == 'auth' )
|
150
|
+
@required.push(:SecCode)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
else
|
154
|
+
# Credit card transaction
|
155
|
+
# If no SAFE ID and its a sale or auth
|
156
|
+
if ( @fields[:SAFE_ID][:value] == '' and
|
157
|
+
( @fields[:TransactionType][:value] == 'sale' or
|
158
|
+
@fields[:TransactionType][:value] == 'auth' ) )
|
159
|
+
# If no Safe ID we need the card info
|
160
|
+
# If no MagData then we need keyed info
|
161
|
+
if @fields[:MagData][:value] == ''
|
162
|
+
@required.push(:CCNumber)
|
163
|
+
@required.push(:CCExpDate)
|
164
|
+
else
|
165
|
+
@required.push(:MagHardware)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
error_array = AgmsAutoValidate();
|
171
|
+
errors = error_array['errors'];
|
172
|
+
messages = error_array['messages'];
|
173
|
+
|
174
|
+
# ExpDate MMYY
|
175
|
+
if ( @fields[:CCExpDate][:value] != '' and
|
176
|
+
( @fields[:CCExpDate][:value].length != 4 or
|
177
|
+
not /(0[1-9]|1[0-2])([0-9][0-9])/.match(@fields[:CCExpDate][:value]) ) )
|
178
|
+
errors += 1
|
179
|
+
messages.push('CCExpDate (credit card expiration date) must be MMYY.')
|
180
|
+
end
|
181
|
+
|
182
|
+
# CCNumber length
|
183
|
+
if ( @fields[:CCNumber][:value] != '' and
|
184
|
+
@fields[:CCNumber][:value].length != 16 and
|
185
|
+
@fields[:CCNumber][:value].length != 15 )
|
186
|
+
errors += 1
|
187
|
+
messages.push('CCNumber (credit card number) must be 15-16 digits long.')
|
188
|
+
end
|
189
|
+
|
190
|
+
# ABA length
|
191
|
+
if ( @fields[:CheckABA][:value] != '' and
|
192
|
+
@fields[:CheckABA][:value].length != 9)
|
193
|
+
errors += 1
|
194
|
+
messages.push('CheckABA (routing number) must be 9 digits long.')
|
195
|
+
end
|
196
|
+
|
197
|
+
@validate_errors = errors;
|
198
|
+
@validate_messages = messages;
|
199
|
+
|
200
|
+
if errors == 0
|
201
|
+
return {'errors' => errors, 'messages' => messages}
|
202
|
+
else
|
203
|
+
print "Request validation failed with #{messages.join(' ')}"
|
204
|
+
raise RequestValidationError, "Request validation failed with #{messages.join(' ')}."
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
def getFields
|
210
|
+
return getFieldArray
|
211
|
+
end
|
212
|
+
|
213
|
+
def getParams(request)
|
214
|
+
return {:objparameters => request}
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Agms
|
2
|
+
class HPPResponse < Response
|
3
|
+
# A class representing AGMS HPP Response objects.
|
4
|
+
|
5
|
+
def initialize(response, op)
|
6
|
+
super(response, op)
|
7
|
+
@op = op
|
8
|
+
@mapping = {'0' => 'hash', }
|
9
|
+
@response = Hash.new
|
10
|
+
@response['0'] = response
|
11
|
+
@hash = response
|
12
|
+
|
13
|
+
if not isSuccessful()
|
14
|
+
raise ResponseError, 'HPP Generation failed with message ' + @hash
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def getHash
|
19
|
+
return @hash
|
20
|
+
end
|
21
|
+
|
22
|
+
def isSuccessful
|
23
|
+
@hash = getHash()
|
24
|
+
if ( not @hash or
|
25
|
+
@hash == 0 or
|
26
|
+
@hash.include? 'INVALID' or
|
27
|
+
@hash.include? 'ERROR' or
|
28
|
+
@hash.include? 'EXCEPTION' or
|
29
|
+
@hash.include? 'REQUIRED' or
|
30
|
+
@hash.include? 'IF USED' or
|
31
|
+
@hash.include? 'MUST BE' or
|
32
|
+
@hash.include? 'FAILED')
|
33
|
+
return false
|
34
|
+
else
|
35
|
+
return true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|