activemerchant 1.42.9 → 1.43.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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG +14 -1
- data/CONTRIBUTORS +4 -0
- data/README.md +2 -1
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +14 -9
- data/lib/active_merchant/billing/gateways/iats_payments.rb +199 -16
- data/lib/active_merchant/billing/gateways/network_merchants.rb +239 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +5 -1
- data/lib/active_merchant/billing/gateways/sage_pay.rb +1 -1
- data/lib/active_merchant/billing/gateways/transnational.rb +1 -231
- data/lib/active_merchant/billing/integrations/pag_seguro.rb +53 -0
- data/lib/active_merchant/billing/integrations/pag_seguro/helper.rb +121 -0
- data/lib/active_merchant/billing/integrations/pag_seguro/notification.rb +104 -0
- data/lib/active_merchant/billing/integrations/pxpay/helper.rb +5 -4
- data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +1 -1
- data/lib/active_merchant/version.rb +1 -1
- metadata +7 -2
- metadata.gz.sig +0 -0
@@ -0,0 +1,239 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class NetworkMerchantsGateway < Gateway
|
4
|
+
self.live_url = self.test_url = 'https://secure.networkmerchants.com/api/transact.php'
|
5
|
+
|
6
|
+
self.supported_countries = ['US']
|
7
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
8
|
+
|
9
|
+
self.homepage_url = 'http://www.nmi.com/'
|
10
|
+
self.display_name = 'Network Merchants (NMI)'
|
11
|
+
|
12
|
+
self.money_format = :dollars
|
13
|
+
self.default_currency = 'USD'
|
14
|
+
|
15
|
+
def initialize(options = {})
|
16
|
+
requires!(options, :login, :password)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def authorize(money, creditcard_or_vault_id, options = {})
|
21
|
+
post = build_auth_post(money, creditcard_or_vault_id, options)
|
22
|
+
commit('auth', post)
|
23
|
+
end
|
24
|
+
|
25
|
+
def purchase(money, creditcard_or_vault_id, options = {})
|
26
|
+
post = build_purchase_post(money, creditcard_or_vault_id, options)
|
27
|
+
commit('sale', post)
|
28
|
+
end
|
29
|
+
|
30
|
+
def capture(money, authorization, options = {})
|
31
|
+
post = build_capture_post(money, authorization, options)
|
32
|
+
commit('capture', post)
|
33
|
+
end
|
34
|
+
|
35
|
+
def void(authorization, options = {})
|
36
|
+
post = build_void_post(authorization, options)
|
37
|
+
commit('void', post)
|
38
|
+
end
|
39
|
+
|
40
|
+
def refund(money, authorization, options = {})
|
41
|
+
post = build_refund_post(money, authorization, options)
|
42
|
+
commit('refund', post)
|
43
|
+
end
|
44
|
+
|
45
|
+
def store(creditcard, options = {})
|
46
|
+
post = build_store_post(creditcard, options)
|
47
|
+
commit_vault('add_customer', post)
|
48
|
+
end
|
49
|
+
|
50
|
+
def unstore(customer_vault_id, options = {})
|
51
|
+
post = build_unstore_post(customer_vault_id, options)
|
52
|
+
commit_vault('delete_customer', post)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def build_auth_post(money, creditcard_or_vault_id, options)
|
58
|
+
post = {}
|
59
|
+
add_order(post, options)
|
60
|
+
add_address(post, options)
|
61
|
+
add_shipping_address(post, options)
|
62
|
+
add_payment_method(post, creditcard_or_vault_id, options)
|
63
|
+
add_amount(post, money)
|
64
|
+
post
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_purchase_post(money, creditcard, options)
|
68
|
+
build_auth_post(money, creditcard, options)
|
69
|
+
end
|
70
|
+
|
71
|
+
def build_capture_post(money, authorization, option)
|
72
|
+
post = {}
|
73
|
+
post[:transactionid] = authorization
|
74
|
+
add_amount(post, money)
|
75
|
+
post
|
76
|
+
end
|
77
|
+
|
78
|
+
def build_void_post(authorization, options)
|
79
|
+
post = {}
|
80
|
+
post[:transactionid] = authorization
|
81
|
+
post
|
82
|
+
end
|
83
|
+
|
84
|
+
def build_refund_post(money, authorization, options)
|
85
|
+
post = {}
|
86
|
+
post[:transactionid] = authorization
|
87
|
+
add_amount(post, money)
|
88
|
+
post
|
89
|
+
end
|
90
|
+
|
91
|
+
def build_store_post(creditcard_or_check, options)
|
92
|
+
post = {}
|
93
|
+
add_address(post, options)
|
94
|
+
add_shipping_address(post, options)
|
95
|
+
add_payment_method(post, creditcard_or_check, options)
|
96
|
+
post
|
97
|
+
end
|
98
|
+
|
99
|
+
def build_unstore_post(customer_vault_id, options)
|
100
|
+
post = {}
|
101
|
+
post['customer_vault_id'] = customer_vault_id
|
102
|
+
post
|
103
|
+
end
|
104
|
+
|
105
|
+
def add_order(post, options)
|
106
|
+
post[:orderid] = options[:order_id]
|
107
|
+
post[:orderdescription] = options[:description]
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_address(post, options)
|
111
|
+
post[:email] = options[:email]
|
112
|
+
post[:ipaddress] = options[:ip]
|
113
|
+
|
114
|
+
address = options[:billing_address] || options[:address] || {}
|
115
|
+
post[:address1] = address[:address1]
|
116
|
+
post[:address2] = address[:address2]
|
117
|
+
post[:city] = address[:city]
|
118
|
+
post[:state] = address[:state]
|
119
|
+
post[:zip] = address[:zip]
|
120
|
+
post[:country] = address[:country]
|
121
|
+
post[:phone] = address[:phone]
|
122
|
+
end
|
123
|
+
|
124
|
+
def add_shipping_address(post, options)
|
125
|
+
shipping_address = options[:shipping_address] || {}
|
126
|
+
post[:shipping_address1] = shipping_address[:address1]
|
127
|
+
post[:shipping_address2] = shipping_address[:address2]
|
128
|
+
post[:shipping_city] = shipping_address[:city]
|
129
|
+
post[:shipping_state] = shipping_address[:state]
|
130
|
+
post[:shipping_zip] = shipping_address[:zip]
|
131
|
+
post[:shipping_country] = shipping_address[:country]
|
132
|
+
end
|
133
|
+
|
134
|
+
def add_swipe_data(post, options)
|
135
|
+
# unencrypted tracks
|
136
|
+
post[:track_1] = options[:track_1]
|
137
|
+
post[:track_2] = options[:track_2]
|
138
|
+
post[:track_3] = options[:track_3]
|
139
|
+
|
140
|
+
# encrypted tracks
|
141
|
+
post[:magnesafe_track_1] = options[:magnesafe_track_1]
|
142
|
+
post[:magnesafe_track_2] = options[:magnesafe_track_2]
|
143
|
+
post[:magnesafe_track_3] = options[:magnesafe_track_3]
|
144
|
+
post[:magnesafe_magneprint] = options[:magnesafe_magneprint]
|
145
|
+
post[:magnesafe_ksn] = options[:magnesafe_ksn]
|
146
|
+
post[:magnesafe_magneprint_status] = options[:magnesafe_magneprint_status]
|
147
|
+
end
|
148
|
+
|
149
|
+
def add_payment_method(post, creditcard_or_check_or_vault_id, options)
|
150
|
+
post[:processor_id] = options[:processor_id]
|
151
|
+
post[:customer_vault] = 'add_customer' if options[:store]
|
152
|
+
|
153
|
+
add_swipe_data(post, options)
|
154
|
+
|
155
|
+
# creditcard_or_check can be blank if using swipe data
|
156
|
+
if creditcard_or_check_or_vault_id.is_a?(CreditCard) # creditcard or check
|
157
|
+
creditcard = creditcard_or_check_or_vault_id
|
158
|
+
post[:firstname] = creditcard.first_name
|
159
|
+
post[:lastname] = creditcard.last_name
|
160
|
+
post[:ccnumber] = creditcard.number
|
161
|
+
post[:ccexp] = format(creditcard.month, :two_digits) + format(creditcard.year, :two_digits)
|
162
|
+
post[:cvv] = creditcard.verification_value
|
163
|
+
post[:payment] = 'creditcard'
|
164
|
+
elsif creditcard_or_check_or_vault_id.is_a?(Check)
|
165
|
+
check = creditcard_or_check_or_vault_id
|
166
|
+
post[:firstname] = check.first_name
|
167
|
+
post[:lastname] = check.last_name
|
168
|
+
post[:checkname] = check.name
|
169
|
+
post[:checkaba] = check.routing_number
|
170
|
+
post[:checkaccount] = check.account_number
|
171
|
+
post[:account_type] = check.account_type
|
172
|
+
post[:account_holder_type] = check.account_holder_type
|
173
|
+
post[:payment] = 'check'
|
174
|
+
else
|
175
|
+
post[:customer_vault_id] = creditcard_or_check_or_vault_id
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def add_login(post)
|
180
|
+
post[:username] = @options[:login]
|
181
|
+
post[:password] = @options[:password]
|
182
|
+
end
|
183
|
+
|
184
|
+
def add_amount(post, money)
|
185
|
+
post[:currency] = options[:currency] || currency(money)
|
186
|
+
post[:amount] = amount(money)
|
187
|
+
end
|
188
|
+
|
189
|
+
def commit_vault(action, parameters)
|
190
|
+
commit(nil, parameters.merge(:customer_vault => action))
|
191
|
+
end
|
192
|
+
|
193
|
+
def commit(action, parameters)
|
194
|
+
raw = parse(ssl_post(self.live_url, build_request(action, parameters)))
|
195
|
+
|
196
|
+
success = (raw['response'] == ResponseCodes::APPROVED)
|
197
|
+
|
198
|
+
authorization = authorization_from(success, parameters, raw)
|
199
|
+
|
200
|
+
Response.new(success, raw['responsetext'], raw,
|
201
|
+
:test => test?,
|
202
|
+
:authorization => authorization,
|
203
|
+
:avs_result => { :code => raw['avsresponse']},
|
204
|
+
:cvv_result => raw['cvvresponse']
|
205
|
+
)
|
206
|
+
end
|
207
|
+
|
208
|
+
def build_request(action, parameters)
|
209
|
+
parameters[:type] = action if action
|
210
|
+
add_login(parameters)
|
211
|
+
parameters.to_query
|
212
|
+
end
|
213
|
+
|
214
|
+
def authorization_from(success, parameters, response)
|
215
|
+
return nil unless success
|
216
|
+
|
217
|
+
authorization = response['transactionid']
|
218
|
+
if(parameters[:customer_vault] && (authorization.nil? || authorization.empty?))
|
219
|
+
authorization = response['customer_vault_id']
|
220
|
+
end
|
221
|
+
|
222
|
+
authorization
|
223
|
+
end
|
224
|
+
|
225
|
+
class ResponseCodes
|
226
|
+
APPROVED = '1'
|
227
|
+
DENIED = '2'
|
228
|
+
ERROR = '3'
|
229
|
+
end
|
230
|
+
|
231
|
+
def parse(raw_response)
|
232
|
+
rsp = CGI.parse(raw_response)
|
233
|
+
rsp.keys.each { |k| rsp[k] = rsp[k].first } # flatten out the values
|
234
|
+
rsp
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
@@ -66,7 +66,11 @@ module ActiveMerchant #:nodoc:
|
|
66
66
|
begin
|
67
67
|
raw_response = ssl_request(method, "https://api.paymill.com/v2/#{url}", post_data(parameters), headers)
|
68
68
|
rescue ResponseError => e
|
69
|
-
|
69
|
+
begin
|
70
|
+
parsed = JSON.parse(e.response.body)
|
71
|
+
rescue JSON::ParserError
|
72
|
+
return Response.new(false, "Unable to parse error response: '#{e.response.body}'")
|
73
|
+
end
|
70
74
|
return Response.new(false, response_message(parsed), parsed, {})
|
71
75
|
end
|
72
76
|
|
@@ -290,7 +290,7 @@ module ActiveMerchant #:nodoc:
|
|
290
290
|
parameters.update(
|
291
291
|
:Vendor => @options[:login],
|
292
292
|
:TxType => TRANSACTIONS[action],
|
293
|
-
:VPSProtocol => "
|
293
|
+
:VPSProtocol => "3.00"
|
294
294
|
)
|
295
295
|
|
296
296
|
if(application_id && (application_id != Gateway.application_id))
|
@@ -1,238 +1,8 @@
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
2
2
|
module Billing #:nodoc:
|
3
|
-
class TransnationalGateway <
|
4
|
-
self.live_url = self.test_url = 'https://secure.networkmerchants.com/api/transact.php'
|
5
|
-
|
6
|
-
self.supported_countries = ['US']
|
7
|
-
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
8
|
-
|
3
|
+
class TransnationalGateway < NetworkMerchantsGateway
|
9
4
|
self.homepage_url = 'http://www.tnbci.com/'
|
10
5
|
self.display_name = 'Transnational'
|
11
|
-
|
12
|
-
self.money_format = :dollars
|
13
|
-
self.default_currency = 'USD'
|
14
|
-
|
15
|
-
def initialize(options = {})
|
16
|
-
requires!(options, :login, :password)
|
17
|
-
super
|
18
|
-
end
|
19
|
-
|
20
|
-
def authorize(money, creditcard_or_vault_id, options = {})
|
21
|
-
post = build_auth_post(money, creditcard_or_vault_id, options)
|
22
|
-
commit('auth', post)
|
23
|
-
end
|
24
|
-
|
25
|
-
def purchase(money, creditcard_or_vault_id, options = {})
|
26
|
-
post = build_purchase_post(money, creditcard_or_vault_id, options)
|
27
|
-
commit('sale', post)
|
28
|
-
end
|
29
|
-
|
30
|
-
def capture(money, authorization, options = {})
|
31
|
-
post = build_capture_post(money, authorization, options)
|
32
|
-
commit('capture', post)
|
33
|
-
end
|
34
|
-
|
35
|
-
def void(authorization, options = {})
|
36
|
-
post = build_void_post(authorization, options)
|
37
|
-
commit('void', post)
|
38
|
-
end
|
39
|
-
|
40
|
-
def refund(money, authorization, options = {})
|
41
|
-
post = build_refund_post(money, authorization, options)
|
42
|
-
commit('refund', post)
|
43
|
-
end
|
44
|
-
|
45
|
-
def store(creditcard, options = {})
|
46
|
-
post = build_store_post(creditcard, options)
|
47
|
-
commit_vault('add_customer', post)
|
48
|
-
end
|
49
|
-
|
50
|
-
def unstore(customer_vault_id, options = {})
|
51
|
-
post = build_unstore_post(customer_vault_id, options)
|
52
|
-
commit_vault('delete_customer', post)
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def build_auth_post(money, creditcard_or_vault_id, options)
|
58
|
-
post = {}
|
59
|
-
add_order(post, options)
|
60
|
-
add_address(post, options)
|
61
|
-
add_shipping_address(post, options)
|
62
|
-
add_payment_method(post, creditcard_or_vault_id, options)
|
63
|
-
add_amount(post, money)
|
64
|
-
post
|
65
|
-
end
|
66
|
-
|
67
|
-
def build_purchase_post(money, creditcard, options)
|
68
|
-
build_auth_post(money, creditcard, options)
|
69
|
-
end
|
70
|
-
|
71
|
-
def build_capture_post(money, authorization, option)
|
72
|
-
post = {}
|
73
|
-
post[:transactionid] = authorization
|
74
|
-
add_amount(post, money)
|
75
|
-
post
|
76
|
-
end
|
77
|
-
|
78
|
-
def build_void_post(authorization, options)
|
79
|
-
post = {}
|
80
|
-
post[:transactionid] = authorization
|
81
|
-
post
|
82
|
-
end
|
83
|
-
|
84
|
-
def build_refund_post(money, authorization, options)
|
85
|
-
post = {}
|
86
|
-
post[:transactionid] = authorization
|
87
|
-
add_amount(post, money)
|
88
|
-
post
|
89
|
-
end
|
90
|
-
|
91
|
-
def build_store_post(creditcard_or_check, options)
|
92
|
-
post = {}
|
93
|
-
add_address(post, options)
|
94
|
-
add_shipping_address(post, options)
|
95
|
-
add_payment_method(post, creditcard_or_check, options)
|
96
|
-
post
|
97
|
-
end
|
98
|
-
|
99
|
-
def build_unstore_post(customer_vault_id, options)
|
100
|
-
post = {}
|
101
|
-
post['customer_vault_id'] = customer_vault_id
|
102
|
-
post
|
103
|
-
end
|
104
|
-
|
105
|
-
def add_order(post, options)
|
106
|
-
post[:orderid] = options[:order_id]
|
107
|
-
post[:orderdescription] = options[:description]
|
108
|
-
end
|
109
|
-
|
110
|
-
def add_address(post, options)
|
111
|
-
post[:email] = options[:email]
|
112
|
-
post[:ipaddress] = options[:ip]
|
113
|
-
|
114
|
-
address = options[:billing_address] || options[:address] || {}
|
115
|
-
post[:address1] = address[:address1]
|
116
|
-
post[:address2] = address[:address2]
|
117
|
-
post[:city] = address[:city]
|
118
|
-
post[:state] = address[:state]
|
119
|
-
post[:zip] = address[:zip]
|
120
|
-
post[:country] = address[:country]
|
121
|
-
post[:phone] = address[:phone]
|
122
|
-
end
|
123
|
-
|
124
|
-
def add_shipping_address(post, options)
|
125
|
-
shipping_address = options[:shipping_address] || {}
|
126
|
-
post[:shipping_address1] = shipping_address[:address1]
|
127
|
-
post[:shipping_address2] = shipping_address[:address2]
|
128
|
-
post[:shipping_city] = shipping_address[:city]
|
129
|
-
post[:shipping_state] = shipping_address[:state]
|
130
|
-
post[:shipping_zip] = shipping_address[:zip]
|
131
|
-
post[:shipping_country] = shipping_address[:country]
|
132
|
-
end
|
133
|
-
|
134
|
-
def add_swipe_data(post, options)
|
135
|
-
# unencrypted tracks
|
136
|
-
post[:track_1] = options[:track_1]
|
137
|
-
post[:track_2] = options[:track_2]
|
138
|
-
post[:track_3] = options[:track_3]
|
139
|
-
|
140
|
-
# encrypted tracks
|
141
|
-
post[:magnesafe_track_1] = options[:magnesafe_track_1]
|
142
|
-
post[:magnesafe_track_2] = options[:magnesafe_track_2]
|
143
|
-
post[:magnesafe_track_3] = options[:magnesafe_track_3]
|
144
|
-
post[:magnesafe_magneprint] = options[:magnesafe_magneprint]
|
145
|
-
post[:magnesafe_ksn] = options[:magnesafe_ksn]
|
146
|
-
post[:magnesafe_magneprint_status] = options[:magnesafe_magneprint_status]
|
147
|
-
end
|
148
|
-
|
149
|
-
def add_payment_method(post, creditcard_or_check_or_vault_id, options)
|
150
|
-
post[:processor_id] = options[:processor_id]
|
151
|
-
post[:customer_vault] = 'add_customer' if options[:store]
|
152
|
-
|
153
|
-
add_swipe_data(post, options)
|
154
|
-
|
155
|
-
# creditcard_or_check can be blank if using swipe data
|
156
|
-
if creditcard_or_check_or_vault_id.is_a?(CreditCard) # creditcard or check
|
157
|
-
creditcard = creditcard_or_check_or_vault_id
|
158
|
-
post[:firstname] = creditcard.first_name
|
159
|
-
post[:lastname] = creditcard.last_name
|
160
|
-
post[:ccnumber] = creditcard.number
|
161
|
-
post[:ccexp] = format(creditcard.month, :two_digits) + format(creditcard.year, :two_digits)
|
162
|
-
post[:cvv] = creditcard.verification_value
|
163
|
-
post[:payment] = 'creditcard'
|
164
|
-
elsif creditcard_or_check_or_vault_id.is_a?(Check)
|
165
|
-
check = creditcard_or_check_or_vault_id
|
166
|
-
post[:firstname] = check.first_name
|
167
|
-
post[:lastname] = check.last_name
|
168
|
-
post[:checkname] = check.name
|
169
|
-
post[:checkaba] = check.routing_number
|
170
|
-
post[:checkaccount] = check.account_number
|
171
|
-
post[:account_type] = check.account_type
|
172
|
-
post[:account_holder_type] = check.account_holder_type
|
173
|
-
post[:payment] = 'check'
|
174
|
-
else
|
175
|
-
post[:customer_vault_id] = creditcard_or_check_or_vault_id
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
def add_login(post)
|
180
|
-
post[:username] = @options[:login]
|
181
|
-
post[:password] = @options[:password]
|
182
|
-
end
|
183
|
-
|
184
|
-
def add_amount(post, money)
|
185
|
-
post[:currency] = options[:currency] || currency(money)
|
186
|
-
post[:amount] = amount(money)
|
187
|
-
end
|
188
|
-
|
189
|
-
def commit_vault(action, parameters)
|
190
|
-
commit(nil, parameters.merge(:customer_vault => action))
|
191
|
-
end
|
192
|
-
|
193
|
-
def commit(action, parameters)
|
194
|
-
raw = parse(ssl_post(self.live_url, build_request(action, parameters)))
|
195
|
-
|
196
|
-
success = (raw['response'] == ResponseCodes::APPROVED)
|
197
|
-
|
198
|
-
authorization = authorization_from(success, parameters, raw)
|
199
|
-
|
200
|
-
Response.new(success, raw['responsetext'], raw,
|
201
|
-
:test => test?,
|
202
|
-
:authorization => authorization,
|
203
|
-
:avs_result => { :code => raw['avsresponse']},
|
204
|
-
:cvv_result => raw['cvvresponse']
|
205
|
-
)
|
206
|
-
end
|
207
|
-
|
208
|
-
def build_request(action, parameters)
|
209
|
-
parameters[:type] = action if action
|
210
|
-
add_login(parameters)
|
211
|
-
parameters.to_query
|
212
|
-
end
|
213
|
-
|
214
|
-
def authorization_from(success, parameters, response)
|
215
|
-
return nil unless success
|
216
|
-
|
217
|
-
authorization = response['transactionid']
|
218
|
-
if(parameters[:customer_vault] && (authorization.nil? || authorization.empty?))
|
219
|
-
authorization = response['customer_vault_id']
|
220
|
-
end
|
221
|
-
|
222
|
-
authorization
|
223
|
-
end
|
224
|
-
|
225
|
-
class ResponseCodes
|
226
|
-
APPROVED = '1'
|
227
|
-
DENIED = '2'
|
228
|
-
ERROR = '3'
|
229
|
-
end
|
230
|
-
|
231
|
-
def parse(raw_response)
|
232
|
-
rsp = CGI.parse(raw_response)
|
233
|
-
rsp.keys.each { |k| rsp[k] = rsp[k].first } # flatten out the values
|
234
|
-
rsp
|
235
|
-
end
|
236
6
|
end
|
237
7
|
end
|
238
8
|
end
|