Installation
$ gem install paysio
Usage
Paysio.api_key = 'YOUR_API_KEY'
Paysio::Charge.all
Paysio Objects
Paysio::Charge.all Paysio::Wallet.all Paysio::Coupon.all Paysio::Reward.all Paysio::Event.all Paysio::Log.all Paysio::Customer.all
Actions: update
customer = Paysio::Customer.retrieve("cs_1111111")
customer.description = "test user"
customer.save
Actions: destroy
customer = Paysio::Customer.retrieve("cs_1111111")
customer.destroy
Actions: refund charge
charge = Paysio::Charge.retrieve("ch_1111111")
charge.refund
Sample: redirect to charge after create (e.g. in Ruby on Rails)
def create
charge = Paysio::Charge.create(amount: 100, payment_system_id: 't_123', description: 'test charge')
redirect_to charge.redirect
end
Sample: handle webhook events
def webhook
Paysio.api_key = 'HZClZur5OW3BYimWSydQNsArbph2L7IRo0ql8HK'
event = Paysio::Event.new(params)
end
Sample: handle webhook events, with getting event from api
def webhook
Paysio.api_key = 'HZClZur5OW3BYimWSydQNsArbph2L7IRo0ql8HK'
event = Paysio::Event.retrieve(params['id'])
if event.data.object == 'charge':
if event.type == 'charge.success'
pass #logic for charge success
elsif event.type == 'charge.failure'
pass #logic for charge failure
elsif event.type == 'charge.refund'
pass #logic for charge refund
end
end
end
gist.github.com/gvalmon/104ee698608fee04fae4