activemerchant 1.28.0 → 1.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data.tar.gz.sig +3 -3
  2. data/CHANGELOG +36 -0
  3. data/CONTRIBUTORS +8 -0
  4. data/README.md +5 -0
  5. data/lib/active_merchant/billing/gateway.rb +2 -1
  6. data/lib/active_merchant/billing/gateways.rb +6 -7
  7. data/lib/active_merchant/billing/gateways/authorize_net.rb +3 -2
  8. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +77 -78
  9. data/lib/active_merchant/billing/gateways/balanced.rb +0 -1
  10. data/lib/active_merchant/billing/gateways/banwire.rb +1 -2
  11. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +19 -20
  12. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +35 -36
  13. data/lib/active_merchant/billing/gateways/blue_pay.rb +135 -140
  14. data/lib/active_merchant/billing/gateways/braintree_blue.rb +12 -4
  15. data/lib/active_merchant/billing/gateways/card_stream.rb +54 -59
  16. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -1
  17. data/lib/active_merchant/billing/gateways/cyber_source.rb +19 -14
  18. data/lib/active_merchant/billing/gateways/data_cash.rb +106 -112
  19. data/lib/active_merchant/billing/gateways/efsnet.rb +29 -34
  20. data/lib/active_merchant/billing/gateways/elavon.rb +7 -1
  21. data/lib/active_merchant/billing/gateways/epay.rb +0 -1
  22. data/lib/active_merchant/billing/gateways/eway.rb +88 -93
  23. data/lib/active_merchant/billing/gateways/eway_managed.rb +47 -51
  24. data/lib/active_merchant/billing/gateways/exact.rb +45 -54
  25. data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -4
  26. data/lib/active_merchant/billing/gateways/first_pay.rb +37 -38
  27. data/lib/active_merchant/billing/gateways/garanti.rb +1 -2
  28. data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
  29. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +5 -8
  30. data/lib/active_merchant/billing/gateways/inspire.rb +52 -52
  31. data/lib/active_merchant/billing/gateways/instapay.rb +10 -11
  32. data/lib/active_merchant/billing/gateways/iridium.rb +38 -39
  33. data/lib/active_merchant/billing/gateways/itransact.rb +7 -9
  34. data/lib/active_merchant/billing/gateways/jetpay.rb +45 -46
  35. data/lib/active_merchant/billing/gateways/linkpoint.rb +104 -108
  36. data/lib/active_merchant/billing/gateways/litle.rb +1 -5
  37. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +153 -155
  38. data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -50
  39. data/lib/active_merchant/billing/gateways/mercury.rb +272 -0
  40. data/lib/active_merchant/billing/gateways/metrics_global.rb +9 -10
  41. data/lib/active_merchant/billing/gateways/migs.rb +5 -3
  42. data/lib/active_merchant/billing/gateways/modern_payments.rb +6 -7
  43. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +40 -41
  44. data/lib/active_merchant/billing/gateways/moneris.rb +46 -50
  45. data/lib/active_merchant/billing/gateways/moneris_us.rb +52 -55
  46. data/lib/active_merchant/billing/gateways/nab_transact.rb +0 -5
  47. data/lib/active_merchant/billing/gateways/net_registry.rb +20 -21
  48. data/lib/active_merchant/billing/gateways/netaxept.rb +30 -36
  49. data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
  50. data/lib/active_merchant/billing/gateways/ogone.rb +0 -5
  51. data/lib/active_merchant/billing/gateways/optimal_payment.rb +1 -6
  52. data/lib/active_merchant/billing/gateways/orbital.rb +25 -21
  53. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
  54. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +1 -6
  55. data/lib/active_merchant/billing/gateways/pay_junction.rb +62 -63
  56. data/lib/active_merchant/billing/gateways/pay_secure.rb +29 -30
  57. data/lib/active_merchant/billing/gateways/paybox_direct.rb +0 -5
  58. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +33 -38
  59. data/lib/active_merchant/billing/gateways/payment_express.rb +48 -51
  60. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +7 -11
  61. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +7 -0
  62. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +3 -0
  63. data/lib/active_merchant/billing/gateways/paystation.rb +62 -64
  64. data/lib/active_merchant/billing/gateways/payway.rb +2 -9
  65. data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -1
  66. data/lib/active_merchant/billing/gateways/psigate.rb +102 -94
  67. data/lib/active_merchant/billing/gateways/psl_card.rb +66 -67
  68. data/lib/active_merchant/billing/gateways/qbms.rb +0 -6
  69. data/lib/active_merchant/billing/gateways/quantum.rb +2 -8
  70. data/lib/active_merchant/billing/gateways/quickpay.rb +2 -3
  71. data/lib/active_merchant/billing/gateways/realex.rb +6 -16
  72. data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
  73. data/lib/active_merchant/billing/gateways/sage.rb +15 -16
  74. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +25 -26
  75. data/lib/active_merchant/billing/gateways/sage_pay.rb +51 -56
  76. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  77. data/lib/active_merchant/billing/gateways/samurai.rb +1 -4
  78. data/lib/active_merchant/billing/gateways/secure_net.rb +0 -1
  79. data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -8
  80. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -5
  81. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +17 -18
  82. data/lib/active_merchant/billing/gateways/skip_jack.rb +29 -34
  83. data/lib/active_merchant/billing/gateways/smart_ps.rb +55 -56
  84. data/lib/active_merchant/billing/gateways/stripe.rb +8 -3
  85. data/lib/active_merchant/billing/gateways/trans_first.rb +28 -29
  86. data/lib/active_merchant/billing/gateways/trust_commerce.rb +85 -87
  87. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +27 -28
  88. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +0 -5
  89. data/lib/active_merchant/billing/gateways/verifi.rb +86 -87
  90. data/lib/active_merchant/billing/gateways/viaklix.rb +42 -47
  91. data/lib/active_merchant/billing/gateways/vindicia.rb +30 -28
  92. data/lib/active_merchant/billing/gateways/webpay.rb +45 -0
  93. data/lib/active_merchant/billing/gateways/wirecard.rb +0 -6
  94. data/lib/active_merchant/billing/gateways/worldpay.rb +4 -9
  95. data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
  96. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
  97. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
  98. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
  99. data/lib/active_merchant/billing/integrations/liqpay.rb +30 -0
  100. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
  101. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
  102. data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -0
  103. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +17 -1
  104. data/lib/active_merchant/billing/integrations/notification.rb +4 -0
  105. data/lib/active_merchant/billing/integrations/pay_fast.rb +70 -0
  106. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +42 -0
  107. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
  108. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
  109. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -0
  110. data/lib/active_merchant/billing/integrations/paypal/notification.rb +64 -0
  111. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +10 -7
  112. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +12 -0
  113. data/lib/active_merchant/billing/response.rb +19 -4
  114. data/lib/active_merchant/version.rb +1 -1
  115. metadata +45 -27
  116. metadata.gz.sig +0 -0
