21 lines
522 B
PHP
21 lines
522 B
PHP
<?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);
|
|
}
|
|
}
|