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::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
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.
- #scrub(transcript) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
Token Based Billing.
- #supports_scrubbing ⇒ Object
- #verify(money, payment_source, options = {}) ⇒ Object
Methods inherited from Gateway
#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?
Methods included from CreditCardFormatting
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
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 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 42 def initialize( = {}) requires!(, :login, :password) 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
64 65 66 67 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 64 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
71 72 73 74 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 71 def capture(money, identification, = {}) request = build_capture_or_credit_request(money, identification, ) commit(:capture, request) end |
#credit(money, identification, options = {}) ⇒ Object
84 85 86 87 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 84 def credit(money, identification, = {}) ActiveMerchant.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.
54 55 56 57 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 54 def purchase(money, payment_source, = {}) request = (money, payment_source, ) commit(:purchase, request) end |
#refund(money, identification, options = {}) ⇒ Object
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, = {}) requires!(, :description) request = build_capture_or_credit_request(money, identification, ) commit(:credit, request) end |
#scrub(transcript) ⇒ Object
134 135 136 137 138 139 140 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 134 def scrub(transcript) transcript. gsub(%r((<PostPassword>).+(</PostPassword>)), '\1[FILTERED]\2'). gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]\2'). gsub(%r((<CardNumber>)\d+(</CardNumber>)), '\1[FILTERED]\2'). gsub(%r((<Cvc2>)\d+(</Cvc2>)), '\1[FILTERED]\2') 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.
125 126 127 128 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 125 def store(credit_card, = {}) request = build_token_request(credit_card, ) commit(:validate, request) end |
#supports_scrubbing ⇒ Object
130 131 132 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 130 def supports_scrubbing true end |
#verify(money, payment_source, options = {}) ⇒ Object
89 90 91 92 |
# File 'lib/active_merchant/billing/gateways/payment_express.rb', line 89 def verify(money, payment_source, = {}) request = (money, payment_source, ) commit(:validate, request) end |