activemerchant 1.93.0 → 1.94.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 077fd706902e893fc2824d409a604bc8512849f142e8503c6c1d2081f6fd64b4
4
- data.tar.gz: 34a4a0385f319d09e2000ad4f150814f9b86a331b75941f594387ba7cb30c5b5
3
+ metadata.gz: 5a2728fa6c7116ab636feb7ba715c2e4d5305fb54898d1687d633cbfb2a4795f
4
+ data.tar.gz: d63425c0a65919bc4a2a007d41b145a355a341667be616ae8fc0337ce2d8d145
5
5
  SHA512:
6
- metadata.gz: 0bc0752fc32fb159b99aa2d0fe36fe3b7d2f1f3059945c76b30f80dad9a8d236f29e5ea5b7105636bb4de16398ae44b2dec13fac230dbc6380ff3496f0476a3c
7
- data.tar.gz: 479edb7ec96840e1b05f89955f11fe2b89914dda0f8ebcd42428c40de80e84e93901b79d4549858aba3c95c308052b68412d9d6b984a154aaa3f636315b6e404
6
+ metadata.gz: f577b5623169e0e7a1a12f4f2fa212517fba33a5ec40fb61a8e14c9df629939a4e31ed6a24ed9fabe783404553ff98ff8bdb5f0fabdc3c9da8fe8bc31c8ad97f
7
+ data.tar.gz: 2d37c0742319a5533236acaeb9e885692b8610208d540adda49dc21147584a3dbc50ba28632d014fb7d280d4ff9202032e5fe05dde1b1741eabf4889e9a08a42
data/CHANGELOG CHANGED
@@ -1,6 +1,23 @@
1
1
  = ActiveMerchant CHANGELOG
2
2
 
3
3
  == HEAD
4
+ == Version 1.94.0 (May 21, 2019)
5
+ * Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195
6
+ * Stripe: Support show and list webhook endpoints [jknipp] #3196
7
+ * CardConnect: Add frontendid parameter to requests [gcatlin] #3198
8
+ * Adyen: Correct formatting of Billing Address [nfarve] #3200
9
+ * Stripe: Stripe: Show payment source [jknipp] #3202
10
+ * Checkout V2: Checkout V2: Correct success criteria [curiousepic] #3205
11
+ * Adyen: Add normalized hash of 3DS 2.0 data fields from web browsers [davidsantoso] #3207
12
+ * Stripe: Do not attempt application fee refund if refund was not successful [jasonwebster] #3206
13
+ * Elavon: Send transaction_currency if currency is provided [gcatlin] #3201
14
+ * Elavon: Multi-currency support [jknipp] #3210
15
+ * Adyen: Support preAuths and Synchronous Adjusts [curiousepic] #3212
16
+ * WorldPay: Support Unknown Card Type [tanyajajodia] #3213
17
+ * Mundipagg: Make gateway_affiliation_id an option [curiousepic] #3219
18
+ * CyberSource: Adds Elo Card Type [tanyajajodia] #3220
19
+ * CyberSource: Support standalone credit for cards [curiousepic] 3225
20
+
4
21
  == Version 1.93.0 (April 18, 2019)
5
22
  * Stripe: Do not consider a refund unsuccessful if only refunding the fee failed [jasonwebster] #3188
6
23
  * Stripe: Fix webhook creation for connected account [jknipp] #3193
@@ -13,8 +13,8 @@ module ActiveMerchant #:nodoc:
13
13
  'dankort' => ->(num) { num =~ /^5019\d{12}$/ },
14
14
  'maestro' => ->(num) { (12..19).cover?(num&.size) && in_bin_range?(num.slice(0, 6), MAESTRO_RANGES) },
15
15
  'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ },
