Class: ActiveMerchant::Billing::TransFirstGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/trans_first.rb

Constant Summary collapse

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",
  purchase_echeck: "ACHDebit",
  refund: "CreditCardCredit",
  refund_echeck: "ACHVoidTransaction",
  void: "CreditCardAutoRefundorVoid",
}
ENDPOINTS =
{
  purchase: "creditcard.asmx",
  purchase_echeck: "checkverifyws/checkverifyws.asmx",
  refund: "creditcard.asmx",
  refund_echeck: "checkverifyws/checkverifyws.asmx",
  void: "creditcard.asmx"
}

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from CreditCardFormatting

#format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ TransFirstGateway

Returns a new instance of TransFirstGateway.



33
34
35
36
# File 'lib/active_merchant/billing/gateways/trans_first.rb', line 33

def initialize(options = {})
  requires!(options, :login, :password)
  super
end

Instance Method Details

#purchase(money, payment, options = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/active_merchant/billing/gateways/trans_first.rb', line 38

def purchase(money, payment, options = {})
  post = {}

  add_amount(post, money)
  add_payment(post, payment)
  add_address(post, options)
  add_invoice(post, options) if payment.credit_card?
  add_pair(post, :RefID, options[:order_id], required: true)

  commit((payment.is_a?(Check) ? :purchase_echeck : :purchase), post)
end

#refund(money, authorization, options = {}) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/active_merchant/billing/gateways/trans_first.rb', line 50

def refund(money, authorization, options={})
  post = {}

  transaction_id, payment_type = split_authorization(authorization)
  add_amount(post, money)
  add_pair(post, :TransID, transaction_id)
  add_pair(post, :RefID, options[:order_id], required: true)

  commit((payment_type == "check" ? :refund_echeck : :refund), post)
end

#scrub(transcript) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/active_merchant/billing/gateways/trans_first.rb', line 74

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

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/active_merchant/billing/gateways/trans_first.rb', line 70

def supports_scrubbing?
  true
end

#void(authorization, options = {}) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/active_merchant/billing/gateways/trans_first.rb', line 61

def void(authorization, options={})
  post = {}

  transaction_id, _ = split_authorization(authorization)
  add_pair(post, :TransID, transaction_id)

  commit(:void, post)
end