1. Go to this page and download the library: Download alhelwany/laravel-ecash 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/ */
enum Lang: string
{
case AR = 'AR';
case EN = 'EN';
}
enum Currency: string
{
case SYP = 'SYP'; // The only available currency by the gateway so far
}
enum CheckoutType: string
{
case QR = 'QR';
case CARD = 'Card';
}
enum PaymentStatus: string
{
case PENDING = 'pending';
case PROCESSING = 'processing';
case PAID = 'paid';
case FAILED = 'failed';
}
namespace Alhelwany\LaravelEcash\Events;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Alhelwany\LaravelEcash\Models\EcashPayment;
class PaymentStatusUpdated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct(private EcashPayment $paymentModel)
{
}
public function getPaymentModel(): EcashPayment
{
return $this->paymentModel;
}
}
use App\Http\Controllers\Controller;
use Alhelwany\LaravelEcash\Facades\LaravelEcashClient;
use Alhelwany\LaravelEcash\DataObjects\PaymentDataObject;
use Alhelwany\LaravelEcash\Models\EcashPayment;
use Alhelwany\LaravelEcash\Enums\CheckoutType;
use Alhelwany\LaravelEcash\Enums\Lang;
use Alhelwany\LaravelEcash\Enums\Currency;
class ExampleController extends Controller
{
public function checkout($request)
{
$paymentDataObject = new PaymentDataObject(CheckoutType::CARD, 100.10);
$paymentDataObject->setRedirectUrl(route('payment-successful')); //optional
$paymentDataObject->setLang(Lang::EN); //optional
$paymentDataObject->setCurrency(Currency::SYP); //optional
$model = LaravelEcashClient::checkout($paymentDataObject);
// You may attach the EcashPayment model to your order
return redirect($model['checkout_url']);
}
}