Class: ActiveMerchant::Billing::JetpayGateway

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

Constant Summary collapse

ACTION_CODE_MESSAGES =
{
  "001" =>  "Refer to card issuer.",
  "002" =>  "Refer to card issuer, special condition.",
  "003" =>  "Pick up card.",
  "200" =>  "Deny - Pick up card.",
  "005" =>  "Do not honor.",
  "100" =>  "Deny.",
  "006" =>  "Error.",
  "181" =>  "Format error.",
  "007" =>  "Pickup card, special condition.",
  "104" =>  "Deny - New card issued.",
  "110" =>  "Invalid amount.",
  "014" =>  "Invalid account number (no such number).",
  "111" =>  "Invalid account.",
  "015" =>  "No such issuer.",
  "103" =>  "Deny - Invalid manual Entry 4DBC.",
  "182" =>  "Please wait.",
  "109" =>  "Invalid merchant.",
  "041" =>  "Pick up card (lost card).",
  "043" =>  "Pick up card (stolen card).",
  "051" =>  "Insufficient funds.",
  "052" =>  "No checking account.",
  "105" =>  "Deny - Account Cancelled.",
  "054" =>  "Expired Card.",
  "101" =>  "Expired Card.",
  "183" =>  "Invalid currency code.",
  "057" =>  "Transaction not permitted to cardholder.",
  "115" =>  "Service not permitted.",
  "062" =>  "Restricted card.",
  "189" =>  "Deny - Cancelled or Closed Merchant/SE.",
  "188" =>  "Deny - Expiration date required.",
  "125" =>  "Invalid effective date.",
  "122" =>  "Invalid card (CID) security code.",
  "400" =>  "Reversal accepted.",
  "992" =>  "DECLINE/TIMEOUT.",
  "107" =>  "Please Call Issuer.",
  "025" =>  "Transaction Not Found.",
  "981" =>  "AVS Error.",
  "913" =>  "Invalid Card Type.",
  "996" =>  "Terminal ID Not Found.",
  nil   =>  "No response returned (missing credentials?)."
}

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, inherited, supports?, #test?

Methods included from CreditCardFormatting

#format

Constructor Details

#initialize(options = {}) ⇒ JetpayGateway

Returns a new instance of JetpayGateway.



65
66
67
68
69
# File 'lib/active_merchant/billing/gateways/jetpay.rb', line 65

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

Instance Method Details

#authorize(money, credit_card, options = {}) ⇒ Object



75
76
77
# File 'lib/active_merchant/billing/gateways/jetpay.rb', line 75

def authorize(money, credit_card, options = {})
  commit(money, build_authonly_request(money, credit_card, options))
end

#capture(money, reference, options = {}) ⇒ Object



79
80
81
# File 'lib/active_merchant/billing/gateways/jetpay.rb', line 79

def capture(money, reference, options = {})
  commit(money, build_capture_request('CAPT', reference.split(";").first))
end

#credit(money, transaction_id_or_card, options = {}) ⇒ Object



88
89
90
91
92
93
94
95
# File 'lib/active_merchant/billing/gateways/jetpay.rb', line 88

def credit(money, transaction_id_or_card, options = {})
  if transaction_id_or_card.is_a?(String)
    deprecated CREDIT_DEPRECATION_MESSAGE
    refund(money, transaction_id_or_card, options)
  else
    commit(money, build_credit_request('CREDIT', money, nil, transaction_id_or_card))
  end
end

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



71
72
73
# File 'lib/active_merchant/billing/gateways/jetpay.rb', line 71

def purchase(money, credit_card, options = {})
  commit(money, build_sale_request(money, credit_card, options))
end

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



97
98
99
100
101
# File 'lib/active_merchant/billing/gateways/jetpay.rb', line 97

def refund(money, reference, options = {})
  transaction_id = reference.split(";").first
  credit_card = options[:credit_card]
  commit(money, build_credit_request('CREDIT', money, transaction_id, credit_card))
end

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



83
84
85
86
# File 'lib/active_merchant/billing/gateways/jetpay.rb', line 83

def void(reference, options = {})
  transaction_id, approval, amount = reference.split(";")
  commit(amount.to_i, build_void_request(amount.to_i, transaction_id, approval))
end