Class: ActiveMerchant::Billing::PaymentExpressGateway

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

Overview

In NZ DPS supports ANZ, Westpac, National Bank, ASB and BNZ. In Australia DPS supports ANZ, NAB, Westpac, CBA, St George and Bank of South Australia. The Maybank in Malaysia is supported and the Citibank for Singapore.

Constant Summary collapse

URL =
'https://www.paymentexpress.com/pxpost.aspx'
APPROVED =
'1'
TRANSACTIONS =
{
  :purchase       => 'Purchase',
  :credit         => 'Refund',
  :authorization  => 'Auth',
  :capture        => 'Complete',
  :validate       => 'Validate'
}

Constants inherited from Gateway

Gateway::DEBIT_CARDS

Constants included from PostsData

PostsData::MAX_RETRIES, PostsData::OPEN_TIMEOUT, PostsData::READ_TIMEOUT

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 Utils

generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #ssl_get, #ssl_post

Constructor Details

#initialize(options = {}) ⇒ PaymentExpressGateway

We require the DPS gateway username and password when the object is created.



37
38
39
40
41
42
43
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 37

def initialize(options = {})
  # A DPS username and password must exist 
  requires!(options, :login, :password)
  # Make the options an instance variable
  @options = options
  super
end

Instance Method Details

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

NOTE: Perhaps in options we allow a transaction note to be inserted Verifies that funds are available for the requested card and amount and reserves the specified amount. See: www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Authcomplete



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

def authorize(money, credit_card, options = {})
  options[:credit_card] = credit_card

  request = build_purchase_or_authorization_request(money, options)
  commit(:authorization, request)
end

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



72
73
74
75
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 72

def capture(money, identification, options = {})
  request = build_capture_or_credit_request(money, identification, options)                                            
  commit(:capture, request)
end

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

Refund funds to the card holder



78
79
80
81
82
83
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 78

def credit(money, identification, options = {})
  requires!(options, :description)
  
  request = build_capture_or_credit_request(money, identification, options)                                            
  commit(:credit, request)
end

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

Funds are transferred immediately.



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 46

def purchase(money, payment_source, options = {})
  
  credit_card = payment_source if payment_source.respond_to?(:number)
  
  if credit_card        
    options[:credit_card] = credit_card
  else
    options[:token]       = payment_source
  end
  
  request = build_purchase_or_authorization_request(money, options)
  commit(:purchase, request)      
end

#store(credit_card, options = {}) ⇒ Object

initiates a “Validate” transcation to store card data on payment express servers returns a “token” that can be used to rebill this card see: www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Tokenbilling PaymentExpress does not support unstoring a stored card.



91
92
93
94
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 91

def store(credit_card, options = {})
  request  = build_token_request(credit_card, options)
  commit(:validate, request)
end