activemerchant 1.56.0 → 1.57.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +42 -0
  3. data/lib/active_merchant/billing/gateways/authorize_net.rb +52 -21
  4. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -0
  5. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +243 -0
  6. data/lib/active_merchant/billing/gateways/bpoint.rb +1 -1
  7. data/lib/active_merchant/billing/gateways/braintree_blue.rb +11 -11
  8. data/lib/active_merchant/billing/gateways/bridge_pay.rb +37 -8
  9. data/lib/active_merchant/billing/gateways/card_stream.rb +36 -11
  10. data/lib/active_merchant/billing/gateways/checkout_v2.rb +3 -0
  11. data/lib/active_merchant/billing/gateways/clearhaus.rb +2 -2
  12. data/lib/active_merchant/billing/gateways/creditcall.rb +1 -1
  13. data/lib/active_merchant/billing/gateways/cyber_source.rb +12 -1
  14. data/lib/active_merchant/billing/gateways/element.rb +335 -0
  15. data/lib/active_merchant/billing/gateways/forte.rb +8 -0
  16. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  17. data/lib/active_merchant/billing/gateways/litle.rb +1 -1
  18. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +2 -1
  19. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  20. data/lib/active_merchant/billing/gateways/payeezy.rb +54 -12
  21. data/lib/active_merchant/billing/gateways/sage.rb +379 -128
  22. data/lib/active_merchant/billing/gateways/stripe.rb +13 -3
  23. data/lib/active_merchant/billing/gateways/trans_first.rb +26 -6
  24. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +573 -0
  25. data/lib/active_merchant/billing/gateways/worldpay.rb +7 -0
  26. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +11 -0
  27. data/lib/active_merchant/version.rb +1 -1
  28. metadata +7 -6
  29. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -89
  30. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -115
  31. data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
  32. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -97
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a7fa5a42dbb05e1c335a93e8cefc85781e7cbae
4
- data.tar.gz: 928d0561eab8bc6a0fcac4245ccc2342d4e8fa6a
3
+ metadata.gz: 763b8ca398277831841d2b263a482a46e2f8793b
4
+ data.tar.gz: 6acb014413ea74d8b36ebe9a2a40ae04e60de312
5
5
  SHA512:
6
- metadata.gz: bf1511639e9a72d13e6be69a301e0f0553cd4b52e65205a0e9f777c951e355124c16440182716a622beb5cd56037d98aea1659e1bdf49541b20d0438d2bf3802
7
- data.tar.gz: 83dd4208bb147e5dce68f4751ff27e7298f03fffa0ef8c32f0f335fbf8fa79b1c4177d4839b236510fc7d9f66bedf98a4237085fbb2dcc94a9509d57f3004feb
6
+ metadata.gz: fce7249de3a503a61123f020bf72a374d5fe3fc9368c786e939135995ff5f4d5a392f31026325d7844ffd6458bc832d7c845e56d1f892c21b4e567ce322b5ec7
7
+ data.tar.gz: 204553110484e103828c9767405bf11cd704810a5689f1150bace201316445168ce9f523ba67278f9e3ff2010906ca2237cd8a6d58ddd99192671cffd08d36d3
data/CHANGELOG CHANGED
@@ -1,5 +1,44 @@
1
1
  = ActiveMerchant CHANGELOG
2
2
 
