diff --git a/app/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/PaymentDrivers/PayPalExpressPaymentDriver.php index 6cea7b0a6df5..3bd32aa489f1 100644 --- a/app/PaymentDrivers/PayPalExpressPaymentDriver.php +++ b/app/PaymentDrivers/PayPalExpressPaymentDriver.php @@ -69,6 +69,10 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver protected $customer_reference = ''; + public function setPaymentMethod($payment_method_id = null) + { + return $this; + } public function gatewayTypes() { diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index e71080fd7c21..46e3e806acbd 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -21,6 +21,10 @@ use App\Models\Invoice; use App\Models\Payment; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Stripe\ACH; +use App\PaymentDrivers\Stripe\Alipay; +use App\PaymentDrivers\Stripe\CreditCard; +use App\PaymentDrivers\Stripe\SOFORT; use App\PaymentDrivers\Stripe\Utilities; use App\Utils\Traits\MakesHash; use Illuminate\Http\Request; @@ -43,6 +47,15 @@ class StripePaymentDriver extends BasePaymentDriver protected $payment_method; + public static $methods = [ + GatewayType::CREDIT_CARD => CreditCard::class, + GatewayType::BANK_TRANSFER => ACH::class, + GatewayType::ALIPAY => Alipay::class, + GatewayType::SOFORT => SOFORT::class, + GatewayType::APPLE_PAY => 1, + GatewayType::SEPA => 1, + ]; + /** * Methods in this class are divided into * two separate streams @@ -65,11 +78,11 @@ class StripePaymentDriver extends BasePaymentDriver Stripe::setApiKey($this->company_gateway->getConfigField('apiKey')); } - public function setPaymentMethod(string $method) + public function setPaymentMethod($payment_method_id) { - // Example: setPaymentMethod('App\\PaymentDrivers\\Stripe\\CreditCard'); - - $this->payment_method = new $method($this); + $class = self::$methods[$payment_method_id]; + + $this->payment_method = new $class($this); return $this; }