1. Go to this page and download the library: Download rasedi/php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rasedi / php-sdk example snippets
use Rasedi\Sdk\PaymentClient;
$privateKey = "your_private_key_content"; // Or getenv('PRIVATE_KEY')
$secretKey = 'your_secret_key';
$client = new PaymentClient(
privateKey: $privateKey,
secretKey: $secretKey
);
use Rasedi\Sdk\Interfaces\ICreatePayment;
use Rasedi\Sdk\Enum\Gateway;
$payload = new ICreatePayment(
amount: '10000', // Amount in smallest unit (e.g., cents/dinars)
gateways: [Gateway::FIB, Gateway::ZAIN],
title: 'Order #1234',
description: 'Payment for digital goods',
redirectUrl: 'https://your-site.com/return',
callbackUrl: 'https://your-site.com/webhook',
collectFeeFromCustomer: true,
collectCustomerEmail: true,
collectCustomerPhoneNumber: false
);
try {
$response = $client->createPayment($payload);
echo "Payment Created:\n";
echo "Reference: " . $response->body->referenceCode . "\n";
echo "Redirect URL: " . $response->body->redirectUrl . "\n";
// Redirect user to $response->body->redirectUrl
} catch (\Exception $e) {
echo "Error: " . $e->getMessage();
}