PHP¶
oura/oura · source
Requires PHP 7.4+. Works with plain PHP, Laravel, Symfony and others. This SDK holds your secret key, so use it only on a server.
Install¶
Accept a payment¶
use Oura\Client;
$oura = new Client(getenv('OURA_SECRET_KEY'));
$payment = $oura->payments->create([
'amount' => 245000, // NPR 2,450.00 in paisa
'methods' => ['esewa', 'khalti'],
'reference' => 'order_1042',
'return_url' => 'https://himalstore.com.np/orders/1042',
]);
header('Location: ' . $payment['checkout_url']);
Other calls¶
$oura->payments->retrieve('pay_123');
$oura->payments->list(20, 'pay_123');
$oura->payments->cancel('pay_123');
$oura->payments->create($params, "order_{$orderId}");
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::constructEvent($raw, $sig, $secret) and Webhooks::verify($raw, $sig, $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\OuraError (code in $e->errorCode) with the error code, HTTP status and message. See Errors.