File: D:/HostingSpaces/SBogers10/rentman2019.komma.pro/app/Komma/Shop/Payment/PaymentService.php
<?php
namespace App\Komma\Shop\Payment;
use App\Komma\Shop\Payment\PSPAdapters\AbstractPSPAdapter;
use Illuminate\Support\Facades\App;
/**
* Class PaymentService
*
* The payment service returns Adapters which help handling
* payments for different PSPs.
*/
class PaymentService implements PaymentServiceInterface
{
/**
* Returns the concrete adapter.
* e.g. An adapter that extends this class.
*
* The adapter knows how to both work with KMS and
* a script from a PSP to process payments
*
* @return AbstractPSPAdapter
*/
public function getAdapter(): AbstractPSPAdapter
{
$psp = config('payment.payment_service_provider');
$adapterConfigKey = 'payment.payment_service_providers.'.$psp.'.'.App::environment().'.adapter';
$adapter = config($adapterConfigKey);
if (! $adapter || ! is_a($adapter, AbstractPSPAdapter::class, true)) {
throw new \RuntimeException('The following payment configuration key did not exist or did not return a childclass of "'.AbstractPSPAdapter::class.'": '.$adapterConfigKey);
}
return \App::make($adapter);
}
}