Ruby¶
oura · source
Requires Ruby 2.6+. No runtime dependencies. This SDK holds your secret key, so use it only on a server.
Install¶
Accept a payment¶
require 'oura'
oura = Oura::Client.new(ENV.fetch('OURA_SECRET_KEY'))
payment = oura.payments.create(
amount: 245000, # NPR 2,450.00 in paisa
methods: %w[esewa khalti],
return_url: 'https://himalstore.com.np/orders/1042'
)
redirect_to payment['checkout_url'], allow_other_host: true
Other calls¶
oura.payments.retrieve('pay_123')
oura.payments.list(limit: 20, starting_after: 'pay_123')
oura.payments.cancel('pay_123')
oura.payments.create(params, idempotency_key: "order_#{order_id}")
An idempotency key is generated for every create. Pass your own, tied to your order, to make retries safe across restarts. See Idempotency.
Configuration¶
Point the client at a local API while developing:
Webhooks¶
Verify with Oura::Webhooks.construct_event(raw, header, secret) and Oura::Webhooks.verify(raw, header, secret, 300). Both compare in constant time and reject stale timestamps. Always pass the raw request body. Full example: Webhooks.
Errors¶
Every non-2xx response raises Oura::Error with the error code, HTTP status and message. See Errors.