1. Go to this page and download the library: Download asciisd/kashier 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/ */
asciisd / kashier example snippets
use Asciisd\Kashier\Facades\Kashier;
// Generate a payment URL
$paymentUrl = Kashier::buildPaymentUrl(
amount: 100, // Amount in the smallest currency unit (e.g., piasters for EGP)
orderId: 'order-123', // Your unique order ID
attributes: [
'customerName' => 'John Doe',
'customerEmail' => '[email protected]',
'customerMobile' => '01234567890',
// Additional attributes as needed
]
);
// Redirect the user to the payment URL
return redirect()->away($paymentUrl);
use Asciisd\Kashier\Facades\Kashier;
// Allow only specific payment methods
$paymentUrl = Kashier::setAllowedMethods('card,wallet')
->buildPaymentUrl(100, 'order-123');
use Asciisd\Kashier\Events\KashierResponseHandled;
use Illuminate\Support\Facades\Event;
Event::listen(function (KashierResponseHandled $event) {
$paymentData = $event->payload;
// Process the payment data
// $paymentData['paymentStatus'] contains the payment status
// $paymentData['merchantOrderId'] contains your order ID
// ...
});
use Asciisd\Kashier\Events\KashierWebhookHandled;
use Illuminate\Support\Facades\Event;
Event::listen(function (KashierWebhookHandled $event) {
$webhookData = $event->payload;
// Process the webhook data
// Update order status, send notifications, etc.
});
use Asciisd\Kashier\Facades\Kashier;
try {
$transactionDetails = Kashier::getTransactionDetails('order-123');
// Process transaction details
// $transactionDetails['paymentStatus'] contains the payment status
// ...
} catch (Exception $e) {
// Handle error
}