Currently, I am handling stripe payments with Omnipay's Stripe library. Similar with the example below:
$gateway = Omnipay::create('Stripe');
$gateway->setApiKey("sk_test_xHGgkZtGOlTwxi4d8GYOHifZ");
$formData = array('number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2030', 'cvv' => '123');
$response = $gateway->purchase(array('amount' => '10.00', 'currency' => 'USD', 'card' => $formData))->send();
However, there are too much different payment gateways. Let's assume, I've both Paypal and Stripe packages of omnipay. How can I handle the omnipay package that selected as a default on db. I don't know what to do. Ofcourse, You could say simply use if
and else
. But, it's not a good in practice. What sticks my mind and bother me is implementing this idea with a generic way with the S.O.L.I.D. principles in Laravel.