16
- 'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{8}$/ },
17
- 'vr' => ->(num) { num =~ /^(627416|637036)\d{8}$/ },
16
+ 'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{10}$/ },
17
+ 'vr' => ->(num) { num =~ /^(627416|637036)\d{10}$/ },
18
18
  'carnet' => lambda { |num|
19
19
  num&.size == 16 && (
20
20
  in_bin_range?(num.slice(0, 6), CARNET_RANGES) ||
@@ -80,6 +80,7 @@ module ActiveMerchant #:nodoc:
80
80
  post = init_post(options)
81
81
  add_invoice_for_modification(post, money, options)
82
82
  add_reference(post, authorization, options)
83
+ add_extra_data(post, nil, options)
83
84
  commit('adjustAuthorisation', post, options)
84
85
  end
85
86
 
@@ -174,6 +175,9 @@ module ActiveMerchant #:nodoc:
174
175
  post[:additionalData][:overwriteBrand] = normalize(options[:overwrite_brand]) if options[:overwrite_brand]
175
176
  post[:additionalData][:customRoutingFlag] = options[:custom_routing_flag] if options[:custom_routing_flag]
176
177
  post[:additionalData]['paymentdatasource.type'] = NETWORK_TOKENIZATION_CARD_SOURCE[payment.source.to_s] if payment.is_a?(NetworkTokenizationCreditCard)
178
+ post[:additionalData][:authorisationType] = options[:authorisation_type] if options[:authorisation_type]
179
+ post[:additionalData][:adjustAuthorisationData] = options[:adjust_authorisation_data] if options[:adjust_authorisation_data]
180
+ post[:additionalData][:RequestedTestAcquirerResponseCode] = options[:requested_test_acquirer_response_code] if options[:requested_test_acquirer_response_code] && test?
177
181
  post[:deviceFingerprint] = options[:device_fingerprint] if options[:device_fingerprint]
178
182
  add_risk_data(post, options)
179
183
  end
@@ -214,13 +218,13 @@ module ActiveMerchant #:nodoc:
214
218
  def add_address(post, options)
215
219
  return unless post[:card]&.kind_of?(Hash)
216
220
  if (address = options[:billing_address] || options[:address]) && address[:country]
217
- post[:card][:billingAddress] = {}
218
- post[:card][:billingAddress][:street] = address[:address1] || 'N/A'
219
- post[:card][:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A'
220
- post[:card][:billingAddress][:postalCode] = address[:zip] if address[:zip]
221
- post[:card][:billingAddress][:city] = address[:city] || 'N/A'
222
- post[:card][:billingAddress][:stateOrProvince] = address[:state] || 'N/A'
223
- post[:card][:billingAddress][:country] = address[:country] if address[:country]
221
+ post[:billingAddress] = {}
222
+ post[:billingAddress][:street] = address[:address1] || 'N/A'
223
+ post[:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A'
224
+ post[:billingAddress][:postalCode] = address[:zip] if address[:zip]
225
+ post[:billingAddress][:city] = address[:city] || 'N/A'
226
+ post[:billingAddress][:stateOrProvince] = address[:state] || 'N/A'
227
+ post[:billingAddress][:country] = address[:country] if address[:country]
224
228
  end
225
229
  end
226
230
 
@@ -308,9 +312,31 @@ module ActiveMerchant #:nodoc:
308
312
  end
309
313
 
310
314
  def add_3ds(post, options)
311
- return unless options[:execute_threed] || options[:threed_dynamic]
312
- post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] }
313
- post[:additionalData] = { executeThreeD: 'true' } if options[:execute_threed]
315
+ if three_ds_2_options = options[:three_ds_2]
316
+ if browser_info = three_ds_2_options[:browser_info]
317
+ post[:browserInfo] = {
318
+ acceptHeader: browser_info[:accept_header],
319
+ colorDepth: browser_info[:depth],
320
+ javaEnabled: browser_info[:java],
321
+ language: browser_info[:language],
322
+ screenHeight: browser_info[:height],
323
+ screenWidth: browser_info[:width],
324
+ timeZoneOffset: browser_info[:timezone],
325
+ userAgent: browser_info[:user_agent]
326
+ }
327
+
328
+ if device_channel = three_ds_2_options[:channel]
329
+ post[:threeDS2RequestData] = {
330
+ deviceChannel: device_channel,
331
+ notificationURL: three_ds_2_options[:notification_url] || 'https://example.com/notification'
332
+ }
333
+ end
334
+ end
335
+ else
336
+ return unless options[:execute_threed] || options[:threed_dynamic]
337
+ post[:browserInfo] = { userAgent: options[:user_agent], acceptHeader: options[:accept_header] }
338
+ post[:additionalData] = { executeThreeD: 'true' } if options[:execute_threed]
339
+ end
314
340
  end
315
341
 
316
342
  def parse(body)
@@ -374,8 +400,10 @@ module ActiveMerchant #:nodoc:
374
400
  case action.to_s
375
401
  when 'authorise', 'authorise3d'
376
402
  ['Authorised', 'Received', 'RedirectShopper'].include?(response['resultCode'])
377
- when 'capture', 'refund', 'cancel', 'adjustAuthorisation'
403
+ when 'capture', 'refund', 'cancel'
378
404
  response['response'] == "[#{action}-received]"
405
+ when 'adjustAuthorisation'
406
+ response['response'] == 'Authorised' || response['response'] == '[adjustAuthorisation-received]'
379
407
  else
380
408
  false
381
409
  end
@@ -267,6 +267,7 @@ module ActiveMerchant #:nodoc:
267
267
  end
268
268
 
269
269
  def commit(action, parameters, verb: :put, path: '')
270
+ parameters[:frontendid] = application_id
270
271
  parameters[:merchid] = @options[:merchant_id]
271
272
  url = url(action, path)
272
273
  response = parse(ssl_request(verb, url, post_data(parameters), headers))
@@ -1,15 +1,15 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class CheckoutV2Gateway < Gateway
4
- self.display_name = 'Checkout.com V2 Gateway'
4
+ self.display_name = 'Checkout.com Unified Payments'
5
5
  self.homepage_url = 'https://www.checkout.com/'
6
- self.live_url = 'https://api2.checkout.com/v2'
7
- self.test_url = 'https://sandbox.checkout.com/api2/v2'
6
+ self.live_url = 'https://api.checkout.com'
7
+ self.test_url = 'https://api.sandbox.checkout.com'
8
8
 
9
9
  self.supported_countries = ['AD', 'AE', 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FO', 'FI', 'FR', 'GB', 'GI', 'GL', 'GR', 'HR', 'HU', 'IE', 'IS', 'IL', 'IT', 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SM', 'SK', 'SJ', 'TR', 'VA']
10
10
  self.default_currency = 'USD'
11
11
  self.money_format = :cents
12
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
12
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :maestro, :discover]
13
13
 
14
14
  def initialize(options={})
15
15
  requires!(options, :secret_key)
@@ -30,11 +30,12 @@ module ActiveMerchant #:nodoc:
30
30
 
31
31
  def authorize(amount, payment_method, options={})
32
32
  post = {}
33
- post[:autoCapture] = 'n'
33
+ post[:capture] = false
34
34
  add_invoice(post, amount, options)
35
35
  add_payment_method(post, payment_method)
36
36
  add_customer_data(post, options)
37
37
  add_transaction_data(post, options)
38
+ add_3ds(post, options)
38
39
 
39
40
  commit(:authorize, post)
40
41
  end
@@ -81,49 +82,69 @@ module ActiveMerchant #:nodoc:
81
82
  private
82
83
 
83
84
  def add_invoice(post, money, options)
84
- post[:value] = localized_amount(money, options[:currency])
85
- post[:trackId] = options[:order_id]
85
+ post[:amount] = localized_amount(money, options[:currency])
86
+ post[:reference] = options[:order_id]
86
87
  post[:currency] = options[:currency] || currency(money)
87
- post[:descriptor] = {}
88
- post[:descriptor][:name] = options[:descriptor_name] if options[:descriptor_name]
89
- post[:descriptor][:city] = options[:descriptor_city] if options[:descriptor_city]
88
+ if options[:descriptor_name] || options[:descriptor_city]
89
+ post[:billing_descriptor] = {}
90
+ post[:billing_descriptor][:name] = options[:descriptor_name] if options[:descriptor_name]
91
+ post[:billing_descriptor][:city] = options[:descriptor_city] if options[:descriptor_city]
92
+ end
93
+ post[:metadata] = {}
94
+ post[:metadata][:udf5] = application_id || 'ActiveMerchant'
90
95
  end
91
96
 
92
97
  def add_payment_method(post, payment_method)
93
- post[:card] = {}
94
- post[:card][:name] = payment_method.name
95
- post[:card][:number] = payment_method.number
96
- post[:card][:cvv] = payment_method.verification_value
97
- post[:card][:expiryYear] = format(payment_method.year, :four_digits)
98
- post[:card][:expiryMonth] = format(payment_method.month, :two_digits)
98
+ post[:source] = {}
99
+ post[:source][:type] = 'card'
100
+ post[:source][:name] = payment_method.name
101
+ post[:source][:number] = payment_method.number
102
+ post[:source][:cvv] = payment_method.verification_value
103
+ post[:source][:expiry_year] = format(payment_method.year, :four_digits)
104
+ post[:source][:expiry_month] = format(payment_method.month, :two_digits)
99
105
  end
100
106
 
101
107
  def add_customer_data(post, options)
102
- post[:email] = options[:email] || 'unspecified@example.com'
103
- post[:customerIp] = options[:ip] if options[:ip]
108
+ post[:customer] = {}
109
+ post[:customer][:email] = options[:email] || nil
110
+ post[:payment_ip] = options[:ip] if options[:ip]
104
111
  address = options[:billing_address]
105
- if(address && post[:card])
106
- post[:card][:billingDetails] = {}
107
- post[:card][:billingDetails][:addressLine1] = address[:address1]
108
- post[:card][:billingDetails][:addressLine2] = address[:address2]
109
- post[:card][:billingDetails][:city] = address[:city]
110
- post[:card][:billingDetails][:state] = address[:state]
111
- post[:card][:billingDetails][:country] = address[:country]
112
- post[:card][:billingDetails][:postcode] = address[:zip]
113
- post[:card][:billingDetails][:phone] = { number: address[:phone] } unless address[:phone].blank?
112
+ if(address && post[:source])
113
+ post[:source][:billing_address] = {}
114
+ post[:source][:billing_address][:address_line1] = address[:address1] unless address[:address1].blank?
115
+ post[:source][:billing_address][:address_line2] = address[:address2] unless address[:address2].blank?
116
+ post[:source][:billing_address][:city] = address[:city] unless address[:city].blank?
117
+ post[:source][:billing_address][:state] = address[:state] unless address[:state].blank?
118
+ post[:source][:billing_address][:country] = address[:country] unless address[:country].blank?
119
+ post[:source][:billing_address][:zip] = address[:zip] unless address[:zip].blank?
120
+ post[:source][:phone] = { number: address[:phone] } unless address[:phone].blank?
114
121
  end
115
122
  end
116
123
 
117
124
  def add_transaction_data(post, options={})
118
- post[:cardOnFile] = true if options[:card_on_file] == true
119
- post[:transactionIndicator] = options[:transaction_indicator] || 1
120
- post[:previousChargeId] = options[:previous_charge_id] if options[:previous_charge_id]
125
+ post[:card_on_file] = true if options[:card_on_file] == true
126
+ post[:payment_type] = 'Regular' if options[:transaction_indicator] == 1
127
+ post[:payment_type] = 'Recurring' if options[:transaction_indicator] == 2
128
+ post[:previous_payment_id] = options[:previous_charge_id] if options[:previous_charge_id]
129
+ end
130
+
131
+ def add_3ds(post, options)
132
+ if options[:three_d_secure]
133
+ post[:'3ds'] = {}
134
+ post[:'3ds'][:enabled] = true
135
+ post[:'3ds'][:eci] = options[:eci] if options[:eci]
136
+ post[:'3ds'][:cryptogram] = options[:cavv] if options[:cavv]
137
+ post[:'3ds'][:xid] = options[:xid] if options[:xid]
138
+ end
121
139
  end
122
140
 
123
141
  def commit(action, post, authorization = nil)
124
142
  begin
125
143
  raw_response = ssl_post(url(post, action, authorization), post.to_json, headers)
126
144
  response = parse(raw_response)
145
+ if action == :capture && response.key?('_links')
146
+ response['id'] = response['_links']['payment']['href'].split('/')[-1]
147
+ end
127
148
  rescue ResponseError => e
128
149
  raise unless(e.response.code.to_s =~ /4\d\d/)
129
150
  response = parse(e.response.body)
@@ -160,9 +181,15 @@ module ActiveMerchant #:nodoc:
160
181
 
161
182
  def url(post, action, authorization)
162
183
  if action == :authorize
163
- "#{base_url}/charges/card"
184
+ "#{base_url}/payments"
185
+ elsif action == :capture
186
+ "#{base_url}/payments/#{authorization}/captures"
187
+ elsif action == :refund
188
+ "#{base_url}/payments/#{authorization}/refunds"
189
+ elsif action == :void
190
+ "#{base_url}/payments/#{authorization}/voids"
164
191
  else
165
- "#{base_url}/charges/#{authorization}/#{action}"
192
+ "#{base_url}/payments/#{authorization}/#{action}"
166
193
  end
167
194
  end
168
195
 
@@ -171,33 +198,33 @@ module ActiveMerchant #:nodoc:
171
198
  end
172
199
 
173
200
  def avs_result(response)
174
- response['card'] && response['card']['avsCheck'] ? AVSResult.new(code: response['card']['avsCheck']) : nil
201
+ response['source'] && response['source']['avs_check'] ? AVSResult.new(code: response['source']['avs_check']) : nil
175
202
  end
176
203
 
177
204
  def cvv_result(response)
178
- response['card'] && response['card']['cvvCheck'] ? CVVResult.new(response['card']['cvvCheck']) : nil
205
+ response['source'] && response['source']['cvv_check'] ? CVVResult.new(response['source']['cvv_check']) : nil
179
206
  end
180
207
 
181
208
  def parse(body)
182
209
  JSON.parse(body)
183
210
  rescue JSON::ParserError
184
211
  {
185
- 'message' => 'Invalid JSON response received from CheckoutV2Gateway. Please contact CheckoutV2Gateway if you continue to receive this message.',
212
+ 'message' => 'Invalid JSON response received from Checkout.com Unified Payments Gateway. Please contact Checkout.com if you continue to receive this message.',
186
213
  'raw_response' => scrub(body)
187
214
  }
188
215
  end
189
216
 
190
217
  def success_from(response)
191
- (response['responseCode'] == '10000' && !response['responseMessage'].start_with?('40')) || response['responseCode'] == '10100'
218
+ response['response_summary'] == 'Approved' || !response.key?('response_summary') && response.key?('action_id')
192
219
  end
193
220
 
194
221
  def message_from(succeeded, response)
195
222
  if succeeded
196
223
  'Succeeded'
197
- elsif response['errors']
198
- response['message'] + ': ' + response['errors'].first
224
+ elsif response['error_type']
225
+ response['error_type'] + ': ' + response['error_codes'].first
199
226
  else
200
- response['responseMessage'] || response['message'] || 'Unable to read error message'
227
+ response['response_summary'] || response['response_code'] || 'Unable to read error message'
201
228
  end
202
229
  end
203
230
 
@@ -220,12 +247,12 @@ module ActiveMerchant #:nodoc:
220
247
 
221
248
  def error_code_from(succeeded, response)
222
249
  return if succeeded
223
- if response['errorCode'] && response['errorMessageCodes']
224
- "#{response["errorCode"]}: #{response["errorMessageCodes"].join(", ")}"
225
- elsif response['errorCode']
226
- response['errorCode']
250
+ if response['error_type'] && response['error_codes']
251
+ "#{response["error_type"]}: #{response["error_codes"].join(", ")}"
252
+ elsif response['error_type']
253
+ response['error_type']
227
254
  else
228
- STANDARD_ERROR_CODE_MAPPING[response['responseCode']]
255
+ STANDARD_ERROR_CODE_MAPPING[response['response_code']]
229
256
  end
230
257
  end
231
258
  end
@@ -26,7 +26,7 @@ module ActiveMerchant #:nodoc:
26
26
 
27
27
  XSD_VERSION = '1.153'
28
28
 
29
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro]
29
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro, :elo]
30
30
  self.supported_countries = %w(US BR CA CN DK FI FR DE IN JP MX NO SE GB SG LB)
