Skip to content

refurn/netaxept

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

10202ac415ba19212bcb009def2b60edf64f798e Installation

run

gem install netaxept

or include in your Gemfile:

gem 'netaxept'

Usage

First step is to tell Netaxept your credentials and the desired mode:

Netaxept.configure do |config|
  config.merchant_id      = ENV["NETAXEPT_MERCHANT_ID"]
  config.netaxept_token   = ENV["NETAXEPT_TOKEN"]
  config.default_currency = "SEK"
  config.environment      = :test|:production
end

To interact with Netaxept you need to create an instance of `Netaxept.client

client = Netaxept.client

General

Every request returns a Netaxept::Response object, which has a success? method. In case of an error you can call errors, which gives you a list of Netaxept::ErrorMessages (each with a message, code, source and text).

Off-site payment workflow

The following applies for the Nets hosted service type where the user is redirect to the Netaxept site to enter her payment details (see the Netaxept docs for details).

Registering a payment

client.register <amount in cents>, <order number>, <options>

Required options are currencyCode (3 letter ISO code) and redirectUrl.

On success the response object gives you a transaction_id. You pass that to client.terminal_url(<transaction id>)

For details on the options see http://www.betalingsterminal.no/Netthandel-forside/Teknisk-veiledning/API/Register/

Completing a payment

After the user has authorized the payment on the Netaxept site he is redirected to the redirectUrl you provided. Netaxept adds a resonseCode and transactionId parameter to the URL. To finalize the payment you call sale on the client.

client.sale <transaction id>, <amount in cents>

The response is a Responses::SaleResponse which only has the success? and errors methods mentioned under General.

Congratulations, you have processed a payment.

Testing

To run the tests:

$ bundle
$ MERCHANT_ID=<your merchant id> NETAXEPT_TOKEN=<your token> bundle exec rspec

Packages

No packages published

Languages

  • Ruby 100.0%