Payture InPay API implementation
Add this line to your application's Gemfile:
gem 'paytureman'
And then execute:
$ bundle
Or install it yourself as:
$ gem install paytureman
require 'paytureman'
Paytureman::Configuration.setup do |config|
config.host = "sandbox"
config.key = "MerchantKey"
config.password = "123"
end
# or you can use several configs
Paytureman::Configuration.setup :production do |config|
config.host = "secure"
config.key = "Merchant12345"
config.password = "password"
end
order_id = SecureRandom.uuid # generate an order ID
amount = 123.15 # amount to be charged
customer_ip = "123.45.67.89" # customer's IP address
# create initial payment
payment = Paytureman::PaymentNew.new(order_id, amount, customer_ip)
# in case with several configs
payment = Paytureman::PaymentNew.new(order_id, amount, customer_ip, :production)
# prepare it
description = Paytureman::PaymentDescription.new(product: 'Paytureman demo payment', total: amount, url: '...success url...')
payment = payment.prepare(description)
# ... assert(payment.kind_of?(Paytureman::PaymentPrepared))
puts "Please, visit #{payment.url} to proceed with the payment. Then press Enter."
gets
# mark it as blocked
payment = payment.blocked
# ... assert(payment.kind_of?(Paytureman::PaymentBlocked))
# charge the customer
payment = payment.charge
# ... assert(payment.kind_of?(Paytureman::PaymentCharged))
- Fork it ( http://github.com/SkyWriter/paytureman/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request