31
31
 
32
32
  self.default_currency = 'USD'
@@ -43,7 +43,8 @@ module ActiveMerchant #:nodoc:
43
43
  :diners_club => '005',
44
44
  :jcb => '007',
45
45
  :dankort => '034',
46
- :maestro => '042'
46
+ :maestro => '042',
47
+ :elo => '054'
47
48
  }
48
49
 
49
50
  @@response_codes = {
@@ -142,9 +143,10 @@ module ActiveMerchant #:nodoc:
142
143
  end
143
144
  end
144
145
 
145
- # Adds credit to a subscription (stand alone credit).
146
- def credit(money, reference, options = {})
147
- commit(build_credit_request(money, reference, options), :credit, money, options)
146
+ # Adds credit to a card or subscription (stand alone credit).
147
+ def credit(money, creditcard_or_reference, options = {})
148
+ setup_address_hash(options)
149
+ commit(build_credit_request(money, creditcard_or_reference, options), :credit, money, options)
148
150
  end
149
151
 
150
152
  # Stores a customer subscription/profile with type "on-demand".
@@ -327,11 +329,10 @@ module ActiveMerchant #:nodoc:
327
329
  xml.target!
328
330
  end
329
331
 
330
- def build_credit_request(money, reference, options)
332
+ def build_credit_request(money, creditcard_or_reference, options)
331
333
  xml = Builder::XmlMarkup.new :indent => 2
332
334
 
333
- add_purchase_data(xml, money, true, options)
334
- add_subscription(xml, options, reference)
335
+ add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)
335
336
  add_credit_service(xml)