@@ -6,24 +6,24 @@ module ActiveMerchant #:nodoc:
6
6
  self.test_url = 'https://demo.viaklix.com/process.asp'
7
7
  self.live_url = 'https://www.viaklix.com/process.asp'
8
8
  self.delimiter = "\r\n"
9
-
9
+
10
10
  self.actions = {
11
11
  :purchase => 'SALE',
12
12
  :credit => 'CREDIT'
13
13
  }
14
-
14
+
15
15
  APPROVED = '0'
16
-
16
+
17
17
  self.supported_cardtypes = [:visa, :master, :american_express, :discover]
18
18
  self.supported_countries = ['US']
19
19
  self.display_name = 'ViaKLIX'
20
20
  self.homepage_url = 'http://viaklix.com'
21
-
21
+
22
22
  # Initialize the Gateway
23
23
  #
24
24
  # The gateway requires that a valid login and password be passed
25
25
  # in the +options+ hash.
26
- #
26
+ #
27
27
  # ==== Options
28
28
  #
29
29
  # * <tt>:login</tt> -- Merchant ID
@@ -32,55 +32,54 @@ module ActiveMerchant #:nodoc:
32
32
  # * <tt>:test => +true+ or +false+</tt> -- Force test transactions
33
33
  def initialize(options = {})
