Class: ActiveMerchant::Billing::NetpayGateway
- Defined in:
- lib/active_merchant/billing/gateways/netpay.rb
Overview
NETPAY Gateway
Support for NETPAY’s HTTP Connector payment gateway in Mexico.
The gateway sends requests as HTTP POST and receives the response details in the HTTP header, making the process really rather simple.
Support for calls to the authorize and capture methods have been included as per the Netpay manuals, however, your millage may vary with these methods. At the time of writing (January 2013) they were not fully supported by the production or test gateways. This situation is expected to change within a few weeks/months.
Purchases can be cancelled (‘#void`) only within 24 hours of the transaction. After this, a refund should be performed instead.
In addition to the regular ActiveMerchant transaction options, NETPAY also supports a ‘:mode` parameter. This allows testing to be performed in production and force specific results.
* 'P' - Production
* 'A' - Approved
* 'D' - Declined
* 'R' - Random (Approved or Declined)
* 'T' - Test
For example:
response = @gateway.purchase(1000, card, :mode => 'D')
response.success # false
Constant Summary collapse
- CURRENCY_CODES =
{ "MXN" => '484' }
- RESPONSE_KEYS =
The header keys that we will provide in the response params hash
['ResponseMsg', 'ResponseText', 'ResponseCode', 'TimeIn', 'TimeOut', 'AuthCode', 'OrderId', 'CardTypeName', 'MerchantId', 'IssuerAuthDate']
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#authorize(money, creditcard, options = {}) ⇒ Object
Send an authorization request.
-
#capture(money, authorization, options = {}) ⇒ Object
Capture an authorization.
-
#initialize(options = {}) ⇒ NetpayGateway
constructor
A new instance of NetpayGateway.
-
#purchase(money, creditcard, options = {}) ⇒ Object
Make a purchase.
-
#refund(money, authorization, options = {}) ⇒ Object
Perform a Credit transaction.
-
#void(authorization, options = {}) ⇒ Object
Cancel an auth/purchase within first 24 hours.
Methods inherited from Gateway
#card_brand, card_brand, #generate_unique_id, inherited, non_fractional_currency?, #scrub, 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 = {}) ⇒ NetpayGateway
Returns a new instance of NetpayGateway.
60 61 62 63 |
# File 'lib/active_merchant/billing/gateways/netpay.rb', line 60 def initialize( = {}) requires!(, :store_id, :login, :password) super end |
Instance Method Details
#authorize(money, creditcard, options = {}) ⇒ Object
Send an authorization request
66 67 68 69 70 71 72 73 74 |
# File 'lib/active_merchant/billing/gateways/netpay.rb', line 66 def (money, creditcard, = {}) post = {} add_invoice(post, ) add_creditcard(post, creditcard) add_customer_data(post, ) add_amount(post, money, ) commit('PreAuth', post, ) end |
#capture(money, authorization, options = {}) ⇒ Object
Capture an authorization
77 78 79 80 81 82 83 |
# File 'lib/active_merchant/billing/gateways/netpay.rb', line 77 def capture(money, , = {}) post = {} add_order_id(post, order_id_from()) add_amount(post, money, ) commit('PostAuth', post, ) end |
#purchase(money, creditcard, options = {}) ⇒ Object
Make a purchase.
97 98 99 100 101 102 103 104 105 |
# File 'lib/active_merchant/billing/gateways/netpay.rb', line 97 def purchase(money, creditcard, = {}) post = {} add_invoice(post, ) add_creditcard(post, creditcard) add_customer_data(post, ) add_amount(post, money, ) commit('Auth', post, ) end |
#refund(money, authorization, options = {}) ⇒ Object
Perform a Credit transaction.
108 109 110 111 112 113 114 115 |
# File 'lib/active_merchant/billing/gateways/netpay.rb', line 108 def refund(money, , = {}) post = {} add_order_id(post, order_id_from()) add_amount(post, money, ) #commit('Refund', post, options) commit('Credit', post, ) end |
#void(authorization, options = {}) ⇒ Object
Cancel an auth/purchase within first 24 hours
86 87 88 89 90 91 92 93 94 |
# File 'lib/active_merchant/billing/gateways/netpay.rb', line 86 def void(, = {}) post = {} order_id, amount, currency = () add_order_id(post, order_id) post['Total'] = ([:amount] || amount) post['CurrencyCode'] = currency commit('Refund', post, ) end |