Class: ActiveMerchant::Billing::NetRegistryGateway

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

Overview

Gateway for netregistry.com.au.

Note that NetRegistry itself uses gateway service providers. At the time of this writing, there are at least two (Quest and Ingenico). This module has only been tested with Quest.

Also note that NetRegistry does not offer a test mode, nor does it have support for the authorize/capture/void functionality by default (you may arrange for this as described in “Programming for NetRegistry’s E-commerce Gateway.” [rubyurl.com/hNG]), and no #void functionality is documented. As a result, the #authorize and #capture have not yet been tested through a live gateway, and #void will raise an error.

If you have this functionality enabled, please consider contributing to ActiveMerchant by writing tests/code for these methods, and submitting a patch.

In addition to the standard ActiveMerchant functionality, the response will contain a ‘receipt’ parameter (response.params) if a receipt was issued by the gateway.

Constant Summary collapse

URL =
'https://4tknox.au.com/cgi-bin/themerchant.au.com/ecom/external2.pl'
FILTERED_PARAMS =
[ 'card_no', 'card_expiry', 'receipt_array' ]
TRANSACTIONS =
{
  :authorization => 'preauth',
  :purchase => 'purchase',
  :capture => 'completion',
  :status => 'status',
  :credit => 'refund'
}

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

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, #retry_exceptions, #ssl_post

Constructor Details

#initialize(options = {}) ⇒ NetRegistryGateway

Create a new NetRegistry gateway.

Options :login and :password must be given.



50
51
52
53
54
# File 'lib/active_merchant/billing/gateways/net_registry.rb', line 50

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

Instance Method Details

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

Note that #authorize and #capture only work if your account vendor is St George, and if your account has been setup as described in “Programming for NetRegistry’s E-commerce Gateway.” [rubyurl.com/hNG]



60
61
62
63
64
65
66
67
68
# File 'lib/active_merchant/billing/gateways/net_registry.rb', line 60

def authorize(money, credit_card, options = {})
  params = {
    'AMOUNT'  => amount(money),
    'CCNUM'   => credit_card.number,
    'CCEXP'   => expiry(credit_card)
  }
  add_request_details(params, options)
  commit(:authorization, params)
end

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

Note that #authorize and #capture only work if your account vendor is St George, and if your account has been setup as described in “Programming for NetRegistry’s E-commerce Gateway.” [rubyurl.com/hNG]



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/active_merchant/billing/gateways/net_registry.rb', line 74

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

  params = {
    'PREAUTHNUM' => authorization,
    'AMOUNT'     => amount(money),
    'CCNUM'      => credit_card.number,
    'CCEXP'      => expiry(credit_card)
  }
  add_request_details(params, options)
  commit(:capture, params)
end

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



97
98
99
100
101
102
103
104
# File 'lib/active_merchant/billing/gateways/net_registry.rb', line 97

def credit(money, identification, options = {})
  params = {
    'AMOUNT'  => amount(money),
    'TXNREF'  => identification
  }
  add_request_details(params, options)
  commit(:credit, params)
end

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



87
88
89
90
91
92
93
94
95
# File 'lib/active_merchant/billing/gateways/net_registry.rb', line 87

def purchase(money, credit_card, options = {})
  params = {
    'AMOUNT'  => amount(money),
    'CCNUM'   => credit_card.number,
    'CCEXP'   => expiry(credit_card)
  }
  add_request_details(params, options)
  commit(:purchase, params)
end

#status(identification) ⇒ Object

Specific to NetRegistry.

Run a ‘status’ command. This lets you view the status of a completed transaction.



111
112
113
114
115
116
117
# File 'lib/active_merchant/billing/gateways/net_registry.rb', line 111

def status(identification)
  params = {
    'TXNREF'  => identification
  }
  
  commit(:status, params)
end