lib/active_merchant/billing/gateways/epsilon.rb in active_merchant-epsilon-0.13.0 vs lib/active_merchant/billing/gateways/epsilon.rb in active_merchant-epsilon-0.14.0
- old
+ new
@@ -20,17 +20,35 @@
change_recurring_amount: 'change_amount_payment.cgi',
find_order: 'getsales2.cgi',
capture: 'sales_payment.cgi',
}.freeze
+ RISK_BASE_AUTH_PARAMS_KEYS = %i[
+ tds_flag billAddrCity billAddrCountry billAddrLine1 billAddrLine2 billAddrLine3
+ billAddrPostCode billAddrState shipAddrCity shipAddrCountry shipAddrLine1 shipAddrLine2
+ shipAddrLine3 shipAddrPostCode shipAddrState chAccAgeInd chAccChange
+ chAccChangeIndchAccDate chAccPwdChange chAccPwChangeInd nbPurchaseAccount paymentAccAge
+ paymentAccInd provisionAttemptsDay shipAddressUsage shipAddressUsageInd shipNameIndicator
+ suspiciousAccActivity txnActivityDay txnActivityYear threeDSReqAuthData threeDSReqAuthMethod
+ threeDSReqAuthTimestamp addrMatch cardholderName homePhone mobilePhone
+ workPhone challengeInd deliveryEmailAddress deliveryTimeframe giftCardAmount
+ giftCardCount preOrderDate preOrderPurchaseInd reorderItemsInd shipIndicator
+ ].freeze
+
+ THREE_D_SECURE_2_INDICATORS = [21, 22].freeze
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
def purchase(amount, credit_card, detail = {})
detail[:mission_code] = EpsilonMissionCode::PURCHASE
params = billing_params(amount, credit_card, detail)
+ if three_d_secure_2?(detail)
+ params.merge!(detail.slice(*RISK_BASE_AUTH_PARAMS_KEYS).compact)
+ end
+
commit(PATHS[:purchase], params)
end
def registered_purchase(amount, detail = {})
params = {
@@ -52,10 +70,14 @@
params[:memo1] = detail[:memo1] if detail.has_key?(:memo1)
params[:memo2] = detail[:memo2] if detail.has_key?(:memo2)
params[:kari_flag] = detail[:capture] ? 2 : 1 if detail.has_key?(:capture)
+ if three_d_secure_2?(detail)
+ params.merge!(detail.slice(*RISK_BASE_AUTH_PARAMS_KEYS).compact)
+ end
+
commit(PATHS[:registered_purchase], params)
end
def recurring(amount, credit_card, detail = {})
detail[:mission_code] ||= EpsilonMissionCode::RECURRING_2
@@ -236,9 +258,13 @@
security_check: 1, # use security code
)
end
params
+ end
+
+ def three_d_secure_2?(detail)
+ THREE_D_SECURE_2_INDICATORS.include?(detail[:tds_flag])
end
end
end
end