PHP - accepting multiple payment gateways

I am building a site where I will sell one item and want to be able to accept payments through Paypal, Google Checkout and Amazon, but don't want to use some heavy ecommerce software for just one item.

I'm looking for a good PHP solution that will make it easier to implement all 3, something like Django-Merchant for Django.

thank

+3


source to share


2 answers


If you are waiting for a proposal for an architectural design solution,

First you need to create an interface with all the methods that are required for all gateways

interface PaymentGateway {
   public function processPayment();
   public function authorize();
}

      

then create concrete classes for each payment gateway



public class GoogleCheckoutGateway extends PaymentGateway {
     public function processPayment() {
        //Code to process google checkout payment
     }
}

//Same like other payment gateways like paypal
public class PaypalCheckoutGateway extends PaymentGateway {
     public function processPayment() {
        //Code to process paypal payment
     }
}

      

then create a Business Logic method to process the payment by accessing the various gateways.

public class PaymentProcessor {
     public function processPayment(string gateway) {
        //Create the respective object depending upon gateway
        $gateway = getGateway(type);
        $response = $gateway->processPayment();
     }
}

      

This design will help you add additional gateways later

+1


source


A single element for the foreseeable future? Each of these third-party verification alternatives (just differentiating the term "gateway" which has a different meaning when paying by credit card) provides an API and sample code / SDK.

I think it is good practice for you to review them, so you have first-hand knowledge of how each work, which will help you even more in the future when the time comes for some software package - re: you can tinker with your needs and / or know how to deal with problems if / when they occur.



You might also find that whatever "order management interface" each one provides is all you really need to use (re: one item) - the classic case of falling between the hats of a developer and a business owner (you know you really want to do and / or execute).

0


source







All Articles