Class: ActiveMerchant::Billing::PaymentExpressGateway
- 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
- 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
Instance Method Summary collapse
-
#authorize(money, payment_source, 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.
-
#capture(money, identification, options = {}) ⇒ Object
Transfer pre-authorized funds immediately See: www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Authcomplete.
- #credit(money, identification, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ PaymentExpressGateway
constructor
We require the DPS gateway username and password when the object is created.
-
#purchase(money, payment_source, options = {}) ⇒ Object
Funds are transferred immediately.
-
#refund(money, identification, options = {}) ⇒ Object
Refund funds to the card holder.
-
#store(credit_card, options = {}) ⇒ Object
Token Based Billing.
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?, #test?
Methods included from CreditCardFormatting
Constructor Details
#initialize(options = {}) ⇒ PaymentExpressGateway
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 46 47 48 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 42 def initialize( = {}) # A DPS username and password must exist requires!(, :login, :password) # Make the options an instance variable @options = super end |
Instance Method Details
#authorize(money, payment_source, 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
‘payment_source` can be a usual ActiveMerchant credit_card object or a token, see #purchased method
67 68 69 70 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 67 def (money, payment_source, = {}) request = (money, payment_source, ) commit(:authorization, request) end |
#capture(money, identification, options = {}) ⇒ Object
Transfer pre-authorized funds immediately See: www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Authcomplete
74 75 76 77 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 74 def capture(money, identification, = {}) request = build_capture_or_credit_request(money, identification, ) commit(:capture, request) end |
#credit(money, identification, options = {}) ⇒ Object
87 88 89 90 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 87 def credit(money, identification, = {}) deprecated CREDIT_DEPRECATION_MESSAGE refund(money, identification, ) end |
#purchase(money, payment_source, options = {}) ⇒ Object
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.
57 58 59 60 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 57 def purchase(money, payment_source, = {}) request = (money, payment_source, ) commit(:purchase, request) end |
#refund(money, identification, options = {}) ⇒ Object
Refund funds to the card holder
80 81 82 83 84 85 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 80 def refund(money, identification, = {}) requires!(, :description) request = build_capture_or_credit_request(money, identification, ) commit(:credit, request) end |
#store(credit_card, options = {}) ⇒ Object
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.
123 124 125 126 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 123 def store(credit_card, = {}) request = build_token_request(credit_card, ) commit(:validate, request) end |