@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Billing;
|
||||
|
||||
use App\Billing\Contracts\PaymentGateway;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class PaymentGatewayManager
|
||||
{
|
||||
public function driver(?string $name = null): PaymentGateway
|
||||
{
|
||||
$name ??= config('billing.default_gateway');
|
||||
$class = config("billing.gateways.{$name}");
|
||||
if (! $class || ! is_a($class, PaymentGateway::class, true)) {
|
||||
throw new InvalidArgumentException("Payment gateway [{$name}] tidak tersedia.");
|
||||
}
|
||||
|
||||
return app($class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user