3
+ == Version 1.57.0 (February 1, 2016)
4
+ * AuthorizeNetCim: Add unmaskExpirationDate option [RamilGilmanov]
5
+ * Element: Add gateway support [davidsantoso]
6
+ * Cardstream: 3D-secure capture fix [duff]
7
+ * Auth.net: Update store to create payment profiles [davidsantoso]
8
+ * CyberSource: Add support for mdd_fields [duff]
9
+ * Worldpay: Add support for verify [davidsantoso]
10
+ * Element: Add guard clause to handle undocumented errors [davidsantoso]
11
+ * Clearhaus: Add tests for signed requests [anellis]
12
+ * Stripe: Support adding cards to account [anellis]
13
+ * Clearhaus: Add text_on_statement option [anellis]
14
+ * Payeezy: Void and verify support [davidsantoso]
15
+ * Creditcall: Use ecommerce rather than cnp [duff]
16
+ * Payeezy: Add support for echecks [davidsantoso]
17
+ * Bridgepay: Add ability to store cards and pay with token [anellis]
18
+ * Initial support for Android Pay network tokenization cards [mrezentes]
19
+ * Transfirst: Fix exception when not all eCheck information is present [davidsantoso]
20
+ * Auth.net: Add tests for echeck refunds [davidsantoso]
21
+ * Transfirst: use default values for some eCheck data [davidsantoso]
22
+ * Element: Update the live URL endpoint [davidsantoso]
23
+ * Element: Parse responses from unexpected API errors [davidsantoso]
24
+ * Transfirst: Remove unused fields for echeck [davidsantoso]
25
+ * Sage: Internal refactoring into a single gateway class w/ common http conn [anellis]
26
+ * Cardstream: Adjust authorize and capture transactions [anellis]
27
+ * NCRSecurePay: New gateway support (Monetra white-label) [rwdaigle]
28
+ * Element: Map ReferenceNumber to order_id [duff]
29
+ * Element: Use a better MotoECICode default [duff]
30
+ * BraintreeBlue: Return transaction id for failed transactions when available [prburke]
31
+ * PayPal: Add InContextPaypalExpressGateway [xuorig]
32
+ * TransFirst: CVV is a required tag [duff]
33
+ * Checkout V2: Add Descriptor Name and City Options [anellis]
34
+ * Forte: Pass order_id [anellis]
35
+ * Merchant ESolutioins: Truncate order_id [anellis]
36
+ * Transfirst Transaction Express: New gateway support [sdball]
37
+ * Stripe: Add `stripe_account` header option [anellis]
38
+ * Cardstream: Add AVS code and message [anellis]
39
+ * Barclaycard Smartpay: New gateway support [curiousepic]
40
+
41
+
3
42
  == Version 1.56.0 (December 1, 2015)
4
43
  * Add Cardknox gateway [dlehren]
5
44
  * Mercury: Add support for card present track 2 [ryanbalsdon]
@@ -201,6 +240,9 @@
201
240
  * Paystation: No longer require order_id everywhere [duff]
202
241
  * Checkout: Support descriptor_name and descriptor_city [duff]
203
242
  * Add supports_network_tokenization? to gateways [jnormore]
243
+ * Bpoint: Handle message for invalid login [anellis]
244
+ * TransFirst: Add scrubbing [davidsantoso]
245
+ * TransFirst: Add back a few request fields [davidsantoso]
204
246
 
205
247
 
206
248
  == Version 1.50.0 (June 1, 2015)
@@ -8,7 +8,7 @@ module ActiveMerchant #:nodoc:
8
8
  self.test_url = 'https://apitest.authorize.net/xml/v1/request.api'
9
9
  self.live_url = 'https://api2.authorize.net/xml/v1/request.api'
10
10
 
11
- self.supported_countries = %w(AD AT AU BE BG CA CH CY CZ DE DK ES FI FR GB GB GI GR HU IE IT LI LU MC MT NL NO PL PT RO SE SI SK SM TR US VA)
11
+ self.supported_countries = %w(AD AT AU BE BG CA CH CY CZ DE DK EE ES FI FR GB GB GI GR HU IE IS IT LI LT LU LV MC MT NL NO PL PT RO SE SI SK SM TR US VA)
12
12
  self.default_currency = 'USD'
13
13
  self.money_format = :dollars
14
14
  self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro]
@@ -154,25 +154,10 @@ module ActiveMerchant #:nodoc:
154
154
  end
155
155
 
156
156
  def store(credit_card, options = {})
157
- commit(:cim_store) do |xml|
158
- xml.profile do
159
- xml.merchantCustomerId(truncate(options[:merchant_customer_id], 20) || SecureRandom.hex(10))
160
- xml.description(truncate(options[:description], 255)) unless empty?(options[:description])
161
- xml.email(options[:email]) unless empty?(options[:email])
162
-
163
- xml.paymentProfiles do
164
- xml.customerType("individual")
165
- add_billing_address(xml, credit_card, options)
166
- add_shipping_address(xml, options, "shipToList")
167
- xml.payment do
168
- xml.creditCard do
169
- xml.cardNumber(truncate(credit_card.number, 16))
170
- xml.expirationDate(format(credit_card.year, :four_digits) + '-' + format(credit_card.month, :two_digits))
171
- xml.cardCode(credit_card.verification_value) if credit_card.verification_value
172
- end
173
- end
174
- end
175
- end
157
+ if options[:customer_profile_id]
158
+ create_customer_payment_profile(credit_card, options)
159
+ else
160
+ create_customer_profile(credit_card, options)
176
161
  end
177
162
  end
178
163
 
@@ -460,7 +445,6 @@ module ActiveMerchant #:nodoc:
460
445
  xml.routingNumber(check.routing_number)
461
446
  xml.accountNumber(check.account_number)
462
447
  xml.nameOnAccount(check.name)
463
- xml.echeckType("WEB")
464
448
  xml.bankName(check.bank_name)
465
449
  xml.checkNumber(check.number)
466
450
  end
@@ -538,6 +522,46 @@ module ActiveMerchant #:nodoc:
538
522
  end
539
523
  end
540
524
 
525
+ def create_customer_payment_profile(credit_card, options)
526
+ commit(:cim_store_update) do |xml|
527
+ xml.customerProfileId options[:customer_profile_id]
528
+ xml.paymentProfile do
529
+ add_billing_address(xml, credit_card, options)
530
+ xml.payment do
531
+ xml.creditCard do
532
+ xml.cardNumber(truncate(credit_card.number, 16))
533
+ xml.expirationDate(format(credit_card.year, :four_digits) + '-' + format(credit_card.month, :two_digits))
534
+ xml.cardCode(credit_card.verification_value) if credit_card.verification_value
535
+ end
536
+ end
537
+ end
538
+ end
539
+ end
540
+
541
+ def create_customer_profile(credit_card, options)
542
+ commit(:cim_store) do |xml|
543
+ xml.profile do
544
+ xml.merchantCustomerId(truncate(options[:merchant_customer_id], 20) || SecureRandom.hex(10))
545
+ xml.description(truncate(options[:description], 255)) unless empty?(options[:description])
546
+ xml.email(options[:email]) unless empty?(options[:email])
547
+
548
+ xml.paymentProfiles do
549
+ xml.customerType("individual")
550
+ add_billing_address(xml, credit_card, options)
551
+ add_shipping_address(xml, options, "shipToList")
552
+ xml.payment do
553
+ xml.creditCard do
554
+ xml.cardNumber(truncate(credit_card.number, 16))
555
+ xml.expirationDate(format(credit_card.year, :four_digits) + '-' + format(credit_card.month, :two_digits))
556
+ xml.cardCode(credit_card.verification_value) if credit_card.verification_value
557
+ end
558
+ end
559
+ end
560
+ end
561
+ end
562
+ end
563
+
564
+
541
565
  def names_from(payment_source, address, options)
542
566
  if payment_source && !payment_source.is_a?(PaymentToken) && !payment_source.is_a?(String)
543
567
  first_name, last_name = split_names(address[:name])
@@ -602,6 +626,8 @@ module ActiveMerchant #:nodoc:
602
626
  def root_for(action)
603
627
  if action == :cim_store
604
628
  "createCustomerProfileRequest"
629
+ elsif action == :cim_store_update
630
+ "createCustomerPaymentProfileRequest"
605
631
  elsif is_cim_action?(action)
606
632
  "createCustomerProfileTransactionRequest"
607
633
  else
@@ -697,6 +723,11 @@ module ActiveMerchant #:nodoc:
697
723
  (empty?(element.content) ? nil : element.content)
698
724
  end
699
725
 
726
+ response[:customer_payment_profile_id] = if(element = doc.at_xpath("//customerPaymentProfileIdList/numericString") ||
727
+ doc.at_xpath("//customerPaymentProfileId"))
728
+ (empty?(element.content) ? nil : element.content)
729
+ end
730
+
700
731
  response[:direct_response] = if(element = doc.at_xpath("//directResponse"))
701
732
  (empty?(element.content) ? nil : element.content)
702
733
  end
@@ -574,6 +574,7 @@ module ActiveMerchant #:nodoc:
574
574
  def build_get_customer_payment_profile_request(xml, options)
575
575
  xml.tag!('customerProfileId', options[:customer_profile_id])
576
576
  xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
577
+ xml.tag!('unmaskExpirationDate', options[:unmask_expiration_date]) if options[:unmask_expiration_date]
577
578
  xml.target!
578
579
  end
579
580
 
@@ -0,0 +1,243 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class BarclaycardSmartpayGateway < Gateway
4
+ self.test_url = 'https://pal-test.barclaycardsmartpay.com/pal/servlet'
5
+ self.live_url = 'https://pal-live.barclaycardsmartpay.com/pal/servlet'
6
+
7
+ self.supported_countries = ['AR', 'AT', 'BE', 'BR', 'CA', 'CH', 'CL', 'CN', 'CO', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'HK', 'ID', 'IE', 'IL', 'IN', 'IT', 'JP', 'KR', 'LU', 'MX', 'MY', 'NL', 'NO', 'PA', 'PE', 'PH', 'PL', 'PT', 'RU', 'SE', 'SG', 'TH', 'TR', 'TW', 'US', 'VN', 'ZA']
8
+ self.default_currency = 'EUR'
9
+ self.money_format = :cents
10
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :dankort, :maestro]
11
+
12
+ self.homepage_url = 'https://www.barclaycardsmartpay.com/'
13
+ self.display_name = 'Barclaycard Smartpay'
14
+
15
+ def initialize(options = {})
16
+ requires!(options, :company, :merchant, :password)
17
+ super
18
+ end
19
+
20
+ def purchase(money, creditcard, options = {})
21
+ requires!(options, :order_id)
22
+
23
+ MultiResponse.run do |r|
24
+ r.process { authorize(money, creditcard, options) }
25
+ r.process { capture(money, r.authorization, options) }
26
+ end
27
+ end
28
+
29
+ def authorize(money, creditcard, options = {})
30
+ requires!(options, :order_id)
31
+
32
+ post = payment_request(money, options)
33
+ post[:amount] = amount_hash(money, options[:currency])
34
+ post[:card] = credit_card_hash(creditcard)
35
+
36
+ if address = (options[:billing_address] || options[:address])
37
+ post[:billingAddress] = address_hash(address)
38
+ end
39
+
40
+ if options[:shipping_address]
41
+ post[:deliveryAddress] = address_hash(options[:shipping_address])
42
+ end
43
+
44
+ commit('authorise', post)
45
+ end
46
+
47
+ def capture(money, authorization, options = {})
48
+ requires!(options, :order_id)
49
+
50
+ post = modification_request(authorization, options)
51
+ post[:modificationAmount] = amount_hash(money, options[:currency])
52
+
53
+ commit('capture', post)
54
+ end
55
+
56
+ def refund(money, authorization, options = {})
57
+ requires!(options, :order_id)
58
+
59
+ post = modification_request(authorization, options)
60
+ post[:modificationAmount] = amount_hash(money, options[:currency])
61
+
62
+ commit('refund', post)
63
+ end
64
+
65
+ def void(identification, options = {})
66
+ requires!(options, :order_id)
67
+
68
+ post = modification_request(identification, options)
69
+
70
+ commit('cancel', post)
71
+ end
72
+
73
+ def verify(creditcard, options = {})
74
+ authorize(0, creditcard, options)
75
+ end
76
+
77
+ def store(creditcard, options = {})
78
+ # ??? require :email and :customer, :order_id?
79
+
80
+ post = store_request(options)
81
+ post[:card] = credit_card_hash(creditcard)
82
+ post[:recurring] = {:contract => 'RECURRING'}
83
+
84
+ commit('store', post)
85
+ end
86
+
87
+ def supports_scrubbing?
88
+ true
89
+ end
90
+
91
+ def scrub(transcript)
92
+ transcript.
93
+ gsub(%r(((?:\r\n)?Authorization: Basic )[^\r\n]+(\r\n)?), '\1[FILTERED]').
94
+ gsub(%r((card.number=)\d+), '\1[FILTERED]').
95
+ gsub(%r((card.cvc=)\d+), '\1[FILTERED]')
96
+ end
97
+
98
+ private
99
+
100
+ def commit(action, post)
101
+ request = post_data(flatten_hash(post))
102
+ raw_response = ssl_post(build_url(action), request, headers)
103
+ response = parse(raw_response)
104
+
105
+ Response.new(
106
+ success_from(response),
107
+ message_from(response),
108
+ response,
109
+ test: test?,
110
+ authorization: response['recurringDetailReference'] || response['pspReference']
111
+ )
112
+
113
+ rescue ResponseError => e
114
+ case e.response.code
115
+ when '401'
116
+ return Response.new(false, 'Invalid credentials', {}, :test => test?)
117
+ when '422'
118
+ return Response.new(false, 'Unprocessable Entity', {}, :test => test?)
119
+ when '500'
120
+ if e.response.body.split(' ')[0] == 'validation'
121
+ return Response.new(false, e.response.body.split(' ', 3)[2], {}, :test => test?)
122
+ end
123
+ end
124
+ raise
125
+ end
126
+
127
+ def flatten_hash(hash, prefix = nil)
128
+ flat_hash = {}
129
+ hash.each_pair do |key, val|
130
+ conc_key = prefix.nil? ? key : "#{prefix}.#{key}"
131
+ if val.is_a?(Hash)
132
+ flat_hash.merge!(flatten_hash(val, conc_key))
133
+ else
134
+ flat_hash[conc_key] = val
135
+ end
136
+ end
137
+ flat_hash
138
+ end
139
+
140
+ def headers
141
+ {
142
+ 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8',
143
+ 'Authorization' => 'Basic ' + Base64.encode64("ws@Company.#{@options[:company]}:#{@options[:password]}").strip
144
+ }
145
+ end
146
+
147
+ def parse(response)
148
+ Hash[
149
+ response.split('&').map do |x|
150
+ key, val = x.split('=', 2)
151
+ [key.split('.').last, CGI.unescape(val)]
152
+ end
153
+ ]
154
+ end
155
+
156
+ def post_data(data)
157
+ data.map do |key, val|
158
+ "#{key}=#{CGI.escape(val.to_s)}"
159
+ end.reduce do |x, y|
160
+ "#{x}&#{y}"
161
+ end
162
+ end
163
+
164
+ def message_from(response)
165
+ return response['resultCode'] if response.has_key?('resultCode') # Payment request
166
+ return response['response'] if response['response'] # Modification request
167
+ return response['result'] if response.has_key?('result') # Store/Recurring request
168
+ 'Failure' # Negative fallback in case of error
169
+ end
170
+
171
+ def success_from(response)
172
+ return true if response.has_key?('authCode')
173
+ return true if response['result'] == 'Success'
174
+ successful_responses = %w([capture-received] [cancel-received] [refund-received])
175
+ successful_responses.include?(response['response'])
176
+ end
177
+
178
+ def build_url(action)
179
+ case action
180
+ when 'store'
181
+ "#{test? ? self.test_url : self.live_url}/Recurring/v12/storeToken"
182
+ else
183
+ "#{test? ? self.test_url : self.live_url}/Payment/v12/#{action}"
184
+ end
185
+ end
186
+
187
+ def address_hash(address)
188
+ full_address = "#{address[:address1]} #{address[:address2]}" if address
189
+
190
+ hash = {}
191
+ hash[:city] = address[:city] if address[:city]
192
+ hash[:street] = full_address.split(/\s+/).keep_if { |x| x !~ /\d/ }.join(' ')
193
+ hash[:houseNumberOrName] = full_address.split(/\s+/).keep_if { |x| x =~ /\d/ }.join(' ')
194
+ hash[:postalCode] = address[:zip] if address[:zip]
195
+ hash[:stateOrProvince] = address[:state] if address[:state]
196
+ hash[:country] = address[:country] if address[:country]
197
+ hash
198
+ end
199
+
200
+ def amount_hash(money, currency)
201
+ hash = {}
202
+ hash[:currency] = currency || currency(money)
203
+ hash[:value] = amount(money) if money
204
+ hash
205
+ end
206
+
207
+ def credit_card_hash(creditcard)
208
+ hash = {}
209
+ hash[:cvc] = creditcard.verification_value if creditcard.verification_value
210
+ hash[:expiryMonth] = format(creditcard.month, :two_digits) if creditcard.month
211
+ hash[:expiryYear] = format(creditcard.year, :four_digits) if creditcard.year
212
+ hash[:holderName] = creditcard.name if creditcard.name
213
+ hash[:number] = creditcard.number if creditcard.number
214
+ hash
215
+ end
216
+
217
+ def modification_request(reference, options)
218
+ hash = {}
219
+ hash[:merchantAccount] = @options[:merchant]
220
+ hash[:originalReference] = reference if reference
221
+ hash.keep_if { |_, v| v }
222
+ end
223
+
224
+ def payment_request(money, options)
225
+ hash = {}
226
+ hash[:merchantAccount] = @options[:merchant]
227
+ hash[:reference] = options[:order_id] if options[:order_id]
228
+ hash[:shopperEmail] = options[:email] if options[:email]
229
+ hash[:shopperIP] = options[:ip] if options[:ip]
230
+ hash[:shopperReference] = options[:customer] if options[:customer]
231
+ hash.keep_if { |_, v| v }
232
+ end
233
+
234
+ def store_request(options)
235
+ hash = {}
236
+ hash[:merchantAccount] = @options[:merchant]
237
+ hash[:shopperEmail] = options[:email] if options[:email]
238
+ hash[:shopperReference] = options[:customer] if options[:customer]
239
+ hash.keep_if { |_, v| v }
240
+ end
241
+ end
242
+ end
243
+ end
@@ -252,7 +252,7 @@ module ActiveMerchant #:nodoc:
252
252
  end
253
253
 
254
254
  def message
255
- params[:ProcessPaymentResult_AuthorisationResult]
255
+ params[:ProcessPaymentResult_AuthorisationResult] || params[:response_ResponseMessage]
256
256
  end
257
257
  end
258
258
 
@@ -321,7 +321,7 @@ module ActiveMerchant #:nodoc:
321
321
  def response_from_result(result)
322
322
  Response.new(result.success?, message_from_result(result),
323
323
  { braintree_transaction: transaction_hash(result) },
324
- { authorization: (result.transaction.id if result.success?) }
324
+ { authorization: (result.transaction.id if result.transaction) }
325
325
  )
326
326
  end
327
327
 
@@ -334,10 +334,8 @@ module ActiveMerchant #:nodoc:
334
334
 
335
335
  def response_options(result)
336
336
  options = {}
337
- if result.success?
338
- options[:authorization] = result.transaction.id
339
- end
340
337
  if result.transaction
338
+ options[:authorization] = result.transaction.id
341
339
  options[:avs_result] = { code: avs_code_from(result.transaction) }
342
340
  options[:cvv_result] = result.transaction.cvv_response_code
343
341
  end
@@ -554,13 +552,15 @@ module ActiveMerchant #:nodoc:
554
552
  :last_name => credit_card_or_vault_id.last_name
555
553
  )
556
554
  if credit_card_or_vault_id.is_a?(NetworkTokenizationCreditCard)
557
- parameters[:apple_pay_card] = {
558
- :number => credit_card_or_vault_id.number,
559
- :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"),
560
- :expiration_year => credit_card_or_vault_id.year.to_s,
561
- :cardholder_name => "#{credit_card_or_vault_id.first_name} #{credit_card_or_vault_id.last_name}",
562
- :cryptogram => credit_card_or_vault_id.payment_cryptogram
563
- }
555
+ if credit_card_or_vault_id.source == :apple_pay
556
+ parameters[:apple_pay_card] = {
557
+ :number => credit_card_or_vault_id.number,
558
+ :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"),
559
+ :expiration_year => credit_card_or_vault_id.year.to_s,
560
+ :cardholder_name => "#{credit_card_or_vault_id.first_name} #{credit_card_or_vault_id.last_name}",
561
+ :cryptogram => credit_card_or_vault_id.payment_cryptogram
562
+ }
563
+ end
564
564
  else
565
565
  parameters[:credit_card] = {
566
566
  :number => credit_card_or_vault_id.number,