34
34
  requires!(options, :login, :password)
35
- @options = options
36
35
  super
37
36
  end
38
-
39
- # Make a purchase
37
+
38
+ # Make a purchase
40
39
  def purchase(money, creditcard, options = {})
41
40
  form = {}
42
41
  add_invoice(form, options)
43
- add_creditcard(form, creditcard)
44
- add_address(form, options)
42
+ add_creditcard(form, creditcard)
43
+ add_address(form, options)
45
44
  add_customer_data(form, options)
46
45
  add_test_mode(form, options)
47
46
  commit(:purchase, money, form)
48
47
  end
49
-
48
+
50
49
  # Make a credit to a card (Void can only be done from the virtual terminal)
51
50
  # Viaklix does not support credits by reference. You must pass in the credit card
52
51
  def credit(money, creditcard, options = {})
53
52
  if creditcard.is_a?(String)
54
53
  raise ArgumentError, "Reference credits are not supported. Please supply the original credit card"
55
54
  end
56
-
55
+
57
56
  form = {}
58
57
  add_invoice(form, options)
59
- add_creditcard(form, creditcard)
60
- add_address(form, options)
58
+ add_creditcard(form, creditcard)
59
+ add_address(form, options)
61
60
  add_customer_data(form, options)
62
61
  add_test_mode(form, options)
63
62
  commit(:credit, money, form)
64
63
  end
65
-
64
+
66
65
  private
67
66
  def add_test_mode(form, options)
68
67
  form[:test_mode] = 'TRUE' if options[:test_mode]
69
68
  end
70
-
69
+
71
70
  def add_customer_data(form, options)
72
71
  form[:email] = options[:email].to_s.slice(0, 100) unless options[:email].blank?
73
72
  form[:customer_code] = options[:customer].to_s.slice(0, 10) unless options[:customer].blank?
74
73
  end
75
-
74
+
76
75
  def add_invoice(form,options)
77
76
  form[:invoice_number] = (options[:order_id] || options[:invoice]).to_s.slice(0, 10)
78
77
  form[:description] = options[:description].to_s.slice(0, 255)
79
78
  end
80
-
79
+
81
80
  def add_address(form,options)
82
- billing_address = options[:billing_address] || options[:address]
83
-
81
+ billing_address = options[:billing_address] || options[:address]
82
+
84
83
  if billing_address
85
84
  form[:avs_address] = billing_address[:address1].to_s.slice(0, 30)
86
85
  form[:address2] = billing_address[:address2].to_s.slice(0, 30)
@@ -91,7 +90,7 @@ module ActiveMerchant #:nodoc:
91
90
  form[:phone] = billing_address[:phone].to_s.slice(0, 20)
92
91
  form[:country] = billing_address[:country].to_s.slice(0, 50)
93
92
  end
94
-
93
+
95
94
  if shipping_address = options[:shipping_address]
96
95
  first_name, last_name = parse_first_and_last_name(shipping_address[:name])
97
96
  form[:ship_to_first_name] = first_name.to_s.slice(0, 20)
@@ -104,82 +103,78 @@ module ActiveMerchant #:nodoc:
104
103
  form[:ship_to_zip] = shipping_address[:zip].to_s.slice(0, 10)
105
104
  end
106
105
  end
107
-
106
+
108
107
  def parse_first_and_last_name(value)
109
108
  name = value.to_s.split(' ')
110
-
109
+
111
110
  last_name = name.pop || ''
112
111
  first_name = name.join(' ')
113
- [ first_name, last_name ]
112
+ [ first_name, last_name ]
114
113
  end
115
-
114
+
116
115
  def add_creditcard(form, creditcard)
