NICEPay Ruby Binding
Ruby SDK API Operation Test
Virtual Account
$ ruby test-va.rb
----------------------------------------------------------------------
Virtual Account Number : 7001400000000631
Description : Payment of Invoice-7834
Reference No : Invoice-7834
Transaction ID : VACCTCLOSE02201606061649584906
----------------------------------------------------------------------
Card Checkout
$ ruby test-card.rb
-----------------------------------------------------------------------------------------------------
Redirect Customer to : https://www.nicepay.co.id/nicepay/api/orderInquiry.do?tXid=IONPAYTEST01201606061651114907
tXid : IONPAYTEST01201606061651114907
-----------------------------------------------------------------------------------------------------
Check Transaction Status
$ ruby test-status.rb
----------------------------------------------------------------------
Transaction Status : 3
Amount : 3000
Reference No : Invoice-7834
Transaction ID : VACCTCLOSE02201606061354204825
----------------------------------------------------------------------
Ruby on Rails
Install NICEPay Gem
$ gem install nicepay
or build from source
$ gem build nicepay.gemspec
Create checkout controller
$ rails g controller checkout
Add action to controller
def new end def create # Amount in cents @amount = 500 requestVa= Nicepay::Api::RequestVa.new(Nicepay.requestParam) chargeCard= Nicepay::Api::ChargeCard.new(Nicepay.requestParam) checkStatus=Nicepay::Api::CheckStatus.new(Nicepay.requestParam) end
Define Route
resources :checkout
Configure application
Rails.configuration.nicepay = { :iMid=> ENV['I_MID'], :merchantKey=> ENV['MERCHANT_KEY'] } Nicepay.merchantKey= Rails.configuration.nicepay[:merchantKey] Nicepay.iMid= Rails.configuration.nicepay[:iMid]
Create view
Create a checkout.html.erb layout under app/views/layouts:
<!DOCTYPE html> <html> <head> </head> <body> <%= yield %> </body> </html>
and so on...