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

APPROVED =
'1'
TRANSACTIONS =
{
  :purchase       => 'Purchase',
  :credit         => 'Refund',
  :authorization  => 'Auth',
  :capture        => 'Complete',
  :validate       => 'Validate'
}

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

- (PaymentExpressGateway) initialize(options = {})

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

The PaymentExpress gateway also supports a :use_custom_payment_token boolean option. If set to true the gateway will use BillingId for the Token type. If set to false, then the token will be sent as the DPS specified “DpsBillingId”. This is per the documentation at www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Tokenbilling



42
43
44
45
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 42

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

Instance Method Details

- (Object) authorize(money, payment_source, options = {})

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

`payment_source` can be a usual ActiveMerchant credit_card object or a token, see #purchased method



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

def authorize(money, payment_source, options = {})
  request = build_purchase_or_authorization_request(money, payment_source, options)
  commit(:authorization, request)
end

- (Object) capture(money, identification, options = {})



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

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

- (Object) credit(money, identification, options = {})



84
85
86
87
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 84

def credit(money, identification, options = {})
  deprecated CREDIT_DEPRECATION_MESSAGE
  refund(money, identification, options)
end

- (Object) purchase(money, payment_source, options = {})

Funds are transferred immediately.

`payment_source` can be a usual ActiveMerchant credit_card object, or can also be a string of the `DpsBillingId` or `BillingId` which can be gotten through the store method. If you are using a `BillingId` instead of `DpsBillingId` you must also set the instance method `#use_billing_id_for_token` to true, see the `#store` method for an example of how to do this.



54
55
56
57
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 54

def purchase(money, payment_source, options = {})
  request = build_purchase_or_authorization_request(money, payment_source, options)
  commit(:purchase, request)
end

- (Object) refund(money, identification, options = {})

Refund funds to the card holder



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

def refund(money, identification, options = {})
  requires!(options, :description)

  request = build_capture_or_credit_request(money, identification, options)
  commit(:credit, request)
end

- (Object) store(credit_card, options = {})

Token Based Billing

Instead of storing the credit card details locally, you can store them inside the Payment Express system and instead bill future transactions against a token.

This token can either be specified by your code or autogenerated by the PaymentExpress system. The default is to let PaymentExpress generate the token for you and so use the `DpsBillingId`. If you do not pass in any option of the `billing_id`, then the store method will ask PaymentExpress to create a token for you. Additionally, if you are using the default `DpsBillingId`, you do not have to do anything extra in the initialization of your gateway object.

To specify and use your own token, you need to do two things.

Firstly, pass in a `:billing_id` as an option in the hash of this store method. No validation is done on this BillingId by PaymentExpress so you must ensure that it is unique.

gateway.store(credit_card, {:billing_id => 'YourUniqueBillingId'})

Secondly, you will need to pass in the option `=> true` when initializing your gateway instance, like so:

gateway = ActiveMerchant::Billing::PaymentExpressGateway.new(
  :login    => 'USERNAME',
  :password => 'PASSWORD',
  :use_custom_payment_token => true
)

see: www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Tokenbilling

Note, once stored, PaymentExpress does not support unstoring a stored card.



120
121
122
123
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 120

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