lib/active_merchant/billing/gateways/card_connect.rb in activemerchant-1.126.0 vs lib/active_merchant/billing/gateways/card_connect.rb in activemerchant-1.129.0
- old
+ new
@@ -1,10 +1,10 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class CardConnectGateway < Gateway
- self.test_url = 'https://fts.cardconnect.com:6443/cardconnect/rest/'
- self.live_url = 'https://fts.cardconnect.com:8443/cardconnect/rest/'
+ self.test_url = 'https://fts-uat.cardconnect.com/cardconnect/rest/'
+ self.live_url = 'https://fts.cardconnect.com/cardconnect/rest/'
self.supported_countries = ['US']
self.default_currency = 'USD'
self.supported_cardtypes = %i[visa master american_express discover]
@@ -59,10 +59,12 @@
'05' => STANDARD_ERROR_CODE[:card_declined],
'03' => STANDARD_ERROR_CODE[:config_error],
'60' => STANDARD_ERROR_CODE[:pickup_card]
}
+ SCHEDULED_PAYMENT_TYPES = %w(recurring installment)
+
def initialize(options = {})
requires!(options, :merchant_id, :username, :password)
require_valid_domain!(options, :domain)
super
end
@@ -85,12 +87,13 @@
add_money(post, money)
add_payment(post, payment)
add_currency(post, money, options)
add_address(post, options)
add_customer_data(post, options)
- add_3DS(post, options)
+ add_three_ds_mpi_data(post, options)
add_additional_data(post, options)
+ add_stored_credential(post, options)
post[:capture] = 'Y'
commit('auth', post)
end
end
@@ -100,12 +103,13 @@
add_currency(post, money, options)
add_invoice(post, options)
add_payment(post, payment)
add_address(post, options)
add_customer_data(post, options)
- add_3DS(post, options)
+ add_three_ds_mpi_data(post, options)
add_additional_data(post, options)
+ add_stored_credential(post, options)
commit('auth', post)
end
def capture(money, authorization, options = {})
post = {}
@@ -186,11 +190,15 @@
post[:currency] = (options[:currency] || currency(money))
end
def add_invoice(post, options)
post[:orderid] = options[:order_id]
- post[:ecomind] = (options[:recurring] ? 'R' : 'E')
+ post[:ecomind] = if options[:ecomind]
+ options[:ecomind].capitalize
+ else
+ (options[:recurring] ? 'R' : 'E')
+ end
end
def add_payment(post, payment)
if payment.is_a?(String)
account_id, profile_id = payment.split('|')
@@ -239,13 +247,23 @@
end
end
post[:userfields] = options[:user_fields] if options[:user_fields]
end
- def add_3DS(post, options)
- post[:secureflag] = options[:secure_flag] if options[:secure_flag]
- post[:securevalue] = options[:secure_value] if options[:secure_value]
- post[:securexid] = options[:secure_xid] if options[:secure_xid]
+ def add_three_ds_mpi_data(post, options)
+ return unless three_d_secure = options[:three_d_secure]
+
+ post[:secureflag] = three_d_secure[:eci]
+ post[:securevalue] = three_d_secure[:cavv]
+ post[:securedstid] = three_d_secure[:ds_transaction_id]
+ end
+
+ def add_stored_credential(post, options)
+ return unless stored_credential = options[:stored_credential]
+
+ post[:cof] = stored_credential[:initiator] == 'merchant' ? 'M' : 'C'
+ post[:cofscheduled] = SCHEDULED_PAYMENT_TYPES.include?(stored_credential[:reason_type]) ? 'Y' : 'N'
+ post[:cofpermission] = stored_credential[:initial_transaction] ? 'Y' : 'N'
end
def headers
{
'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:username]}:#{@options[:password]}"),