Class: ActiveMerchant::Billing::PayWayGateway

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

Constant Summary collapse

URL =
'https://ccapi.client.qvalent.com/payway/ccapi'
SUMMARY_CODES =
{ 
  '0' => 'Approved',
  '1' => 'Declined',
  '2' => 'Erred',
  '3' => 'Rejected'
}
RESPONSE_CODES =
{
  '00' => 'Completed Successfully',
  '01' => 'Refer to card issuer',
  '03' => 'Invalid merchant',
  '04' => 'Pick-up card',
  '05' => 'Do not honour',
  '08' => 'Honour only with identification',
  '12' => 'Invalid transaction',
  '13' => 'Invalid amount',
  '14' => 'Invalid card number (no such number)',
  '30' => 'Format error',
  '36' => 'Restricted card',
  '41' => 'Lost card',
  '42' => 'No universal card',
  '43' => 'Stolen card',
  '51' => 'Not sufficient funds',
  '54' => 'Expired card',
  '61' => 'Exceeds withdrawal amount limits',
  '62' => 'Restricted card',
  '65' => 'Exceeds withdrawal frequency limit',
  '91' => 'Issuer or switch is inoperative',
  '92' => 'Financial institution or intermediate network facility cannot be found for routing',
  '94' => 'Duplicate transmission',
  'Q1' => 'Unknown Buyer',
  'Q2' => 'Transaction Pending',
  'Q3' => 'Payment Gateway Connection Error',
  'Q4' => 'Payment Gateway Unavailable',
  'Q5' => 'Invalid Transaction',
  'Q6' => 'Duplicate Transaction - requery to determine status',
  'QA' => 'Invalid parameters or Initialisation failed',
  'QB' => 'Order type not currently supported',
  'QC' => 'Invalid Order Type',
  'QD' => 'Invalid Payment Amount - Payment amount less than minimum/exceeds maximum allowed limit',
  'QE' => 'Internal Error',
  'QF' => 'Transaction Failed',
  'QG' => 'Unknown Customer Order Number',
  'QH' => 'Unknown Customer Username or Password',
  'QI' => 'Transaction incomplete - contact Westpac to confirm reconciliation',
  'QJ' => 'Invalid Client Certificate',
  'QK' => 'Unknown Customer Merchant',
  'QL' => 'Business Group not configured for customer',
  'QM' => 'Payment Instrument not configured for customer',
  'QN' => 'Configuration Error',
  'QO' => 'Missing Payment Instrument',
  'QP' => 'Missing Supplier Account',
  'QQ' => 'Invalid Credit Card Verification Number',
  'QR' => 'Transaction Retry',
  'QS' => 'Transaction Successful',
  'QT' => 'Invalid currency',
  'QU' => 'Unknown Customer IP Address',
  'QV' => 'Invalid Original Order Number specified for Refund, Refund amount exceeds capture amount, or Previous capture was not approved',
  'QW' => 'Invalid Reference Number',
  'QX' => 'Network Error has occurred',
  'QY' => 'Card Type Not Accepted',
  'QZ' => 'Zero value transaction'
}
TRANSACTIONS =
{
  :authorization  => 'preauth',
  :purchase       => 'capture',
  :capture        => 'captureWithoutAuth',
  :status         => 'query',
  :credit         => 'refund'
}

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PayWayGateway

Create a new Payway gateway.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/active_merchant/billing/gateways/pay_way.rb', line 88

def initialize(options = {})
  requires!(options, :username, :password, :pem)
  @options = options
  
  @options[:eci]      ||= 'SSL'
  @options[:currency] ||= default_currency
  @options[:merchant] ||= 'TEST'
  @options[:pem]        = File.read(options[:pem])
  
  @post = {}
  @transaction = {}
  
  super
end

Instance Method Details

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



118
119
120
121
122
123
124
# File 'lib/active_merchant/billing/gateways/pay_way.rb', line 118

def authorize(amount, credit_card, options = {})
  requires!(options, :order_number)
  
  @transaction.merge!({ :order_number => options[:order_number] })
  
  process(:authorize, amount, credit_card)
end

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



126
127
128
129
130
131
132
133
134
135
# File 'lib/active_merchant/billing/gateways/pay_way.rb', line 126

def capture(amount, credit_card, options = {})
  requires!(options, :order_number, :original_order_number)
  
  @transaction.merge!({ 
    :order_number           => options[:order_number],
    :original_order_number  => options[:original_order_number]
  })
  
  process(:capture, amount, credit_card)
end

#credit(amount, credit_card, options = {}) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/active_merchant/billing/gateways/pay_way.rb', line 145

def credit(amount, credit_card, options = {})
  requires!(options, :order_number, :original_order_number)
  
  
  @transaction.merge!({ 
    :order_number           => options[:order_number],
    :original_order_number  => options[:original_order_number]
  })
  
  process(:credit, amount, credit_card)
end

#process(action, amount, credit_card) ⇒ Object

Build the string and send it



104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/active_merchant/billing/gateways/pay_way.rb', line 104

def process(action, amount, credit_card)
  @transaction.merge!({
    :type         => action,
    :amount       => amount,
    :credit_card  => credit_card
  })
  
  build_card
  build_order
  build_customer
  
  send_post
end

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



137
138
139
140
141
142
143
# File 'lib/active_merchant/billing/gateways/pay_way.rb', line 137

def purchase(amount, credit_card, options = {})
  requires!(options, :order_number)
  
  @transaction.merge!({ :order_number => options[:order_number] })
  
  process(:purchase, amount, credit_card)
end

#status(options = {}) ⇒ Object



157
158
159
160
161
162
163
164
165
# File 'lib/active_merchant/billing/gateways/pay_way.rb', line 157

def status(options = {})
  requires!(options, :order_number)
  @transaction = transaction
  @transaction[:type] = TRANSACTIONS[:status]
  
  build_order
  
  send_post
end