336
337
 
337
338
  xml.target!
@@ -42,6 +42,7 @@ module ActiveMerchant #:nodoc:
42
42
  else
43
43
  add_creditcard(form, payment_method)
44
44
  end
45
+ add_currency(form, money, options)
45
46
  add_address(form, options)
46
47
  add_customer_data(form, options)
47
48
  add_test_mode(form, options)
@@ -54,6 +55,7 @@ module ActiveMerchant #:nodoc:
54
55
  add_salestax(form, options)
55
56
  add_invoice(form, options)
56
57
  add_creditcard(form, creditcard)
58
+ add_currency(form, money, options)
57
59
  add_address(form, options)
58
60
  add_customer_data(form, options)
59
61
  add_test_mode(form, options)
@@ -69,6 +71,7 @@ module ActiveMerchant #:nodoc:
69
71
  add_approval_code(form, authorization)
70
72
  add_invoice(form, options)
71
73
  add_creditcard(form, options[:credit_card])
74
+ add_currency(form, money, options)
72
75
  add_customer_data(form, options)
73
76
  add_test_mode(form, options)
74
77
  else
@@ -102,6 +105,7 @@ module ActiveMerchant #:nodoc:
102
105
  form = {}
103
106
  add_invoice(form, options)
104
107
  add_creditcard(form, creditcard)