117
116
  form[:card_number] = creditcard.number
118
117
  form[:exp_date] = expdate(creditcard)
119
-
118
+
120
119
  if creditcard.verification_value?
121
120
  add_verification_value(form, creditcard)
122
121
  end
123
-
122
+
124
123
  form[:first_name] = creditcard.first_name.to_s.slice(0, 20)
125
124
  form[:last_name] = creditcard.last_name.to_s.slice(0, 30)
126
125
  end
127
-
126
+
128
127
  def add_verification_value(form, creditcard)
129
- form[:cvv2cvc2] = creditcard.verification_value
128
+ form[:cvv2cvc2] = creditcard.verification_value
130
129
  form[:cvv2] = 'present'
131
130
  end
132
-
131
+
133
132
  def preamble
134
133
  result = {
135
134
  'merchant_id' => @options[:login],
136
135
  'pin' => @options[:password],
137
136
  'show_form' => 'false',
138
- 'result_format' => 'ASCII'
137
+ 'result_format' => 'ASCII'
139
138
  }
140
-
139
+
141
140
  result['user_id'] = @options[:user] unless @options[:user].blank?
142
141
  result
143
142
  end
144
-
145
- def test?
146
- @options[:test] || super
147
- end
148
-
143
+
149
144
  def commit(action, money, parameters)
150
145
  parameters[:amount] = amount(money)
151
146
  parameters[:transaction_type] = self.actions[action]
152
-
147
+
153
148
  response = parse( ssl_post(test? ? self.test_url : self.live_url, post_data(parameters)) )
154
149
 
