0.0
No commit activity in last 3 years
No release in over 3 years
Client for consuming the Paytrail API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 0.11
~> 12.1
~> 3.7
~> 0.15
~> 3.0
~> 3.1

Runtime

 Project Readme

paytrail-client

Build Status Code Climate Test Coverage Gem Version

Paytrail client for the Paytrail API. Please refer to the Paytrail documentation for more information.

Installation

Add this line to your application's Gemfile:

gem 'paytrail-client'

Usage

require 'paytrail-client'

# Configure the client with your merchant credentials
PaytrailClient.configure do |config|
  config.merchant_id     = 12345
  config.merchant_secret = 'your_merchant_secret'
end

# Call Paytrail API for a payment token.
# The client supports passing the object keys as snake_case or camelCase.
token = PaytrailClient::Payment.create(order_number: '1234',
                               currency: 'EUR',
                               locale: 'en_US',
                               url_set: {
                                 success: 'http://www.example.org/success',
                                 failure: 'http://www.example.org/failure',
                                 notification: 'http://www.example.org/notification'
                               },
                               price: 100.50)

# Redirect to received url
redirect_to(token['url'])


# Verify payment

begin
  PaytrailClient::Payment.verify_payment!(
                            params['ORDER_NUMBER'],
                            params['TIMESTAMP'],
                            params['PAID'],
                            params['METHOD'],
                            params['RETURN_AUTHCODE'])
  puts 'Payment verified'
rescue PaytrailClient::InvalidPaymentError
  puts 'Could not verify payment'
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/anakinj/paytrail-client.

License

The gem is available as open source under the terms of the MIT License.