108
+ add_currency(form, money, options)
105
109
  add_address(form, options)
106
110
  add_customer_data(form, options)
107
111
  add_test_mode(form, options)
@@ -178,6 +182,11 @@ module ActiveMerchant #:nodoc:
178
182
  form[:last_name] = truncate(creditcard.last_name, 30)
179
183
  end
180
184
 
185
+ def add_currency(form, money, options)
186
+ currency = options[:currency] || currency(money)
187
+ form[:transaction_currency] = currency if currency && (@options[:multi_currency] || options[:multi_currency])
188
+ end
189
+
181
190
  def add_token(form, token)
182
191
  form[:token] = token
183
192
  end
@@ -155,7 +155,8 @@ module ActiveMerchant #:nodoc:
155
155
  post[:customer][:name] = payment.name if post[:customer]
156
156
  post[:customer_id] = parse_auth(payment)[0] if payment.is_a?(String)
157
157
  post[:payment] = {}
158
- post[:payment][:gateway_affiliation_id] = @options[:gateway_id] if @options[:gateway_id]
158
+ affiliation = options[:gateway_affiliation_id] || @options[:gateway_id]
159
+ post[:payment][:gateway_affiliation_id] = affiliation if affiliation
159
160
  post[:payment][:metadata] = { mundipagg_payment_method_code: '1' } if test?
