yetanothernguyen-activemerchant 1.16.0 → 1.21.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.
- data/CHANGELOG +95 -0
- data/CONTRIBUTORS +29 -0
- data/lib/active_merchant/billing/credit_card.rb +105 -19
- data/lib/active_merchant/billing/credit_card_methods.rb +5 -1
- data/lib/active_merchant/billing/gateway.rb +1 -1
- data/lib/active_merchant/billing/gateways/authorize_net.rb +24 -2
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +104 -18
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +110 -4
- data/lib/active_merchant/billing/gateways/beanstream.rb +29 -1
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +9 -4
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +4 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +279 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +9 -9
- data/lib/active_merchant/billing/gateways/elavon.rb +2 -1
- data/lib/active_merchant/billing/gateways/epay.rb +12 -6
- data/lib/active_merchant/billing/gateways/eway_managed.rb +46 -12
- data/lib/active_merchant/billing/gateways/exact.rb +5 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +3 -3
- data/lib/active_merchant/billing/gateways/ipay88.rb +157 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +3 -3
- data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +4 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +244 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +94 -56
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +277 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +57 -34
- data/lib/active_merchant/billing/gateways/pay_junction.rb +6 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +2 -2
- data/lib/active_merchant/billing/gateways/payflow.rb +10 -2
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +8 -5
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +93 -40
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +8 -3
- data/lib/active_merchant/billing/gateways/qbms.rb +4 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +97 -22
- data/lib/active_merchant/billing/gateways/realex.rb +5 -1
- data/lib/active_merchant/billing/gateways/samurai.rb +121 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +136 -49
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -1
- data/lib/active_merchant/billing/gateways/skip_jack.rb +7 -2
- data/lib/active_merchant/billing/gateways/stripe.rb +51 -19
- data/lib/active_merchant/billing/gateways/usa_epay.rb +13 -184
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1496 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +206 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +2 -2
- data/lib/active_merchant/billing/gateways/viaklix.rb +1 -1
- data/lib/active_merchant/billing/gateways/worldpay.rb +1 -1
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +6 -2
- data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
- data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +4 -4
- data/lib/active_merchant/billing/integrations/dwolla/helper.rb +31 -0
- data/lib/active_merchant/billing/integrations/dwolla/notification.rb +55 -0
- data/lib/active_merchant/billing/integrations/dwolla/return.rb +38 -0
- data/lib/active_merchant/billing/integrations/dwolla.rb +30 -0
- data/lib/active_merchant/billing/integrations/helper.rb +19 -2
- data/lib/active_merchant/billing/integrations/ipay88/helper.rb +120 -0
- data/lib/active_merchant/billing/integrations/ipay88/return.rb +121 -0
- data/lib/active_merchant/billing/integrations/ipay88.rb +40 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +1 -1
- data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
- data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +4 -4
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +18 -2
- data/lib/active_merchant/billing/integrations/two_checkout.rb +1 -2
- data/lib/active_merchant/railtie.rb +7 -7
- data/lib/active_merchant/railtie.rb.orig +19 -0
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant.rb +23 -10
- data/lib/active_merchant.rb.orig +78 -0
- metadata +147 -63
- data/lib/active_merchant/common/connection.rb +0 -177
- data/lib/active_merchant/common/country.rb +0 -328
- data/lib/active_merchant/common/error.rb +0 -26
- data/lib/active_merchant/common/post_data.rb +0 -24
- data/lib/active_merchant/common/posts_data.rb +0 -63
- data/lib/active_merchant/common/requires_parameters.rb +0 -16
- data/lib/active_merchant/common/utils.rb +0 -22
- data/lib/active_merchant/common/validateable.rb +0 -81
- data/lib/active_merchant/common.rb +0 -14
- data/lib/certs/cacert.pem +0 -7815
@@ -0,0 +1,340 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
module ActiveMerchant #:nodoc:
|
3
|
+
module Billing #:nodoc:
|
4
|
+
module Integrations #:nodoc:
|
5
|
+
|
6
|
+
# # Example:
|
7
|
+
# parser = AuthorizeNetSim::Notification.new(request.raw_post)
|
8
|
+
# passed = parser.complete?
|
9
|
+
#
|
10
|
+
# order = Order.find_by_order_number(parser.invoice_num)
|
11
|
+
#
|
12
|
+
# unless order
|
13
|
+
# @message = 'Error--unable to find your transaction! Please contact us directly.'
|
14
|
+
# return render :partial => 'authorize_net_sim_payment_response'
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# if order.total != parser.gross.to_f
|
18
|
+
# logger.error "Authorize.Net sim said they paid for #{parser.gross} and it should have been #{order.total}!"
|
19
|
+
# passed = false
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# # Theoretically, Authorize.net will *never* pass us the same transaction
|
23
|
+
# # ID twice, but we can double check that... by using
|
24
|
+
# # parser.transaction_id, and checking against previous orders' transaction
|
25
|
+
# # id's (which you can save when the order is completed)....
|
26
|
+
# unless parser.acknowledge MD5_HASH_SET_IN_AUTHORIZE_NET, AUTHORIZE_LOGIN
|
27
|
+
# passed = false
|
28
|
+
# logger.error "ALERT POSSIBLE FRAUD ATTEMPT either that or you haven't setup your md5 hash setting right in #{__FILE__}
|
29
|
+
# because a transaction came back from Authorize.Net with the wrong hash value--rejecting!"
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# unless parser.cavv_matches? and parser.avs_code_matches?
|
33
|
+
# logger.error 'Warning--non matching CC!' + params.inspect
|
34
|
+
# # Could fail them here, as well (recommended)...
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# if passed
|
38
|
+
# # Set up your session, and render something that will redirect them to
|
39
|
+
# # your site, most likely.
|
40
|
+
# else
|
41
|
+
# # Render failure or redirect them to your site where you will render failure
|
42
|
+
# end
|
43
|
+
|
44
|
+
module AuthorizeNetSim
|
45
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
46
|
+
|
47
|
+
def unescape(val) #:nodoc:
|
48
|
+
if val
|
49
|
+
CGI::unescape val
|
50
|
+
else
|
51
|
+
val
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Passes a hash of the address the user entered in at Authorize.Net
|
56
|
+
def billing_address
|
57
|
+
all = {}
|
58
|
+
[:fax, :city, :company, :last_name, :country, :zip, :first_name, :address, :email, :state].each do |key_out|
|
59
|
+
all[key_out] = unescape params['x_' + key_out.to_s]
|
60
|
+
end
|
61
|
+
all
|
62
|
+
end
|
63
|
+
|
64
|
+
def customer_id
|
65
|
+
unescape params['x_cust_id']
|
66
|
+
end
|
67
|
+
|
68
|
+
def auth_code
|
69
|
+
unescape params['x_auth_code']
|
70
|
+
end
|
71
|
+
|
72
|
+
def po_num
|
73
|
+
unescape params['x_po_num']
|
74
|
+
end
|
75
|
+
|
76
|
+
def ship_to_address
|
77
|
+
all = {}
|
78
|
+
[:city, :last_name, :first_name, :country, :zip, :address].each do |key_out|
|
79
|
+
all[key_out] = unescape params['x_ship_to_' + key_out.to_s]
|
80
|
+
end
|
81
|
+
all
|
82
|
+
end
|
83
|
+
|
84
|
+
# Tax amount we sent them.
|
85
|
+
def tax
|
86
|
+
unescape params['x_tax']
|
87
|
+
end
|
88
|
+
|
89
|
+
# Transaction type (probably going to be auth_capture, since that's
|
90
|
+
# all we set it as).
|
91
|
+
def transaction_type
|
92
|
+
unescape params['x_type']
|
93
|
+
end
|
94
|
+
|
95
|
+
# Payment method used--almost always CC (for credit card).
|
96
|
+
def method
|
97
|
+
unescape params['x_method']
|
98
|
+
end
|
99
|
+
|
100
|
+
# Ff our payment method is available. Almost always "true".
|
101
|
+
def method_available
|
102
|
+
params['x_method_available']
|
103
|
+
end
|
104
|
+
|
105
|
+
# Invoice num we passed in as invoice_num to them.
|
106
|
+
def invoice_num
|
107
|
+
item_id
|
108
|
+
end
|
109
|
+
|
110
|
+
# If you pass any values to authorize that aren't its expected, it
|
111
|
+
# will pass them back to you verbatim, returned by this method.
|
112
|
+
# custom values:
|
113
|
+
def all_custom_values_passed_in_and_now_passed_back_to_us
|
114
|
+
all = {}
|
115
|
+
params.each do |key, value|
|
116
|
+
if key[0..1] != 'x_'
|
117
|
+
all[key] = unescape value
|
118
|
+
end
|
119
|
+
end
|
120
|
+
all
|
121
|
+
end
|
122
|
+
|
123
|
+
def duty
|
124
|
+
unescape params['x_duty']
|
125
|
+
end
|
126
|
+
|
127
|
+
# Shipping we sent them.
|
128
|
+
def freight
|
129
|
+
unescape params['x_freight']
|
130
|
+
end
|
131
|
+
alias_method :shipping, :freight
|
132
|
+
|
133
|
+
def description
|
134
|
+
unescape params['x_description']
|
135
|
+
end
|
136
|
+
|
137
|
+
# Returns the response code as a symbol.
|
138
|
+
# {'1' => :approved, '2' => :declined, '3' => :error, '4' => :held_for_review}
|
139
|
+
def response_code_as_ruby_symbol
|
140
|
+
map = {'1' => :approved, '2' => :declined, '3' => :error, '4' => :held_for_review}
|
141
|
+
map[params['x_response_code']]
|
142
|
+
end
|
143
|
+
|
144
|
+
def response_reason_text
|
145
|
+
unescape params['x_response_reason_text']
|
146
|
+
end
|
147
|
+
|
148
|
+
# The response reason text's numeric id [equivalent--just a number]
|
149
|
+
def response_reason_code
|
150
|
+
unescape params['x_response_reason_code']
|
151
|
+
end
|
152
|
+
|
153
|
+
# 'used internally by their gateway'
|
154
|
+
def response_subcode
|
155
|
+
params['x_response_subcode']
|
156
|
+
end
|
157
|
+
|
158
|
+
# They pass back a tax_exempt value.
|
159
|
+
def tax_exempt
|
160
|
+
params['x_tax_exempt']
|
161
|
+
end
|
162
|
+
|
163
|
+
# avs [address verification] code
|
164
|
+
# A = Address (Street)
|
165
|
+
# matches, ZIP does not
|
166
|
+
# B = Address information
|
167
|
+
# not provided for AVS
|
168
|
+
# check
|
169
|
+
# E = AVS error
|
170
|
+
# G = Non-U.S. Card Issuing
|
171
|
+
# Bank
|
172
|
+
# N = No Match on Address
|
173
|
+
# (Street) or ZIP
|
174
|
+
# P = AVS not applicable for
|
175
|
+
# this transaction
|
176
|
+
# R = Retry – System
|
177
|
+
# unavailable or timed out
|
178
|
+
# S = Service not supported
|
179
|
+
# by issuer
|
180
|
+
# U = Address information is
|
181
|
+
# unavailable
|
182
|
+
# W = Nine digit ZIP
|
183
|
+
# matches, Address (Street)
|
184
|
+
# does not
|
185
|
+
# X = Address (Street) and
|
186
|
+
# nine digit ZIP match
|
187
|
+
# Y = Address (Street) and
|
188
|
+
# five digit ZIP match
|
189
|
+
# Z = Five digit ZIP matches
|
190
|
+
# Address (Street) does not
|
191
|
+
def avs_code
|
192
|
+
params['x_avs_code']
|
193
|
+
end
|
194
|
+
|
195
|
+
# Returns true if their address completely matched [Y or X, P from
|
196
|
+
# #avs_code, which mean 'add+zip match', 'address + 9-zip match', and
|
197
|
+
# not applicable, respectively].
|
198
|
+
def avs_code_matches?
|
199
|
+
return ['Y', 'X', 'P'].include? params['x_avs_code']
|
200
|
+
end
|
201
|
+
|
202
|
+
# cvv2 response
|
203
|
+
# M = Match
|
204
|
+
# N = No Match
|
205
|
+
# P = Not Processed
|
206
|
+
# S = Should have been
|
207
|
+
# present
|
208
|
+
# U = Issuer unable to
|
209
|
+
# process request
|
210
|
+
def cvv2_resp_code
|
211
|
+
params['x_cvv2_resp_code']
|
212
|
+
end
|
213
|
+
|
214
|
+
# check if #cvv2_resp_code == 'm' for Match. otherwise false
|
215
|
+
def cvv2_resp_code_matches?
|
216
|
+
return ['M'].include? cvv2_resp_code
|
217
|
+
end
|
218
|
+
|
219
|
+
# cavv_response--'cardholder authentication verification response code'--most likely not use for SIM
|
220
|
+
# Blank or not present =
|
221
|
+
# CAVV not validated
|
222
|
+
# 0 = CAVV not validated
|
223
|
+
# because erroneous data
|
224
|
+
# was submitted
|
225
|
+
# 1 = CAVV failed validation
|
226
|
+
# 2 = CAVV passed
|
227
|
+
# validation
|
228
|
+
# 3 = CAVV validation could
|
229
|
+
# not be performed; issuer
|
230
|
+
# attempt incomplete
|
231
|
+
# 4 = CAVV validation could
|
232
|
+
# not be performed; issuer
|
233
|
+
# system error
|
234
|
+
# 5 = Reserved for future
|
235
|
+
# use
|
236
|
+
# 6 = Reserved for future
|
237
|
+
# use
|
238
|
+
# 7 = CAVV attempt – failed
|
239
|
+
# validation – issuer
|
240
|
+
# available (U.S.-issued
|
241
|
+
# card/non-U.S acquirer)
|
242
|
+
# 8 = CAVV attempt –
|
243
|
+
# passed validation – issuer
|
244
|
+
# available (U.S.-issued
|
245
|
+
# card/non-U.S. acquirer)
|
246
|
+
# 9 = CAVV attempt – failed
|
247
|
+
# validation – issuer
|
248
|
+
def cavv_response
|
249
|
+
params['x_cavv_response']
|
250
|
+
end
|
251
|
+
|
252
|
+
# Check if #cavv_response == '', '2', '8' one of those [non failing]
|
253
|
+
# [blank means no validated, 2 is passed, 8 is passed issuer
|
254
|
+
# available]
|
255
|
+
def cavv_matches?
|
256
|
+
['','2','8'].include? cavv_response
|
257
|
+
end
|
258
|
+
|
259
|
+
# Payment is complete -- returns true if x_response_code == '1'
|
260
|
+
def complete?
|
261
|
+
params["x_response_code"] == '1'
|
262
|
+
end
|
263
|
+
|
264
|
+
# Alias for invoice number--this is the only id they pass back to us
|
265
|
+
# that we passed to them, except customer id is also passed back.
|
266
|
+
def item_id
|
267
|
+
unescape params['x_invoice_num']
|
268
|
+
end
|
269
|
+
|
270
|
+
# They return this number to us [it's unique to Authorize.net].
|
271
|
+
def transaction_id
|
272
|
+
params['x_trans_id']
|
273
|
+
end
|
274
|
+
|
275
|
+
# When was this payment was received by the client. --unimplemented --
|
276
|
+
# always returns nil
|
277
|
+
def received_at
|
278
|
+
nil
|
279
|
+
end
|
280
|
+
|
281
|
+
# End-user's email
|
282
|
+
def payer_email
|
283
|
+
unescape params['x_email']
|
284
|
+
end
|
285
|
+
|
286
|
+
# They don't pass merchant email back to us -- unimplemented -- always
|
287
|
+
# returns nil
|
288
|
+
def receiver_email
|
289
|
+
nil
|
290
|
+
end
|
291
|
+
|
292
|
+
# md5 hash used internally
|
293
|
+
def security_key
|
294
|
+
params['x_MD5_Hash']
|
295
|
+
end
|
296
|
+
|
297
|
+
# The money amount we received in X.2 decimal. Returns a string
|
298
|
+
def gross
|
299
|
+
unescape params['x_amount']
|
300
|
+
end
|
301
|
+
|
302
|
+
# Was this a test transaction?
|
303
|
+
def test?
|
304
|
+
params['x_test_request'] == 'true'
|
305
|
+
end
|
306
|
+
|
307
|
+
# #method_available alias
|
308
|
+
def status
|
309
|
+
complete?
|
310
|
+
end
|
311
|
+
|
312
|
+
# Called to request back and check if it was a valid request.
|
313
|
+
# Authorize.net passes us back a hash that includes a hash of our
|
314
|
+
# 'unique' MD5 value that we set within their system.
|
315
|
+
#
|
316
|
+
# Example:
|
317
|
+
# acknowledge('my secret md5 hash that I set within Authorize.Net', 'authorize_login')
|
318
|
+
#
|
319
|
+
# Note this is somewhat unsafe unless you actually set that md5 hash
|
320
|
+
# to something (defaults to '' in their system).
|
321
|
+
def acknowledge(md5_hash_set_in_authorize_net, authorize_net_login_name)
|
322
|
+
Digest::MD5.hexdigest(md5_hash_set_in_authorize_net + authorize_net_login_name + params['x_trans_id'] + gross) == params['x_MD5_Hash'].downcase
|
323
|
+
end
|
324
|
+
|
325
|
+
private
|
326
|
+
|
327
|
+
# Take the posted data and move the relevant data into a hash.
|
328
|
+
def parse(post)
|
329
|
+
@raw = post
|
330
|
+
post.split('&').each do |line|
|
331
|
+
key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
|
332
|
+
params[key] = value
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module AuthorizeNetSim
|
5
|
+
autoload :Helper, 'active_merchant/billing/integrations/authorize_net_sim/helper.rb'
|
6
|
+
autoload :Notification, 'active_merchant/billing/integrations/authorize_net_sim/notification.rb'
|
7
|
+
|
8
|
+
# Overwrite this if you want to change the ANS test url
|
9
|
+
mattr_accessor :test_url
|
10
|
+
self.test_url = 'https://test.authorize.net/gateway/transact.dll'
|
11
|
+
|
12
|
+
# Overwrite this if you want to change the ANS production url
|
13
|
+
mattr_accessor :production_url
|
14
|
+
self.production_url = 'https://secure.authorize.net/gateway/transact.dll'
|
15
|
+
|
16
|
+
def self.service_url
|
17
|
+
mode = ActiveMerchant::Billing::Base.integration_mode
|
18
|
+
case mode
|
19
|
+
when :production
|
20
|
+
self.production_url
|
21
|
+
when :test
|
22
|
+
self.test_url
|
23
|
+
else
|
24
|
+
raise StandardError, "Integration mode set to an invalid value: #{mode}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.notification(post)
|
29
|
+
Notification.new(post)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.return(query_string)
|
33
|
+
Return.new(query_string)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -173,15 +173,15 @@ module ActiveMerchant #:nodoc:
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def encode_value(value)
|
176
|
-
encoded =
|
176
|
+
encoded = Base64.strict_encode64(value)
|
177
177
|
string_to_encode = encoded[0, 1] + "T" + encoded[1, encoded.length]
|
178
|
-
|
178
|
+
Base64.strict_encode64(string_to_encode)
|
179
179
|
end
|
180
180
|
|
181
181
|
def decode_value(value)
|
182
|
-
decoded =
|
182
|
+
decoded = Base64.decode64(value)
|
183
183
|
string_to_decode = decoded[0, 1] + decoded[2, decoded.length]
|
184
|
-
|
184
|
+
Base64.decode64(string_to_decode)
|
185
185
|
end
|
186
186
|
|
187
187
|
def phone_code_for_country(country)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module Dwolla
|
5
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
6
|
+
|
7
|
+
def initialize(order, account, options = {})
|
8
|
+
super
|
9
|
+
add_field('name', 'Store Purchase')
|
10
|
+
|
11
|
+
if ActiveMerchant::Billing::Base.integration_mode == :test || options[:test]
|
12
|
+
add_field('test', 'true')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Replace with the real mapping
|
17
|
+
mapping :account, 'destinationid'
|
18
|
+
mapping :credential2, 'key'
|
19
|
+
mapping :credential3, 'secret'
|
20
|
+
mapping :notify_url, 'callback'
|
21
|
+
mapping :return_url, 'redirect'
|
22
|
+
mapping :description, 'description'
|
23
|
+
mapping :amount, 'amount'
|
24
|
+
mapping :tax, 'tax'
|
25
|
+
mapping :shipping, 'shipping'
|
26
|
+
mapping :order, 'orderid'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Dwolla
|
7
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
8
|
+
def complete?
|
9
|
+
status == "Completed"
|
10
|
+
end
|
11
|
+
|
12
|
+
def status
|
13
|
+
params["Status"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def transaction_id
|
17
|
+
params['TransactionId']
|
18
|
+
end
|
19
|
+
|
20
|
+
def item_id
|
21
|
+
params['OrderId']
|
22
|
+
end
|
23
|
+
|
24
|
+
def currency
|
25
|
+
"USD"
|
26
|
+
end
|
27
|
+
|
28
|
+
def gross
|
29
|
+
params['Amount']
|
30
|
+
end
|
31
|
+
|
32
|
+
def error
|
33
|
+
params['Message']
|
34
|
+
end
|
35
|
+
|
36
|
+
# Was this a test transaction?
|
37
|
+
def test?
|
38
|
+
params['TestMode']
|
39
|
+
end
|
40
|
+
|
41
|
+
def acknowledge
|
42
|
+
true
|
43
|
+
end
|
44
|
+
private
|
45
|
+
# Take the posted data and move the relevant data into a hash
|
46
|
+
def parse(post)
|
47
|
+
@raw = post.to_s
|
48
|
+
json_post = JSON.parse(post)
|
49
|
+
params.merge!(json_post)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module Dwolla
|
5
|
+
class Return < ActiveMerchant::Billing::Integrations::Return
|
6
|
+
|
7
|
+
def success?
|
8
|
+
self.error.nil? && self.callback_success?
|
9
|
+
end
|
10
|
+
|
11
|
+
def error
|
12
|
+
params['error']
|
13
|
+
end
|
14
|
+
|
15
|
+
def error_description
|
16
|
+
params['error_description']
|
17
|
+
end
|
18
|
+
|
19
|
+
def checkout_id
|
20
|
+
params['checkoutid']
|
21
|
+
end
|
22
|
+
|
23
|
+
def transaction
|
24
|
+
params['transaction']
|
25
|
+
end
|
26
|
+
|
27
|
+
def test?
|
28
|
+
params['test']
|
29
|
+
end
|
30
|
+
|
31
|
+
def callback_success?
|
32
|
+
params['postback'] != "failure"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# All mappings in helper.rb are required fields to be sent to Dwolla.
|
2
|
+
# :account = 'Dwolla Id of merchant'
|
3
|
+
# :credential1 = 'key from Dwolla Application'
|
4
|
+
# :credential2 = 'secret from Dwolla Application'
|
5
|
+
# :redirect_url = 'can be different that what is specified on Dwolla Application creation'
|
6
|
+
# :return_url = 'can be different that what is specified on Dwolla Application creation'
|
7
|
+
# :order_id = must be unique for each transaction
|
8
|
+
|
9
|
+
module ActiveMerchant #:nodoc:
|
10
|
+
module Billing #:nodoc:
|
11
|
+
module Integrations #:nodoc:
|
12
|
+
module Dwolla
|
13
|
+
autoload :Return, 'active_merchant/billing/integrations/dwolla/return.rb'
|
14
|
+
autoload :Helper, 'active_merchant/billing/integrations/dwolla/helper.rb'
|
15
|
+
autoload :Notification, 'active_merchant/billing/integrations/dwolla/notification.rb'
|
16
|
+
|
17
|
+
mattr_accessor :service_url
|
18
|
+
self.service_url = 'https://www.dwolla.com/payment/pay'
|
19
|
+
|
20
|
+
def self.notification(post, options={})
|
21
|
+
Notification.new(post)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.return(query_string, options={})
|
25
|
+
Return.new(query_string)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -14,8 +14,10 @@ module ActiveMerchant #:nodoc:
|
|
14
14
|
self.application_id = 'ActiveMerchant'
|
15
15
|
|
16
16
|
def initialize(order, account, options = {})
|
17
|
-
options.assert_valid_keys([:amount, :currency, :test, :credential2, :credential3, :credential4, :country, :account_name])
|
18
|
-
@fields
|
17
|
+
options.assert_valid_keys([:amount, :currency, :test, :credential2, :credential3, :credential4, :country, :account_name, :transaction_type])
|
18
|
+
@fields = {}
|
19
|
+
@raw_html_fields = []
|
20
|
+
@test = options[:test]
|
19
21
|
self.order = order
|
20
22
|
self.account = account
|
21
23
|
self.amount = options[:amount]
|
@@ -42,6 +44,17 @@ module ActiveMerchant #:nodoc:
|
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
47
|
+
# Add a field that has characters that CGI::escape would mangle. Allows
|
48
|
+
# for multiple fields with the same name (e.g., to support line items).
|
49
|
+
def add_raw_html_field(name, value)
|
50
|
+
return if name.blank? || value.blank?
|
51
|
+
@raw_html_fields << [name, value]
|
52
|
+
end
|
53
|
+
|
54
|
+
def raw_html_fields
|
55
|
+
@raw_html_fields
|
56
|
+
end
|
57
|
+
|
45
58
|
def billing_address(params = {})
|
46
59
|
add_address(:billing_address, params)
|
47
60
|
end
|
@@ -54,6 +67,10 @@ module ActiveMerchant #:nodoc:
|
|
54
67
|
@fields
|
55
68
|
end
|
56
69
|
|
70
|
+
def test?
|
71
|
+
@test_mode ||= ActiveMerchant::Billing::Base.integration_mode == :test || @test
|
72
|
+
end
|
73
|
+
|
57
74
|
private
|
58
75
|
|
59
76
|
def add_address(key, params)
|