$context Extra data required for specific methods (e.g. cc.pseudocardpan, elv.iban). * * @throws InvalidArgumentException for unknown method strings. */ public static function resolve(string $paymentMethod, array $context = []): PayoneMethodConfig { if (str_contains($paymentMethod, '#')) { [$type, $subtype] = explode('#', $paymentMethod, 2); return match ($type) { 'wlt' => new PayoneMethodConfig([ 'clearingtype' => 'wlt', 'wallettype' => $subtype, 'onlinebanktransfertype' => '', 'request' => 'authorization', ]), 'sb' => new PayoneMethodConfig([ 'clearingtype' => 'sb', 'wallettype' => '', 'onlinebanktransfertype' => $subtype, 'bankcountry' => 'DE', 'request' => 'authorization', ]), 'fnc' => match ($subtype) { 'MIV' => new PayoneMethodConfig([ 'clearingtype' => 'fnc', 'wallettype' => '', 'onlinebanktransfertype' => 'MIV', 'request' => 'authorization', ]), default => throw new InvalidArgumentException("Unknown fnc subtype: {$subtype}"), }, default => throw new InvalidArgumentException("Unknown compound payment method type: {$type}"), }; } return match ($paymentMethod) { 'cc' => new PayoneMethodConfig([ 'clearingtype' => 'cc', 'wallettype' => '', 'onlinebanktransfertype' => '', 'request' => 'authorization', 'pseudocardpan' => $context['cc']['pseudocardpan'] ?? '', ]), 'elv' => new PayoneMethodConfig([ 'clearingtype' => 'elv', 'wallettype' => '', 'onlinebanktransfertype' => '', 'request' => 'authorization', 'mandate_identification' => $context['elv']['mandate_identification'] ?? '', 'iban' => $context['elv']['iban'] ?? '', 'bic' => $context['elv']['bic'] ?? '', 'bankaccountholder' => $context['elv']['bankaccountholder'] ?? '', ]), 'vor' => new PayoneMethodConfig([ 'clearingtype' => 'vor', 'wallettype' => '', 'onlinebanktransfertype' => '', 'request' => 'authorization', ]), default => throw new InvalidArgumentException("Unknown payment method: {$paymentMethod}"), }; } }