HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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);
    }
}