Class: ActiveMerchant::Billing::NetpayGateway

Inherits:
Gateway
  • Object
show all
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

%w[ResponseMsg ResponseText ResponseCode TimeIn TimeOut AuthCode OrderId CardTypeName MerchantId IssuerAuthDate]

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#add_field_to_post_if_present, #add_fields_to_post_if_present, card_brand, #card_brand, #generate_unique_id, inherited, #scrub, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#format

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(options = {})
  requires!(options, :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 authorize(money, creditcard, options = {})
  post = {}
  add_invoice(post, options)
  add_creditcard(post, creditcard)
  add_customer_data(post, options)
  add_amount(post, money, options)

  commit('PreAuth', post, options)
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, authorization, options = {})
  post = {}
  add_order_id(post, order_id_from(authorization))
  add_amount(post, money, options)

  commit('PostAuth', post, options)
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, options = {})
  post = {}
  add_invoice(post, options)
  add_creditcard(post, creditcard)
  add_customer_data(post, options)
  add_amount(post, money, options)

  commit('Auth', post, options)
end

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

Perform a Credit transaction.



108
109
110
111
112
113
114
# File 'lib/active_merchant/billing/gateways/netpay.rb', line 108

def refund(money, authorization, options = {})
  post = {}
  add_order_id(post, order_id_from(authorization))
  add_amount(post, money, options)

  commit('Credit', post, options)
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(authorization, options = {})
  post = {}
  order_id, amount, currency = split_authorization(authorization)
  add_order_id(post, order_id)
  post['Total'] = (options[:amount] || amount)
  post['CurrencyCode'] = currency

  commit('Refund', post, options)
end