155
- Response.new(response['result'] == APPROVED, message_from(response), response,
156
- :test => @options[:test] || test?,
150
+ Response.new(response['result'] == APPROVED, message_from(response), response,
151
+ :test => @options[:test] || test?,
157
152
  :authorization => authorization_from(response),
158
153
  :avs_result => { :code => response['avs_response'] },
159
154
  :cvv_result => response['cvv2_response']
160
155
  )
161
156
  end
162
-
157
+
163
158
  def authorization_from(response)
164
159
  response['txn_id']
165
160
  end
166
-
161
+
167
162
  def message_from(response)
168
163
  response['result_message']
169
164
  end
170
-
165
+
171
166
  def post_data(parameters)
172
167
  result = preamble
173
- result.merge!(parameters)
168
+ result.merge!(parameters)
174
169
  result.collect { |key, value| "ssl_#{key}=#{CGI.escape(value.to_s)}" }.join("&")
175
170
  end
176
-
171
+
177
172
  def expdate(creditcard)
178
173
  year = sprintf("%.4i", creditcard.year)
179
174
  month = sprintf("%.2i", creditcard.month)
180
175
  "#{month}#{year[2..3]}"
181
176
  end
182
-
177
+
183
178
  # Parse the response message
184
179
  def parse(msg)
185
180
  resp = {}
@@ -191,4 +186,4 @@ module ActiveMerchant #:nodoc:
191
186
  end
192
187
  end
193
188
  end
194
- end
189
+ end
@@ -4,12 +4,14 @@ rescue LoadError
4
4
  raise "Could not load the vindicia-api gem. Use `gem install vindicia-api` to install it."
5
5
  end
6
6
 
7
+ require 'i18n/core_ext/string/interpolate'
8
+
7
9
  module ActiveMerchant #:nodoc:
8
10
  module Billing #:nodoc:
9
11
 
10
12
  # For more information on the Vindicia Gateway please visit their {website}[http://vindicia.com/]
11
13
  #
12
- # The login and password are not the username and password you use to
14
+ # The login and password are not the username and password you use to
13
15
  # login to the Vindicia Merchant Portal.
14
16
  #
15
17
  # ==== Recurring Billing
@@ -25,8 +27,8 @@ module ActiveMerchant #:nodoc:
25
27
 
26
28
  class_attribute :test_url, :live_url
27
29
 
28
- self.test_url = "https://soap.prodtest.sj.vindicia.com/soap.pl"
29
- self.live_url = "http://soap.vindicia.com/soap.pl"
30
+ self.test_url = "https://soap.prodtest.sj.vindicia.com/soap.pl"
31
+ self.live_url = "http://soap.vindicia.com/soap.pl"
30
32
 
31
33
  # Creates a new VindiciaGateway
32
34
  #
@@ -40,24 +42,25 @@ module ActiveMerchant #:nodoc:
40
42
  # * <tt>:api_version</tt> -- Vindicia API Version - defaults to 3.6 (OPTIONAL)
41
43
  # * <tt>:account_id</tt> -- Account Id which all transactions will be run against. (REQUIRED)
42
44
  # * <tt>:transaction_prefix</tt> -- Prefix to order id for one-time transactions - defaults to 'X' (OPTIONAL
43
- # * <tt>:min_chargeback_probability</tt> -- Minimum score for chargebacks - defaults to 65 (OPTIONAL)
45
+ # * <tt>:min_chargeback_probability</tt> -- Minimum score for chargebacks - defaults to 65 (OPTIONAL)
44
46
  # * <tt>:cvn_success</tt> -- Array of valid CVN Check return values - defaults to [M, P] (OPTIONAL)
45
47
  # * <tt>:avs_success</tt> -- Array of valid AVS Check return values - defaults to [X, Y, A, W, Z] (OPTIONAL)
46
48
  def initialize(options = {})
47
49
  requires!(options, :login, :password)
50
+ super
48
51
 
49
52
  config = lambda do |config|
50
- config.login = options[:login]
51
- config.password = options[:password]
53
+ config.login = options[:login]
54
+ config.password = options[:password]
52
55
  config.api_version = options[:api_version] || "3.6"
53
- config.endpoint = test? ? self.test_url : self.live_url
56
+ config.endpoint = test? ? self.test_url : self.live_url
54
57
  config.namespace = "http://soap.vindicia.com"
55
58
  end
56
59
 
57
- if Vindicia.config.is_configured?
60
+ if Vindicia.config.is_configured?
58
61
  config.call(Vindicia.config)
59
62
  else
60
- Vindicia.configure(&config)
63
+ Vindicia.configure(&config)
61
64
  end
62
65
 
63
66
  requires!(options, :account_id)
@@ -66,10 +69,9 @@ module ActiveMerchant #:nodoc:
66
69
  @transaction_prefix = options[:transaction_prefix] || "X"
67
70
 
68
71
  @min_chargeback_probability = options[:min_chargeback_probability] || 65
69
- @cvn_success = options[:cvn_success] || %w{M P}
72
+ @cvn_success = options[:cvn_success] || %w{M P}
70
73
  @avs_success = options[:avs_success] || %w{X Y A W Z}
71
74
 
72
- @options = options
73
75
  @allowed_authorization_statuses = %w{Authorized}
74
76
  end
75
77
 
@@ -103,7 +105,7 @@ module ActiveMerchant #:nodoc:
103
105
  if !response.success? && response.fraud_review? && !response.authorization.blank?
104
106
  void_response = void([vindicia_transaction[:transaction][:merchantTransactionId]], options)
105
107
  if void_response.success?
106
- return response
108
+ return response
107
109
  else
108
110
  return void_response
109
111
  end
@@ -142,10 +144,10 @@ module ActiveMerchant #:nodoc:
142
144
  :account => { :merchantAccountId => @account_id },
143
145
  :merchantTransactionId => identification,
144
146
  :sourceIp => options[:ip]
145
- }]
147
+ }]
146
148
  }))
147
149
 
148
- if response[:return][:returnCode] == '200' && response[:qtyFail].to_i == 0
150
+ if response[:return][:returnCode] == '200' && response[:qtyFail].to_i == 0
149
151
  success(response, identification)
150
152
  else
151
153
  fail(response)
@@ -204,22 +206,22 @@ module ActiveMerchant #:nodoc:
204
206
 
