Class: ActiveMerchant::Billing::PayHubGateway

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

Constant Summary collapse

CVV_CODE_TRANSLATOR =
{
  'M' => 'CVV matches',
  'N' => 'CVV does not match',
  'P' => 'CVV not processed',
  'S' => 'CVV should have been present',
  'U' => 'CVV request unable to be processed by issuer'
}
AVS_CODE_TRANSLATOR =
{
  '0' =>  "Approved, Address verification was not requested.",
  'A' =>  "Approved, Address matches only.",
  'B' =>  "Address Match. Street Address math for international transaction Postal Code not verified because of incompatible formats (Acquirer sent both street address and Postal Code)",
  'C' =>  "Serv Unavailable. Street address and Postal Code not verified for international transaction because of incompatible formats (Acquirer sent both street and Postal Code).",
  'D' =>  "Exact Match, Street Address and Postal Code match for international transaction.",
  'F' =>  "Exact Match, Street Address and Postal Code match. Applies to UK only.",
  'G' =>  "Ver Unavailable, Non-U.S. Issuer does not participate.",
  'I' =>  "Ver Unavailable, Address information not verified for international transaction",
  'M' =>  "Exact Match, Street Address and Postal Code match for international transaction",
  'N' =>  "No - Address and ZIP Code does not match",
  'P' =>  "Zip Match, Postal Codes match for international transaction Street address not verified because of incompatible formats (Acquirer sent both street address and Postal Code).",
  'R' =>  "Retry - Issuer system unavailable",
  'S' =>  "Serv Unavailable, Service not supported",
  'U' =>  "Ver Unavailable, Address unavailable.",
  'W' =>  "ZIP match - Nine character numeric ZIP match only.",
  'X' =>  "Exact match, Address and nine-character ZIP match.",
  'Y' =>  "Exact Match, Address and five character ZIP match.",
  'Z' =>  "Zip Match, Five character numeric ZIP match only.",
  '1' =>  "Cardholder name and ZIP match AMEX only.",
  '2' =>  "Cardholder name, address, and ZIP match AMEX only.",
  '3' =>  "Cardholder name and address match AMEX only.",
  '4' =>  "Cardholder name match AMEX only.",
  '5' =>  "Cardholder name incorrect, ZIP match AMEX only.",
  '6' =>  "Cardholder name incorrect, address and ZIP match AMEX only.",
  '7' =>  "Cardholder name incorrect, address match AMEX only.",
  '8' =>  "Cardholder, all do not match AMEX only."
}
STANDARD_ERROR_CODE_MAPPING =
{
  '14' => STANDARD_ERROR_CODE[:invalid_number],
  '80' => STANDARD_ERROR_CODE[:invalid_expiry_date],
  '82' => STANDARD_ERROR_CODE[:invalid_cvc],
  '54' => STANDARD_ERROR_CODE[:expired_card],
  '51' => STANDARD_ERROR_CODE[:card_declined],
  '05' => STANDARD_ERROR_CODE[:card_declined],
  '61' => STANDARD_ERROR_CODE[:card_declined],
  '62' => STANDARD_ERROR_CODE[:card_declined],
  '65' => STANDARD_ERROR_CODE[:card_declined],
  '93' => STANDARD_ERROR_CODE[:card_declined],
  '01' => STANDARD_ERROR_CODE[:call_issuer],
  '02' => STANDARD_ERROR_CODE[:call_issuer],
  '04' => STANDARD_ERROR_CODE[:pickup_card],
  '07' => STANDARD_ERROR_CODE[:pickup_card],
  '41' => STANDARD_ERROR_CODE[:pickup_card],
  '43' => STANDARD_ERROR_CODE[:pickup_card]
}

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, #scrub, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ PayHubGateway

Returns a new instance of PayHubGateway.



69
70
71
72
73
# File 'lib/active_merchant/billing/gateways/pay_hub.rb', line 69

def initialize(options={})
  requires!(options, :orgid, :username, :password, :tid)

  super
end

Instance Method Details

#authorize(amount, creditcard, options = {}) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/active_merchant/billing/gateways/pay_hub.rb', line 75

def authorize(amount, creditcard, options = {})
  post = setup_post('auth')
  add_creditcard(post, creditcard)
  add_amount(post, amount)
  add_address(post, (options[:address] || options[:billing_address]))
  add_customer_data(post, options)

  commit(post)
end

#capture(amount, trans_id, options = {}) ⇒ Object



107
108
109
110
111
112
113
114
# File 'lib/active_merchant/billing/gateways/pay_hub.rb', line 107

def capture(amount, trans_id, options = {})
  post = setup_post('capture')

  add_reference(post, trans_id)
  add_amount(post, amount)

  commit(post)
end

#purchase(amount, creditcard, options = {}) ⇒ Object



85
86
87
88
89
90
91
92
93
# File 'lib/active_merchant/billing/gateways/pay_hub.rb', line 85

def purchase(amount, creditcard, options={})
  post = setup_post('sale')
  add_creditcard(post, creditcard)
  add_amount(post, amount)
  add_address(post, (options[:address] || options[:billing_address]))
  add_customer_data(post, options)

  commit(post)
end

#refund(amount, trans_id, options = {}) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/active_merchant/billing/gateways/pay_hub.rb', line 95

def refund(amount, trans_id, options={})
  # Attempt a void in case the transaction is unsettled
  post = setup_post('void')
  add_reference(post, trans_id)
  response = commit(post)
  return response if response.success?

  post = setup_post('refund')
  add_reference(post, trans_id)
  commit(post)
end

#verify(creditcard, options = {}) ⇒ Object

No void, as PayHub’s void does not work on authorizations



118
119
120
# File 'lib/active_merchant/billing/gateways/pay_hub.rb', line 118

def verify(creditcard, options={})
  authorize(100, creditcard, options)
end