1. Go to this page and download the library: Download mostafax/payment-engine 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/ */
// In EventServiceProvider::boot()
use Mostafax\PaymentEngine\Events\PaymentCaptured;
Event::listen(PaymentCaptured::class, function (PaymentCaptured $event) {
Order::find($event->transaction->metadata['order_id'])?->markAsPaid();
});
use Mostafax\PaymentEngine\Contracts\PaymentDriverInterface;
use Mostafax\PaymentEngine\DTOs\InitiatePaymentDTO;
use Mostafax\PaymentEngine\DTOs\GatewayResponseDTO;
final class MyGatewayDriver implements PaymentDriverInterface
{
public function initiate(InitiatePaymentDTO $dto): array { ... }
public function handleCallback(array $payload): GatewayResponseDTO { ... }
public function inquire(string $trackId, ?float $amount = null): GatewayResponseDTO { ... }
public function fetchTransactions(string $from, string $to, int $page = 1, int $perPage = 500): array { ... }
public function getGatewayName(): string { return 'my-gateway'; }
public function getSupportedCurrencies(): array { return ['KWD', 'USD']; }
}