PHP code example of kodbee / jomabee-php
1. Go to this page and download the library: Download kodbee/jomabee-php 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/ */
kodbee / jomabee-php example snippets
use Kodbee\Paydiver\Paydiver;
$paydiver = new Paydiver(
apiKey: 'your_api_key',
secretKey: 'your_secret_key', //
'amount' => 500,
'product_name' => 'Premium Plan',
'customer_name' => 'Karim Mia',
'customer_email' => '[email protected] ',
'redirect_url' => 'https://yoursite.com/thank-you',
'callback_url' => 'https://yoursite.com/webhooks/paydiver',
// 'gateway' => 'bkash', // optional: lock to one gateway
// 'expiry_minutes' => 30,
]);
header('Location: ' . $payment['payment_url']); // send customer to pay
// Verify a payment with a customer-supplied TrxID
$result = $paydiver->verifyPayment('PAYD-XXXXXX', 'ABCDE12345', 'bkash');
// $result['status'] => verified | pending | failed | expired | duplicate
// Poll invoice status
$status = $paydiver->paymentStatus('PAYD-XXXXXX');
// List transactions
$txns = $paydiver->transactions(['status' => 'verified', 'per_page' => 50]);
// Balance
$balance = $paydiver->balance(); // ['currency' => 'BDT', 'verified_total' => ..., 'available' => ...]
use Kodbee\Paydiver\Webhook;
try {
$event = Webhook::verifyRequest('your_webhook_secret');
// $event['event'] === 'payment.verified'
// $event['invoice_id'], $event['trx_id'], $event['amount'], $event['gateway'] ...
} catch (\RuntimeException $e) {
http_response_code(400);
exit('Invalid signature');
}
Webhook::verify($rawJsonBody, $signature, $secret); // returns payload, throws on failure
Webhook::isValid($payloadArray, $signature, $secret); // returns bool
use Kodbee\Paydiver\Exceptions\ApiException;
use Kodbee\Paydiver\Exceptions\NetworkException;
use Kodbee\Paydiver\Exceptions\ConfigurationException;
try {
$paydiver->createPayment([...]);
} catch (ApiException $e) {
echo $e->errorCode(); // e.g. invalid_api_key, not_found
echo $e->statusCode(); // HTTP status
echo $e->getMessage();
} catch (NetworkException $e) {
// transport failure (timeout/DNS/TLS)
} catch (ConfigurationException $e) {
// missing key/secret
}
bash
composer