Installation
gem install khipu-api-client
Usage
Basic configuration
require 'khipu-api-client'
Khipu.configure do |c|
c.secret = 'abc123'
c.receiver_id = 1234
c.platform = 'my-ecomerce'
c.platform_version = '1.0'
end
Basic usage
Create a new payment
api = Khipu::PaymentsApi.new()
options = {
expires_date: Time.now + (24*60*60)
send_email: true,
payer_name: "payer",
payer_email: "payer@mail.com"
}
response = api.payments_post("Test de api nueva", "CLP", 1, options)
print response
There are a more params you can send in each request. You might want to consider adding these to the options:
transaction_id
return_url
cancel_url
notify_url
notify_api_version
Ask for payment status
api = Khipu::PaymentsApi.new()
status = api.payments_id_get(response.payment_id)
print status
Confirm a payment
If you send a notification_url when creating the payment or if you have set it up on your account configuration, Khipu will sent you a request with a notification_token and a api_version. You can use the notification_token param to get the payment information from the khipu service.
notification_token = params["notification_token"]
client = Khipu::PaymentsApi.new
response = client.payments_get(notification_token)
if response.status == 'done'
end
print response
Documentation