160
161
  if voucher?(payment)
161
162
  add_voucher(post, payment, options)
@@ -152,7 +152,7 @@ module ActiveMerchant #:nodoc:
152
152
 
153
153
  response = commit(:post, "charges/#{CGI.escape(identification)}/refunds", post, options)
154
154
 
155
- if options[:refund_fee_amount] && options[:refund_fee_amount].to_s != '0'
155
+ if response.success? && options[:refund_fee_amount] && options[:refund_fee_amount].to_s != '0'
156
156
  charge = api_request(:get, "charges/#{CGI.escape(identification)}", nil, options)
157
157
 
158
158
  if application_fee = charge['application_fee']
@@ -309,6 +309,10 @@ module ActiveMerchant #:nodoc:
309
309
  commit(:post, 'sources', post, options)
310
310
  end
311
311
 
312
+ def show_source(source_id, options)
313
+ commit(:get, "sources/#{source_id}", nil, options)
314
+ end
315
+
312
316
  def create_webhook_endpoint(options, events)
313
317
  post = {}
314
318
  post[:url] = options[:callback_url]
@@ -322,6 +326,18 @@ module ActiveMerchant #:nodoc:
322
326
  commit(:delete, "webhook_endpoints/#{options[:webhook_id]}", {}, options)
323
327
  end