205
207
  def check_transaction(vindicia_transaction)
206
208
  if vindicia_transaction[:return][:returnCode] == '200'
207
- status_log = vindicia_transaction[:transaction][:statusLog].first
209
+ status_log = vindicia_transaction[:transaction][:statusLog].first
208
210
  if status_log[:creditCardStatus]
209
211
  avs = status_log[:creditCardStatus][:avsCode]
210
212
  cvn = status_log[:creditCardStatus][:cvnCode]
211
213
  end
212
214
 
213
- if @allowed_authorization_statuses.include?(status_log[:status]) &&
215
+ if @allowed_authorization_statuses.include?(status_log[:status]) &&
214
216
  check_cvn(cvn) && check_avs(avs)
215
217
 
216
- success(vindicia_transaction,
217
- vindicia_transaction[:transaction][:merchantTransactionId],
218
+ success(vindicia_transaction,
219
+ vindicia_transaction[:transaction][:merchantTransactionId],
218
220
  avs, cvn)
219
221
  else
220
222
  # If the transaction is authorized, but it didn't pass our AVS/CVV checks send the authorization along so
221
223
  # that is gets voided. Otherwise, send no authorization.
222
- fail(vindicia_transaction, avs, cvn, false,
224
+ fail(vindicia_transaction, avs, cvn, false,
223
225
  @allowed_authorization_statuses.include?(status_log[:status]) ? vindicia_transaction[:transaction][:merchantTransactionId] : "")
224
226
  end
225
227
  else
@@ -238,9 +240,9 @@ module ActiveMerchant #:nodoc:
238
240
  add_customer_data(parameters, options)
239
241
  add_payment_source(parameters, creditcard, options)
240
242
 
241
- post(Vindicia::Transaction.auth({
242
- :transaction => parameters,
243
- :minChargebackProbability => @min_chargeback_probability
243
+ post(Vindicia::Transaction.auth({
244
+ :transaction => parameters,
245
+ :minChargebackProbability => @min_chargeback_probability
244
246
  }))
245
247
  end
246
248
 
@@ -281,8 +283,8 @@ module ActiveMerchant #:nodoc:
281
283
  add_subscription_information(parameters, options)
282
284
 
283
285
  post(Vindicia::AutoBill.update({
284
- :autobill => parameters,
285
- :validatePaymentMethod => false,
286
+ :autobill => parameters,
287
+ :validatePaymentMethod => false,
286
288
  :minChargebackProbability => 100
287
289
  }))
288
290
  end
@@ -290,8 +292,8 @@ module ActiveMerchant #:nodoc:
290
292
  def check_subscription(vindicia_transaction)
291
293
  if vindicia_transaction[:return][:returnCode] == '200'
292
294
  if vindicia_transaction[:autobill] && vindicia_transaction[:autobill][:status] == "Active"
293
- success(vindicia_transaction,
294
- vindicia_transaction[:autobill][:merchantAutoBillId])
295
+ success(vindicia_transaction,
296
+ vindicia_transaction[:autobill][:merchantAutoBillId])
295
297
  else
296
298
  fail(vindicia_transaction)
297
299
  end
@@ -326,8 +328,8 @@ module ActiveMerchant #:nodoc:
326
328
  end
327
329
 
328
330
  def fail(response, avs_code = nil, cvn_code = nil, fraud_review = false, authorization = "")
329
- ActiveMerchant::Billing::Response.new(false, response[:return][:returnString], response,
330
- { :fraud_review => fraud_review || !authorization.blank?,
331
+ ActiveMerchant::Billing::Response.new(false, response[:return][:returnString], response,
332
+ { :fraud_review => fraud_review || !authorization.blank?,
331
333
  :authorization => authorization, :test => test?,
332
334
  :avs_result => { :code => avs_code }, :cvv_result => cvn_code })
333
335
 
@@ -0,0 +1,45 @@
1
+ require 'json'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ class WebpayGateway < StripeGateway
6
+ self.live_url = 'https://api.webpay.jp/v1/'
7
+
8
+ self.supported_countries = ['JP']
9
+ self.default_currency = 'JPY'
10
+ self.money_format = :cents
11
+ self.supported_cardtypes = [:visa, :master, :american_express, :jcb, :diners_club]
12
+
13
+ self.homepage_url = 'https://webpay.jp/'
14
+ self.display_name = 'WebPay'
15
+
16
+ def json_error(raw_response)
17
+ msg = 'Invalid response received from the WebPay API. Please contact support@webpay.jp if you continue to receive this message.'
18
+ msg += " (The raw response returned by the API was #{raw_response.inspect})"
19
+ {
20
+ "error" => {
21
+ "message" => msg
22
+ }
23
+ }
24
+ end
25
+
26
+ def headers(meta={})
27
+ @@ua ||= JSON.dump({
28
+ :bindings_version => ActiveMerchant::VERSION,
29
+ :lang => 'ruby',
30
+ :lang_version => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
31
+ :platform => RUBY_PLATFORM,
32
+ :publisher => 'active_merchant',
33
+ :uname => (RUBY_PLATFORM =~ /linux|darwin/i ? `uname -a 2>/dev/null`.strip : nil)
34
+ })
35
+
36
+ {
37
+ "Authorization" => "Basic " + Base64.encode64(@api_key.to_s + ":").strip,
38
+ "User-Agent" => "Webpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
39
+ "X-Webpay-Client-User-Agent" => @@ua,
40
+ "X-Webpay-Client-User-Metadata" => meta.to_json
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -57,15 +57,9 @@ module ActiveMerchant #:nodoc:
57
57
  requires!(options, :login, :password)
58
58
  # unfortunately Wirecard also requires a BusinessCaseSignature in the XML request
59
59
  requires!(options, :signature)
60
- @options = options
61
60
  super
62
61
  end
63
62
 
64
- # Should run against the test servers or not?
65
- def test?
66
- @options[:test] || super
67
- end
68
-
69
63
  # Authorization
70
64
  def authorize(money, creditcard, options = {})
71
65
  options[:credit_card] = creditcard
@@ -20,12 +20,11 @@ module ActiveMerchant #:nodoc:
20
20
 
21
21
  def initialize(options = {})
22
22
  requires!(options, :login, :password)
23
- @options = options
24
23
  super
25
24
  end
26
25
 
27
26
  def purchase(money, payment_method, options = {})
28
- MultiResponse.new.tap do |r|
27
+ MultiResponse.run do |r|
29
28
  r.process{authorize(money, payment_method, options)}
30
29
  r.process{capture(money, r.authorization, options.merge(:authorization_validated => true))}
31
30
  end
@@ -37,30 +36,26 @@ module ActiveMerchant #:nodoc:
37
36
  end
38
37
 
39
38
  def capture(money, authorization, options = {})
40
- MultiResponse.new.tap do |r|
39
+ MultiResponse.run do |r|
41
40
  r.process{inquire_request(authorization, options, "AUTHORISED")} unless options[:authorization_validated]
42
41
  r.process{capture_request(money, authorization, options)}
43
42
  end
44
43
  end
45
44
 
46
45
  def void(authorization, options = {})
47
- MultiResponse.new.tap do |r|
46
+ MultiResponse.run do |r|
48
47
  r.process{inquire_request(authorization, options, "AUTHORISED")}
49
48
  r.process{cancel_request(authorization, options)}
50
49
  end
51
50
  end
52
51
 
53
52
  def refund(money, authorization, options = {})
54
- MultiResponse.new.tap do |r|
53
+ MultiResponse.run do |r|
55
54
  r.process{inquire_request(authorization, options, "CAPTURED")}
56
55
  r.process{refund_request(money, authorization, options)}
57
56
  end
58
57
  end
59
58
 
60
- def test?
61
- @options[:test] || super
62
- end
63
-
64
59
  private
65
60
 
66
61
  def authorize_request(money, payment_method, options)