Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
81.82% |
9 / 11 |
|
66.67% |
4 / 6 |
CRAP | |
0.00% |
0 / 1 |
| NagadDriver | |
81.82% |
9 / 11 |
|
66.67% |
4 / 6 |
6.22 | |
0.00% |
0 / 1 |
| key | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| label | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| configSchema | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| charge | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| verify | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isImplemented | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Services\Payment\Drivers; |
| 4 | |
| 5 | use App\Models\Order; |
| 6 | use App\Services\Payment\PaymentResult; |
| 7 | use Illuminate\Http\Request; |
| 8 | |
| 9 | /** |
| 10 | * Scaffolded, not wired to a real charge yet. Nagad's merchant API signs |
| 11 | * every request/response with RSA (a merchant-issued private key + Nagad's |
| 12 | * public key) rather than a simple token — getting that checksum/signature |
| 13 | * step subtly wrong is a real risk to get right without a live sandbox to |
| 14 | * test against, so this driver declares its config shape (the settings |
| 15 | * page shows a real card for it) but refuses to charge until someone |
| 16 | * finishes it against Nagad's current merchant docs and verifies it live. |
| 17 | * SSLCommerz already covers Nagad indirectly for stores that don't need a |
| 18 | * direct integration. |
| 19 | */ |
| 20 | class NagadDriver extends AbstractDriver |
| 21 | { |
| 22 | public function key(): string |
| 23 | { |
| 24 | return 'nagad'; |
| 25 | } |
| 26 | |
| 27 | public function label(): string |
| 28 | { |
| 29 | return 'Nagad'; |
| 30 | } |
| 31 | |
| 32 | public function configSchema(): array |
| 33 | { |
| 34 | return [ |
| 35 | 'merchant_id' => ['type' => 'text', 'label' => 'Merchant ID', 'required' => true], |
| 36 | 'merchant_private_key' => ['type' => 'password', 'label' => 'Merchant Private Key (PEM)', 'required' => true], |
| 37 | 'nagad_public_key' => ['type' => 'password', 'label' => "Nagad's Public Key (PEM)", 'required' => true], |
| 38 | 'sandbox' => ['type' => 'toggle', 'label' => 'Sandbox mode', 'default' => true], |
| 39 | ]; |
| 40 | } |
| 41 | |
| 42 | public function charge(Order $order, array $config): PaymentResult |
| 43 | { |
| 44 | return $this->notImplemented(); |
| 45 | } |
| 46 | |
| 47 | public function verify(Request $request, array $config): PaymentResult |
| 48 | { |
| 49 | return $this->notImplemented(); |
| 50 | } |
| 51 | |
| 52 | public function isImplemented(): bool |
| 53 | { |
| 54 | return false; |
| 55 | } |
| 56 | } |