324
328
 
329
+ def show_webhook_endpoint(options)
330
+ options.delete(:stripe_account)
331
+ commit(:get, "webhook_endpoints/#{options[:webhook_id]}", nil, options)
332
+ end
333
+
334
+ def list_webhook_endpoints(options)
335
+ params = {}
336
+ params[:limit] = options[:limit] if options[:limit]
337
+ options.delete(:stripe_account)
338
+ commit(:get, "webhook_endpoints?#{post_data(params)}", nil, options)
339
+ end
340
+
325
341
  def create_post_for_auth_or_purchase(money, payment, options)
326
342
  post = {}
327
343
 
@@ -21,7 +21,8 @@ module ActiveMerchant #:nodoc:
21
21
  'jcb' => 'JCB-SSL',
22
22
  'maestro' => 'MAESTRO-SSL',
23
23
  'diners_club' => 'DINERS-SSL',
24
- 'elo' => 'ELO-SSL'
24
+ 'elo' => 'ELO-SSL',
25
+ 'unknown' => 'CARD-SSL'
25
26
  }
26
27
 
27
28
  AVS_CODE_MAP = {
@@ -252,7 +253,7 @@ module ActiveMerchant #:nodoc:
252
253
  end
253
254
  else
254
255
  xml.tag! 'paymentDetails', credit_fund_transfer_attribute(options) do
255
- xml.tag! CARD_CODES[card_brand(payment_method)] do
256
+ xml.tag! card_code_for(payment_method) do
256
257
  xml.tag! 'cardNumber', payment_method.number
257
258
  xml.tag! 'expiryDate' do
258
259
  xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits)
@@ -502,6 +503,10 @@ module ActiveMerchant #:nodoc:
502
503
  return 3 if three_decimal_currency?(currency)
503
504
  return 2
504
505
  end
506
+
507
+ def card_code_for(payment_method)
508
+ CARD_CODES[card_brand(payment_method)] || CARD_CODES['unknown']
509
+ end
505
510
  end
506
511
  end
507
512
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveMerchant
2
- VERSION = '1.93.0'
2
+ VERSION = '1.94.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemerchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.93.0
4
+ version: 1.94.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-18 00:00:00.000000000 Z
11
+ date: 2019-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport