lib/active_merchant/billing/gateways/safe_charge.rb in activemerchant-1.119.0 vs lib/active_merchant/billing/gateways/safe_charge.rb in activemerchant-1.120.0
- old
+ new
@@ -144,16 +144,24 @@
post[:sg_MerchantPhoneNumber] = options[:merchant_phone_number] if options[:merchant_phone_number]
post[:sg_MerchantName] = options[:merchant_name] if options[:merchant_name]
end
def add_payment(post, payment, options = {})
- post[:sg_NameOnCard] = payment.name
- post[:sg_CardNumber] = payment.number
post[:sg_ExpMonth] = format(payment.month, :two_digits)
post[:sg_ExpYear] = format(payment.year, :two_digits)
- post[:sg_CVV2] = payment.verification_value
- post[:sg_StoredCredentialMode] = (options[:stored_credential_mode] == true ? 1 : 0)
+ post[:sg_CardNumber] = payment.number
+
+ if payment.is_a?(NetworkTokenizationCreditCard) && payment.source == :network_token
+ post[:sg_CAVV] = payment.payment_cryptogram
+ post[:sg_ECI] = options[:three_d_secure] && options[:three_d_secure][:eci] || '05'
+ post[:sg_IsExternalMPI] = 1
+ post[:sg_ExternalTokenProvider] = 5
+ else
+ post[:sg_CVV2] = payment.verification_value
+ post[:sg_NameOnCard] = payment.name
+ post[:sg_StoredCredentialMode] = (options[:stored_credential_mode] == true ? 1 : 0)
+ end
end
def add_customer_details(post, payment, options)
if address = options[:billing_address] || options[:address]
post[:sg_FirstName] = payment.first_name
@@ -168,17 +176,16 @@
post[:sg_Email] = options[:email]
end
def add_external_mpi_data(post, options)
- version = options[:three_d_secure][:ds_transaction_id] ? '2' : '1'
-
- post[:sg_eci] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
- post[:sg_cavv] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
- post[:sg_dsTransID] = options[:three_d_secure][:ds_transaction_id] if version == '2'
- post[:sg_threeDSProtocolVersion] = version
- post[:sg_xid] = options[:three_d_secure][:xid] if version == '1'
+ post[:sg_ECI] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
+ post[:sg_CAVV] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
+ post[:sg_dsTransID] = options[:three_d_secure][:ds_transaction_id] if options[:three_d_secure][:ds_transaction_id]
+ post[:sg_threeDSProtocolVersion] = options[:three_d_secure][:ds_transaction_id] ? '2' : '1'
+ post[:sg_Xid] = options[:three_d_secure][:xid]
post[:sg_IsExternalMPI] = 1
+ post[:sg_EnablePartialApproval] = options[:is_partial_approval]
end
def parse(xml)
response = {}