Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
3 / 4
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
AbstractDriver
75.00% covered (warning)
75.00%
3 / 4
50.00% covered (danger)
50.00%
1 / 2
2.06
0.00% covered (danger)
0.00%
0 / 1
 refund
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 notImplemented
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Services\Payment\Drivers;
4
5use App\Models\Payment;
6use App\Services\Payment\Contracts\PaymentGatewayContract;
7use App\Services\Payment\PaymentResult;
8
9abstract class AbstractDriver implements PaymentGatewayContract
10{
11    public function refund(Payment $payment, float $amount, array $config): bool
12    {
13        // Most drivers here don't yet support refunds through the API —
14        // override in a driver that does. Never throws: the caller shows
15        // "not supported" instead of a crash.
16        return false;
17    }
18
19    /**
20     * A driver that hasn't been wired to a real provider yet (see class doc
21     * on whichever driver calls this) refuses instead of silently
22     * pretending to charge — a misconfigured/unfinished gateway must never
23     * look like it worked.
24     */
25    protected function notImplemented(): PaymentResult
26    {
27        return PaymentResult::failed(
28            "{$this->label()} isn't finished yet — this driver's API integration needs the operator's real merchant credentials and a live sandbox test before it can process payments. Use Cash on Delivery or another gateway for now."
29        );
30    }
31}