run
gem install netaxept
or include in your Gemfile:
gem 'netaxept'
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
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::ErrorMessage
s
(each with a message
, code
, source
and text
).
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).
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/
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.
To run the tests:
$ bundle
$ MERCHANT_ID=<your merchant id> NETAXEPT_TOKEN=<your token> bundle exec rspec