activemerchant 1.123.0 → 1.126.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +206 -0
- data/lib/active_merchant/billing/check.rb +5 -8
- data/lib/active_merchant/billing/credit_card.rb +10 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +18 -3
- data/lib/active_merchant/billing/gateway.rb +3 -2
- data/lib/active_merchant/billing/gateways/adyen.rb +66 -11
- data/lib/active_merchant/billing/gateways/airwallex.rb +341 -0
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +2 -1
- data/lib/active_merchant/billing/gateways/blue_pay.rb +1 -1
- data/lib/active_merchant/billing/gateways/blue_snap.rb +31 -21
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +6 -1
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +87 -15
- data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
- data/lib/active_merchant/billing/gateways/card_stream.rb +17 -13
- data/lib/active_merchant/billing/gateways/cashnet.rb +15 -5
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +34 -5
- data/lib/active_merchant/billing/gateways/credorax.rb +10 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +24 -36
- data/lib/active_merchant/billing/gateways/d_local.rb +61 -6
- data/lib/active_merchant/billing/gateways/decidir.rb +17 -1
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +19 -3
- data/lib/active_merchant/billing/gateways/elavon.rb +6 -3
- data/lib/active_merchant/billing/gateways/element.rb +20 -2
- data/lib/active_merchant/billing/gateways/global_collect.rb +137 -32
- data/lib/active_merchant/billing/gateways/ipg.rb +415 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +7 -0
- data/lib/active_merchant/billing/gateways/litle.rb +93 -1
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +3 -1
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/moka.rb +24 -11
- data/lib/active_merchant/billing/gateways/moneris.rb +35 -8
- data/lib/active_merchant/billing/gateways/mundipagg.rb +8 -6
- data/lib/active_merchant/billing/gateways/nmi.rb +27 -8
- data/lib/active_merchant/billing/gateways/orbital.rb +357 -319
- data/lib/active_merchant/billing/gateways/pay_arc.rb +9 -7
- data/lib/active_merchant/billing/gateways/pay_conex.rb +3 -1
- data/lib/active_merchant/billing/gateways/pay_trace.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +76 -6
- data/lib/active_merchant/billing/gateways/paymentez.rb +35 -9
- data/lib/active_merchant/billing/gateways/paysafe.rb +155 -34
- data/lib/active_merchant/billing/gateways/payu_latam.rb +31 -16
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +3 -3
- data/lib/active_merchant/billing/gateways/pin.rb +31 -4
- data/lib/active_merchant/billing/gateways/priority.rb +369 -0
- data/lib/active_merchant/billing/gateways/rapyd.rb +258 -0
- data/lib/active_merchant/billing/gateways/realex.rb +18 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +7 -6
- data/lib/active_merchant/billing/gateways/simetrik.rb +362 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +30 -8
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +175 -72
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +2 -1
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +2 -1
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +20 -6
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +6 -2
- data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +196 -64
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
- data/lib/active_merchant/billing/response.rb +4 -0
- data/lib/active_merchant/version.rb +1 -1
- metadata +11 -2
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_merchant/billing/gateways/braintree/braintree_common'
|
2
|
+
require 'active_merchant/billing/gateways/braintree/token_nonce'
|
2
3
|
require 'active_support/core_ext/array/extract_options'
|
3
4
|
|
4
5
|
begin
|
@@ -46,6 +47,8 @@ module ActiveMerchant #:nodoc:
|
|
46
47
|
cannot_refund_if_unsettled: 91506
|
47
48
|
}
|
48
49
|
|
50
|
+
DIRECT_BANK_ERROR = 'Direct bank account transactions are not supported. Bank accounts must be successfully stored before use.'.freeze
|
51
|
+
|
49
52
|
def initialize(options = {})
|
50
53
|
requires!(options, :merchant_id, :public_key, :private_key)
|
51
54
|
@merchant_account_id = options[:merchant_account_id]
|
@@ -73,6 +76,8 @@ module ActiveMerchant #:nodoc:
|
|
73
76
|
end
|
74
77
|
|
75
78
|
def authorize(money, credit_card_or_vault_id, options = {})
|
79
|
+
return Response.new(false, DIRECT_BANK_ERROR) if credit_card_or_vault_id.is_a? Check
|
80
|
+
|
76
81
|
create_transaction(:sale, money, credit_card_or_vault_id, options)
|
77
82
|
end
|
78
83
|
|
@@ -148,21 +153,13 @@ module ActiveMerchant #:nodoc:
|
|
148
153
|
end
|
149
154
|
end
|
150
155
|
|
151
|
-
def store(
|
152
|
-
if options
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
add_credit_card_to_customer(creditcard, options)
|
159
|
-
else
|
160
|
-
add_customer_with_credit_card(creditcard, options)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
else
|
165
|
-
add_customer_with_credit_card(creditcard, options)
|
156
|
+
def store(payment_method, options = {})
|
157
|
+
return Response.new(false, bank_account_errors(payment_method, options)) if payment_method.is_a?(Check) && bank_account_errors(payment_method, options).present?
|
158
|
+
|
159
|
+
MultiResponse.run do |r|
|
160
|
+
r.process { check_customer_exists(options[:customer]) }
|
161
|
+
process_by = payment_method.is_a?(Check) ? :store_bank_account : :store_credit_card
|
162
|
+
send process_by, payment_method, options, r
|
166
163
|
end
|
167
164
|
end
|
168
165
|
|
@@ -227,6 +224,8 @@ module ActiveMerchant #:nodoc:
|
|
227
224
|
private
|
228
225
|
|
229
226
|
def check_customer_exists(customer_vault_id)
|
227
|
+
return Response.new true, 'Customer not found', { exists: false } if customer_vault_id.blank?
|
228
|
+
|
230
229
|
commit do
|
231
230
|
@braintree_gateway.customer.find(customer_vault_id)
|
232
231
|
ActiveMerchant::Billing::Response.new(true, 'Customer found', { exists: true }, authorization: customer_vault_id)
|
@@ -827,6 +826,79 @@ module ActiveMerchant #:nodoc:
|
|
827
826
|
end
|
828
827
|
end
|
829
828
|
end
|
829
|
+
|
830
|
+
def bank_account_errors(payment_method, options)
|
831
|
+
if payment_method.validate.present?
|
832
|
+
payment_method.validate
|
833
|
+
elsif options[:billing_address].blank?
|
834
|
+
'billing_address is required parameter to store and verify Bank accounts.'
|
835
|
+
elsif options[:ach_mandate].blank?
|
836
|
+
'ach_mandate is a required parameter to process bank acccount transactions see (https://developer.paypal.com/braintree/docs/guides/ach/client-side#show-required-authorization-language)'
|
837
|
+
end
|
838
|
+
end
|
839
|
+
|
840
|
+
def add_bank_account_to_customer(payment_method, options)
|
841
|
+
bank_account_nonce, error_message = TokenNonce.new(@braintree_gateway, options).create_token_nonce_for_payment_method payment_method
|
842
|
+
return Response.new(false, error_message) unless bank_account_nonce.present?
|
843
|
+
|
844
|
+
result = @braintree_gateway.payment_method.create(
|
845
|
+
customer_id: options[:customer],
|
846
|
+
payment_method_nonce: bank_account_nonce,
|
847
|
+
options: {
|
848
|
+
us_bank_account_verification_method: 'network_check'
|
849
|
+
}
|
850
|
+
)
|
851
|
+
|
852
|
+
verified = result.success? && result.payment_method&.verified
|
853
|
+
message = message_from_result(result)
|
854
|
+
message = not_verified_reason(result.payment_method) unless verified
|
855
|
+
|
856
|
+
Response.new(verified, message,
|
857
|
+
{
|
858
|
+
customer_vault_id: options[:customer],
|
859
|
+
bank_account_token: result.payment_method&.token,
|
860
|
+
verified: verified
|
861
|
+
},
|
862
|
+
authorization: result.payment_method&.token)
|
863
|
+
end
|
864
|
+
|
865
|
+
def not_verified_reason(bank_account)
|
866
|
+
return unless bank_account.verifications.present?
|
867
|
+
|
868
|
+
verification = bank_account.verifications.first
|
869
|
+
"verification_status: [#{verification.status}], processor_response: [#{verification.processor_response_code}-#{verification.processor_response_text}]"
|
870
|
+
end
|
871
|
+
|
872
|
+
def store_bank_account(payment_method, options, multi_response)
|
873
|
+
multi_response.process { create_customer_from_bank_account payment_method, options } unless multi_response.params['exists']
|
874
|
+
multi_response.process { add_bank_account_to_customer payment_method, options }
|
875
|
+
end
|
876
|
+
|
877
|
+
def store_credit_card(payment_method, options, multi_response)
|
878
|
+
process_by = multi_response.params['exists'] ? :add_credit_card_to_customer : :add_customer_with_credit_card
|
879
|
+
multi_response.process { send process_by, payment_method, options }
|
880
|
+
end
|
881
|
+
|
882
|
+
def create_customer_from_bank_account(payment_method, options)
|
883
|
+
parameters = {
|
884
|
+
id: options[:customer],
|
885
|
+
first_name: payment_method.first_name,
|
886
|
+
last_name: payment_method.last_name,
|
887
|
+
email: scrub_email(options[:email]),
|
888
|
+
phone: options[:phone] || options.dig(:billing_address, :phone),
|
889
|
+
device_data: options[:device_data]
|
890
|
+
}.compact
|
891
|
+
|
892
|
+
result = @braintree_gateway.customer.create(parameters)
|
893
|
+
customer_id = result.customer.id if result.success?
|
894
|
+
options[:customer] = customer_id
|
895
|
+
|
896
|
+
Response.new(
|
897
|
+
result.success?,
|
898
|
+
message_from_result(result),
|
899
|
+
{ customer_vault_id: customer_id, 'exists': true }
|
900
|
+
)
|
901
|
+
end
|
830
902
|
end
|
831
903
|
end
|
832
904
|
end
|
@@ -169,7 +169,7 @@ module ActiveMerchant #:nodoc:
|
|
169
169
|
def add_address(post, options)
|
170
170
|
if address = options[:billing_address] || options[:address]
|
171
171
|
post[:address] = address[:address1] if address[:address1]
|
172
|
-
post[:
|
172
|
+
post[:address2] = address[:address2] if address[:address2]
|
173
173
|
post[:city] = address[:city] if address[:city]
|
174
174
|
post[:region] = address[:state] if address[:state]
|
175
175
|
post[:country] = address[:country] if address[:country]
|
@@ -150,23 +150,13 @@ module ActiveMerchant #:nodoc:
|
|
150
150
|
|
151
151
|
def authorize(money, credit_card_or_reference, options = {})
|
152
152
|
post = {}
|
153
|
-
|
154
|
-
add_amount(post, money, options)
|
155
|
-
add_invoice(post, credit_card_or_reference, money, options)
|
156
|
-
add_credit_card_or_reference(post, credit_card_or_reference)
|
157
|
-
add_customer_data(post, options)
|
158
|
-
add_remote_address(post, options)
|
153
|
+
add_auth_purchase(post, -1, money, credit_card_or_reference, options)
|
159
154
|
commit('SALE', post)
|
160
155
|
end
|
161
156
|
|
162
157
|
def purchase(money, credit_card_or_reference, options = {})
|
163
158
|
post = {}
|
164
|
-
|
165
|
-
add_amount(post, money, options)
|
166
|
-
add_invoice(post, credit_card_or_reference, money, options)
|
167
|
-
add_credit_card_or_reference(post, credit_card_or_reference)
|
168
|
-
add_customer_data(post, options)
|
169
|
-
add_remote_address(post, options)
|
159
|
+
add_auth_purchase(post, 0, money, credit_card_or_reference, options)
|
170
160
|
commit('SALE', post)
|
171
161
|
end
|
172
162
|
|
@@ -184,6 +174,7 @@ module ActiveMerchant #:nodoc:
|
|
184
174
|
add_pair(post, :xref, authorization)
|
185
175
|
add_amount(post, money, options)
|
186
176
|
add_remote_address(post, options)
|
177
|
+
add_country_code(post, options)
|
187
178
|
response = commit('REFUND_SALE', post)
|
188
179
|
|
189
180
|
return response if response.success?
|
@@ -223,6 +214,16 @@ module ActiveMerchant #:nodoc:
|
|
223
214
|
|
224
215
|
private
|
225
216
|
|
217
|
+
def add_auth_purchase(post, pair_value, money, credit_card_or_reference, options)
|
218
|
+
add_pair(post, :captureDelay, pair_value)
|
219
|
+
add_amount(post, money, options)
|
220
|
+
add_invoice(post, credit_card_or_reference, money, options)
|
221
|
+
add_credit_card_or_reference(post, credit_card_or_reference)
|
222
|
+
add_customer_data(post, options)
|
223
|
+
add_remote_address(post, options)
|
224
|
+
add_country_code(post, options)
|
225
|
+
end
|
226
|
+
|
226
227
|
def add_amount(post, money, options)
|
227
228
|
currency = options[:currency] || currency(money)
|
228
229
|
add_pair(post, :amount, localized_amount(money, currency), required: true)
|
@@ -286,6 +287,10 @@ module ActiveMerchant #:nodoc:
|
|
286
287
|
add_pair(post, :remoteAddress, options[:ip] || '1.1.1.1')
|
287
288
|
end
|
288
289
|
|
290
|
+
def add_country_code(post, options)
|
291
|
+
post[:countryCode] = options[:country_code] || self.supported_countries[0]
|
292
|
+
end
|
293
|
+
|
289
294
|
def normalize_line_endings(str)
|
290
295
|
str.gsub(/%0D%0A|%0A%0D|%0D/, '%0A')
|
291
296
|
end
|
@@ -309,7 +314,6 @@ module ActiveMerchant #:nodoc:
|
|
309
314
|
end
|
310
315
|
|
311
316
|
def commit(action, parameters)
|
312
|
-
parameters.update(countryCode: self.supported_countries[0]) unless %w[CAPTURE CANCEL].include?(action)
|
313
317
|
parameters.update(
|
314
318
|
merchantID: @options[:login],
|
315
319
|
action: action
|
@@ -41,7 +41,7 @@ module ActiveMerchant #:nodoc:
|
|
41
41
|
def purchase(money, payment_object, options = {})
|
42
42
|
post = {}
|
43
43
|
add_creditcard(post, payment_object)
|
44
|
-
add_invoice(post, options)
|
44
|
+
add_invoice(post, money, options)
|
45
45
|
add_address(post, options)
|
46
46
|
add_customer_data(post, options)
|
47
47
|
commit('SALE', money, post)
|
@@ -50,7 +50,7 @@ module ActiveMerchant #:nodoc:
|
|
50
50
|
def refund(money, identification, options = {})
|
51
51
|
post = {}
|
52
52
|
post[:origtx] = identification
|
53
|
-
add_invoice(post, options)
|
53
|
+
add_invoice(post, money, options)
|
54
54
|
add_customer_data(post, options)
|
55
55
|
commit('REFUND', money, post)
|
56
56
|
end
|
@@ -69,7 +69,6 @@ module ActiveMerchant #:nodoc:
|
|
69
69
|
private
|
70
70
|
|
71
71
|
def commit(action, money, fields)
|
72
|
-
fields[:amount] = amount(money)
|
73
72
|
url = (test? ? test_url : live_url) + CGI.escape(@options[:merchant_gateway_name])
|
74
73
|
raw_response = ssl_post(url, post_data(action, fields))
|
75
74
|
parsed_response = parse(raw_response)
|
@@ -92,6 +91,7 @@ module ActiveMerchant #:nodoc:
|
|
92
91
|
|
93
92
|
def post_data(action, parameters = {})
|
94
93
|
post = {}
|
94
|
+
|
95
95
|
post[:command] = action
|
96
96
|
post[:merchant] = @options[:merchant]
|
97
97
|
post[:operator] = @options[:operator]
|
@@ -110,9 +110,19 @@ module ActiveMerchant #:nodoc:
|
|
110
110
|
post[:lname] = creditcard.last_name
|
111
111
|
end
|
112
112
|
|
113
|
-
def add_invoice(post, options)
|
113
|
+
def add_invoice(post, money, options)
|
114
114
|
post[:order_number] = options[:order_id] if options[:order_id].present?
|
115
|
-
|
115
|
+
|
116
|
+
if options[:item_codes].present?
|
117
|
+
codes_and_amounts = options[:item_codes].transform_keys { |key| key.to_s.delete('_') }
|
118
|
+
codes_and_amounts.each do |key, value|
|
119
|
+
post[key] = value if key.start_with?('itemcode')
|
120
|
+
post[key] = amount(value.to_i) if key.start_with?('amount')
|
121
|
+
end
|
122
|
+
else
|
123
|
+
post[:itemcode] = (options[:item_code] || @options[:default_item_code])
|
124
|
+
post[:amount] = amount(money.to_i)
|
125
|
+
end
|
116
126
|
end
|
117
127
|
|
118
128
|
def add_address(post, options)
|
@@ -87,6 +87,8 @@ module ActiveMerchant #:nodoc:
|
|
87
87
|
add_transaction_data(post, options)
|
88
88
|
add_3ds(post, options)
|
89
89
|
add_metadata(post, options)
|
90
|
+
add_processing_channel(post, options)
|
91
|
+
add_marketplace_data(post, options)
|
90
92
|
end
|
91
93
|
|
92
94
|
def add_invoice(post, money, options)
|
@@ -109,12 +111,17 @@ module ActiveMerchant #:nodoc:
|
|
109
111
|
|
110
112
|
def add_payment_method(post, payment_method, options)
|
111
113
|
post[:source] = {}
|
112
|
-
if payment_method.is_a?(NetworkTokenizationCreditCard)
|
114
|
+
if payment_method.is_a?(NetworkTokenizationCreditCard)
|
115
|
+
token_type = token_type_from(payment_method)
|
116
|
+
cryptogram = payment_method.payment_cryptogram
|
117
|
+
eci = payment_method.eci || options[:eci]
|
118
|
+
eci ||= '05' if token_type == 'vts'
|
119
|
+
|
113
120
|
post[:source][:type] = 'network_token'
|
114
121
|
post[:source][:token] = payment_method.number
|
115
|
-
post[:source][:token_type] =
|
116
|
-
post[:source][:cryptogram] =
|
117
|
-
post[:source][:eci] =
|
122
|
+
post[:source][:token_type] = token_type
|
123
|
+
post[:source][:cryptogram] = cryptogram if cryptogram
|
124
|
+
post[:source][:eci] = eci if eci
|
118
125
|
else
|
119
126
|
post[:source][:type] = 'card'
|
120
127
|
post[:source][:name] = payment_method.name
|
@@ -162,7 +169,7 @@ module ActiveMerchant #:nodoc:
|
|
162
169
|
end
|
163
170
|
|
164
171
|
case options[:stored_credential][:reason_type]
|
165
|
-
when 'recurring'
|
172
|
+
when 'recurring', 'installment'
|
166
173
|
post[:payment_type] = 'Recurring'
|
167
174
|
when 'unscheduled'
|
168
175
|
return
|
@@ -186,6 +193,17 @@ module ActiveMerchant #:nodoc:
|
|
186
193
|
end
|
187
194
|
end
|
188
195
|
|
196
|
+
def add_processing_channel(post, options)
|
197
|
+
post[:processing_channel_id] = options[:processing_channel_id] if options[:processing_channel_id]
|
198
|
+
end
|
199
|
+
|
200
|
+
def add_marketplace_data(post, options)
|
201
|
+
if options[:marketplace]
|
202
|
+
post[:marketplace] = {}
|
203
|
+
post[:marketplace][:sub_entity_id] = options[:marketplace][:sub_entity_id] if options[:marketplace][:sub_entity_id]
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
189
207
|
def commit(action, post, authorization = nil)
|
190
208
|
begin
|
191
209
|
raw_response = (action == :verify_payment ? ssl_get("#{base_url}/payments/#{post}", headers) : ssl_post(url(post, action, authorization), post.to_json, headers))
|
@@ -306,6 +324,17 @@ module ActiveMerchant #:nodoc:
|
|
306
324
|
STANDARD_ERROR_CODE_MAPPING[response['response_code']]
|
307
325
|
end
|
308
326
|
end
|
327
|
+
|
328
|
+
def token_type_from(payment_method)
|
329
|
+
case payment_method.source
|
330
|
+
when :network_token
|
331
|
+
payment_method.brand == 'visa' ? 'vts' : 'mdes'
|
332
|
+
when :google_pay, :android_pay
|
333
|
+
'googlepay'
|
334
|
+
when :apple_pay
|
335
|
+
'applepay'
|
336
|
+
end
|
337
|
+
end
|
309
338
|
end
|
310
339
|
end
|
311
340
|
end
|
@@ -193,6 +193,7 @@ module ActiveMerchant #:nodoc:
|
|
193
193
|
add_submerchant_id(post, options)
|
194
194
|
add_processor(post, options)
|
195
195
|
add_email(post, options)
|
196
|
+
add_recipient(post, options)
|
196
197
|
|
197
198
|
if options[:referral_cft]
|
198
199
|
add_customer_name(post, options)
|
@@ -320,6 +321,15 @@ module ActiveMerchant #:nodoc:
|
|
320
321
|
post[:c3] = options[:email] || 'unspecified@example.com'
|
321
322
|
end
|
322
323
|
|
324
|
+
def add_recipient(post, options)
|
325
|
+
return unless options[:recipient_street_address] || options[:recipient_city] || options[:recipient_province_code] || options[:recipient_country_code]
|
326
|
+
|
327
|
+
post[:j6] = options[:recipient_street_address] if options[:recipient_street_address]
|
328
|
+
post[:j7] = options[:recipient_city] if options[:recipient_city]
|
329
|
+
post[:j8] = options[:recipient_province_code] if options[:recipient_province_code]
|
330
|
+
post[:j9] = options[:recipient_country_code] if options[:recipient_country_code]
|
331
|
+
end
|
332
|
+
|
323
333
|
def add_customer_name(post, options)
|
324
334
|
post[:j5] = options[:first_name] if options[:first_name]
|
325
335
|
post[:j13] = options[:last_name] if options[:last_name]
|
@@ -15,9 +15,6 @@ module ActiveMerchant #:nodoc:
|
|
15
15
|
# CyberSource what kind of item you are selling. It is used when
|
16
16
|
# calculating tax/VAT.
|
17
17
|
# * All transactions use dollar values.
|
18
|
-
# * To process pinless debit cards through the pinless debit card
|
19
|
-
# network, your Cybersource merchant account must accept pinless
|
20
|
-
# debit card payments.
|
21
18
|
# * The order of the XML elements does matter, make sure to follow the order in
|
22
19
|
# the documentation exactly.
|
23
20
|
class CyberSourceGateway < Gateway
|
@@ -139,7 +136,6 @@ module ActiveMerchant #:nodoc:
|
|
139
136
|
commit(build_capture_request(money, authorization, options), :capture, money, options)
|
140
137
|
end
|
141
138
|
|
142
|
-
# options[:pinless_debit_card] => true # attempts to process as pinless debit card
|
143
139
|
def purchase(money, payment_method_or_reference, options = {})
|
144
140
|
setup_address_hash(options)
|
145
141
|
commit(build_purchase_request(money, payment_method_or_reference, options), :purchase, money, options)
|
@@ -158,9 +154,10 @@ module ActiveMerchant #:nodoc:
|
|
158
154
|
end
|
159
155
|
|
160
156
|
def verify(payment, options = {})
|
157
|
+
amount = eligible_for_zero_auth?(payment, options) ? 0 : 100
|
161
158
|
MultiResponse.run(:use_first_response) do |r|
|
162
|
-
r.process { authorize(
|
163
|
-
r.process(:ignore_result) { void(r.authorization, options) }
|
159
|
+
r.process { authorize(amount, payment, options) }
|
160
|
+
r.process(:ignore_result) { void(r.authorization, options) } unless amount == 0
|
164
161
|
end
|
165
162
|
end
|
166
163
|
|
@@ -229,12 +226,6 @@ module ActiveMerchant #:nodoc:
|
|
229
226
|
commit(build_tax_calculation_request(creditcard, options), :calculate_tax, nil, options)
|
230
227
|
end
|
231
228
|
|
232
|
-
# Determines if a card can be used for Pinless Debit Card transactions
|
233
|
-
def validate_pinless_debit_card(creditcard, options = {})
|
234
|
-
requires!(options, :order_id)
|
235
|
-
commit(build_validate_pinless_debit_request(creditcard, options), :validate_pinless_debit_card, nil, options)
|
236
|
-
end
|
237
|
-
|
238
229
|
def supports_scrubbing?
|
239
230
|
true
|
240
231
|
end
|
@@ -291,6 +282,7 @@ module ActiveMerchant #:nodoc:
|
|
291
282
|
xml = Builder::XmlMarkup.new indent: 2
|
292
283
|
add_customer_id(xml, options)
|
293
284
|
add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)
|
285
|
+
add_other_tax(xml, options)
|
294
286
|
add_threeds_2_ucaf_data(xml, creditcard_or_reference, options)
|
295
287
|
add_decision_manager_fields(xml, options)
|
296
288
|
add_mdd_fields(xml, options)
|
@@ -349,6 +341,7 @@ module ActiveMerchant #:nodoc:
|
|
349
341
|
xml = Builder::XmlMarkup.new indent: 2
|
350
342
|
add_customer_id(xml, options)
|
351
343
|
add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
|
344
|
+
add_other_tax(xml, options)
|
352
345
|
add_threeds_2_ucaf_data(xml, payment_method_or_reference, options)
|
353
346
|
add_decision_manager_fields(xml, options)
|
354
347
|
add_mdd_fields(xml, options)
|
@@ -362,7 +355,7 @@ module ActiveMerchant #:nodoc:
|
|
362
355
|
add_purchase_service(xml, payment_method_or_reference, options)
|
363
356
|
add_threeds_services(xml, options)
|
364
357
|
add_payment_network_token(xml) if network_tokenization?(payment_method_or_reference)
|
365
|
-
add_business_rules_data(xml, payment_method_or_reference, options)
|
358
|
+
add_business_rules_data(xml, payment_method_or_reference, options)
|
366
359
|
add_stored_credential_subsequent_auth(xml, options)
|
367
360
|
add_issuer_additional_data(xml, options)
|
368
361
|
add_partner_solution_id(xml)
|
@@ -474,13 +467,6 @@ module ActiveMerchant #:nodoc:
|
|
474
467
|
xml.target!
|
475
468
|
end
|
476
469
|
|
477
|
-
def build_validate_pinless_debit_request(creditcard, options)
|
478
|
-
xml = Builder::XmlMarkup.new indent: 2
|
479
|
-
add_creditcard(xml, creditcard)
|
480
|
-
add_validate_pinless_debit_service(xml)
|
481
|
-
xml.target!
|
482
|
-
end
|
483
|
-
|
484
470
|
def add_business_rules_data(xml, payment_method, options)
|
485
471
|
prioritized_options = [options, @options]
|
486
472
|
|
@@ -500,6 +486,8 @@ module ActiveMerchant #:nodoc:
|
|
500
486
|
end
|
501
487
|
|
502
488
|
def add_line_item_data(xml, options)
|
489
|
+
return unless options[:line_items]
|
490
|
+
|
503
491
|
options[:line_items].each_with_index do |value, index|
|
504
492
|
xml.tag! 'item', { 'id' => index } do
|
505
493
|
xml.tag! 'unitPrice', localized_amount(value[:declared_value].to_i, options[:currency] || default_currency)
|
@@ -507,6 +495,8 @@ module ActiveMerchant #:nodoc:
|
|
507
495
|
xml.tag! 'productCode', value[:code] || 'shipping_only'
|
508
496
|
xml.tag! 'productName', value[:description]
|
509
497
|
xml.tag! 'productSKU', value[:sku]
|
498
|
+
xml.tag! 'taxAmount', value[:tax_amount] if value[:tax_amount]
|
499
|
+
xml.tag! 'nationalTax', value[:national_tax] if value[:national_tax]
|
510
500
|
end
|
511
501
|
end
|
512
502
|
end
|
@@ -522,10 +512,12 @@ module ActiveMerchant #:nodoc:
|
|
522
512
|
end
|
523
513
|
|
524
514
|
def add_merchant_descriptor(xml, options)
|
525
|
-
return unless options[:merchant_descriptor]
|
515
|
+
return unless options[:merchant_descriptor] || options[:user_po] || options[:taxable]
|
526
516
|
|
527
517
|
xml.tag! 'invoiceHeader' do
|
528
|
-
xml.tag! 'merchantDescriptor', options[:merchant_descriptor]
|
518
|
+
xml.tag! 'merchantDescriptor', options[:merchant_descriptor] if options[:merchant_descriptor]
|
519
|
+
xml.tag! 'userPO', options[:user_po] if options[:user_po]
|
520
|
+
xml.tag! 'taxable', options[:taxable] if options[:taxable]
|
529
521
|
end
|
530
522
|
end
|
531
523
|
|
@@ -628,11 +620,12 @@ module ActiveMerchant #:nodoc:
|
|
628
620
|
end
|
629
621
|
|
630
622
|
def add_other_tax(xml, options)
|
631
|
-
return unless options[:local_tax_amount] || options[:national_tax_amount]
|
623
|
+
return unless options[:local_tax_amount] || options[:national_tax_amount] || options[:national_tax_indicator]
|
632
624
|
|
633
625
|
xml.tag! 'otherTax' do
|
634
626
|
xml.tag! 'localTaxAmount', options[:local_tax_amount] if options[:local_tax_amount]
|
635
627
|
xml.tag! 'nationalTaxAmount', options[:national_tax_amount] if options[:national_tax_amount]
|
628
|
+
xml.tag! 'nationalTaxIndicator', options[:national_tax_indicator] if options[:national_tax_indicator]
|
636
629
|
end
|
637
630
|
end
|
638
631
|
|
@@ -787,15 +780,9 @@ module ActiveMerchant #:nodoc:
|
|
787
780
|
end
|
788
781
|
|
789
782
|
def add_purchase_service(xml, payment_method, options)
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
end
|
794
|
-
else
|
795
|
-
add_auth_service(xml, payment_method, options)
|
796
|
-
xml.tag! 'ccCaptureService', { 'run' => 'true' } do
|
797
|
-
xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
|
798
|
-
end
|
783
|
+
add_auth_service(xml, payment_method, options)
|
784
|
+
xml.tag! 'ccCaptureService', { 'run' => 'true' } do
|
785
|
+
xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
|
799
786
|
end
|
800
787
|
end
|
801
788
|
|
@@ -887,6 +874,7 @@ module ActiveMerchant #:nodoc:
|
|
887
874
|
else
|
888
875
|
add_address(xml, payment_method_or_reference, options[:billing_address], options)
|
889
876
|
add_address(xml, payment_method_or_reference, options[:shipping_address], options, true)
|
877
|
+
add_line_item_data(xml, options)
|
890
878
|
add_purchase_data(xml, money, true, options)
|
891
879
|
add_installments(xml, options)
|
892
880
|
add_creditcard(xml, payment_method_or_reference)
|
@@ -903,10 +891,6 @@ module ActiveMerchant #:nodoc:
|
|
903
891
|
end
|
904
892
|
end
|
905
893
|
|
906
|
-
def add_validate_pinless_debit_service(xml)
|
907
|
-
xml.tag! 'pinlessDebitValidateService', { 'run' => 'true' }
|
908
|
-
end
|
909
|
-
|
910
894
|
def add_threeds_services(xml, options)
|
911
895
|
xml.tag! 'payerAuthEnrollService', { 'run' => 'true' } if options[:payer_auth_enroll_service]
|
912
896
|
if options[:payer_auth_validate_service]
|
@@ -1069,6 +1053,10 @@ module ActiveMerchant #:nodoc:
|
|
1069
1053
|
response[:message]
|
1070
1054
|
end
|
1071
1055
|
end
|
1056
|
+
|
1057
|
+
def eligible_for_zero_auth?(payment_method, options = {})
|
1058
|
+
payment_method.is_a?(CreditCard) && options[:zero_amount_auth]
|
1059
|
+
end
|
1072
1060
|
end
|
1073
1061
|
end
|
1074
1062
|
end
|