lib/active_merchant/billing/gateways/trans_first.rb in activemerchant-1.56.0 vs lib/active_merchant/billing/gateways/trans_first.rb in activemerchant-1.57.0
- old
+ new
@@ -7,11 +7,11 @@
self.supported_countries = ['US']
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
self.homepage_url = 'http://www.transfirst.com/'
self.display_name = 'TransFirst'
- UNUSED_FIELDS = %w(ECIValue UserId CAVVData TrackData POSInd EComInd MerchZIP MerchCustPNum MCC InstallmentNum InstallmentOf POSEntryMode POSConditionCode AuthCharInd CardCertData)
+ UNUSED_CREDIT_CARD_FIELDS = %w(UserId TrackData MerchZIP MerchCustPNum MCC InstallmentNum InstallmentOf POSInd POSEntryMode POSConditionCode EComInd AuthCharInd CardCertData CAVVData)
DECLINED = 'The transaction was declined'
ACTIONS = {
purchase: "CCSale",
@@ -60,10 +60,23 @@
add_pair(post, :TransID, transaction_id)
commit(:void, post)
end
+ def supports_scrubbing?
+ true
+ end
+
+ def scrub(transcript)
+ transcript.
+ gsub(%r((&?RegKey=)\w*(&?)), '\1[FILTERED]\2').
+ gsub(%r((&?CardNumber=)\d*(&?)), '\1[FILTERED]\2').
+ gsub(%r((&?CVV2=)\d*(&?)), '\1[FILTERED]\2').
+ gsub(%r((&?TransRoute=)\d*(&?)), '\1[FILTERED]\2').
+ gsub(%r((&?BankAccountNo=)\d*(&?)), '\1[FILTERED]\2')
+ end
+
private
def add_amount(post, money)
add_pair(post, :Amount, amount(money), required: true)
end
@@ -80,12 +93,12 @@
def add_invoice(post, options)
add_pair(post, :RefID, options[:order_id], required: true)
add_pair(post, :SECCCode, options[:invoice], required: true)
add_pair(post, :PONumber, options[:invoice], required: true)
add_pair(post, :SaleTaxAmount, amount(options[:tax] || 0))
- add_pair(post, :PaymentDesc, options[:description], required: true)
add_pair(post, :TaxIndicator, 0)
+ add_pair(post, :PaymentDesc, options[:description] || "", required: true)
add_pair(post, :CompanyName, options[:company_name] || "", required: true)
end
def add_payment(post, payment)
if payment.is_a?(Check)
@@ -97,24 +110,31 @@
def add_credit_card(post, payment)
add_pair(post, :CardHolderName, payment.name, required: true)
add_pair(post, :CardNumber, payment.number, required: true)
add_pair(post, :Expiration, expdate(payment), required: true)
- add_pair(post, :CVV2, payment.verification_value)
+ add_pair(post, :CVV2, payment.verification_value, required: true)
end
def add_echeck(post, payment)
add_pair(post, :TransRoute, payment.routing_number, required: true)
add_pair(post, :BankAccountNo, payment.account_number, required: true)
- add_pair(post, :BankAccountType, payment.account_type.capitalize, required: true)
- add_pair(post, :CheckType, payment.account_holder_type.capitalize, required: true)
+ add_pair(post, :BankAccountType, add_or_use_default(payment.account_type, "Checking"), required: true)
+ add_pair(post, :CheckType, add_or_use_default(payment.account_holder_type, "Personal"), required: true)
add_pair(post, :Name, payment.name, required: true)
add_pair(post, :ProcessDate, Time.now.strftime("%m%d%y"), required: true)
add_pair(post, :Description, "", required: true)
end
+ def add_or_use_default(payment_data, default_value)
+ return payment_data.capitalize if payment_data
+ return default_value
+ end
+
def add_unused_fields(post)
- UNUSED_FIELDS.each do |f|
+ return if post[:TransRoute]
+
+ UNUSED_CREDIT_CARD_FIELDS.each do |f|
post[f] = ""
end
end
def expdate(credit_card)