4elements, web design and consultancy

  1. Create a Custom Payment Method in OpenCart: Part 1

    Accepting online payments is an essential feature in any eCommerce website. In this series, we're going to explore the payment methods available for OpenCart. 

    We'll start in this tutorial by discussing OpenCart's built-in payment methods. Then later, we'll see how to create a custom payment method, which is the ultimate goal of this series.

    OpenCart comes with lots of built-in payment modules. Most probably, you'll find the payment method of your choice already available. If that's not the case, there are plenty of third-party payment extensions available in the OpenCart store.

    Lets start with the back-end section to see how things look.

    The Back-End

    Head over to the back-end section of your store. Go to Extensions > Payments. It will list all the payment methods available.

    Listing of Payment Methods

    As you can see, payment methods are already available for the most popular payment gateways like PayPal, 2Checkout, Authorize.Net, etc.; however, there are only two payment methods installed and enabled by default, which are "Cash on Delivery" and "Free Checkout".

    In the front-end, only the payment methods enabled in the back-end are displayed. If you want to display your chosen payment method in the front-end, two steps are required. First, you need to install the payment method, and after that you'll need to configure and enable that payment method. Simply installing won't display it in the front-end.

    Also, if you have noticed, there is a Free Checkout option. It'll only be displayed in the payment options if the order total is zero. It's helpful in certain circumstances, for example if you want to set up some free demo products on your store, and still want to capture those orders.

    Install and Enable the "PayPal Payments Standard"

    Let's go through the use case of setting up a new payment method for your store. Click on the Install link for the PayPal Payments Standard, which will install this payment module.

    Install the PayPal Payments Standard

    After you've successfully installed the PayPal Payments Standard, you'll see one more link, Edit, which will take us to the configuration form interface.

    Edit the PayPal Payments Standard Configuration

    Go ahead and click on the Edit link for PayPal Payments Standard, which will open the configuration form.

    PayPal Payments Standard Configuration Interface

    The configuration form shows the parameters which are required for this payment method. It varies for different payment methods, as there are different parameters required for each of the methods. Let's have a look at some of the important parameters.

    A few parameters are common to every payment method. Let's review them:

    • Status indicates whether the payment method is enabled in the front-end.
    • Order Status allows you to select the status of your order when it is completed using this payment method. For most cases, "Pending" is suitable.
    • Geo Zone displays this payment method for certain geographical zones. If you've selected "All Zones", the payment method will be displayed to all users, irrespective of their geographical location.
    • Sort Order is the order in which your payment method will be listed.

    There are also some PayPal-specific parameters like EmailTransaction Method, Sandbox Mode, etc. And you'll see that there are different order status parameters available, reflecting the status the order could have during the PayPal transaction.

    Once you've filled in the necessary information, click the Save button to record your changes. In the same way, you can enable multiple payment methods for your store.

    Test Drive the Front-End

    Once you've enabled and configured payment methods from the back-end, let's check it in the front-end.

    Go to the front-end of your store. Add couple of products to the cart and start the checkout process. OpenCart has provided a nice user interface for the checkout. We'll jump directly to the fifth step of the checkout, which is Payment Method.

    PayPal Method Selection - Front End

    So as you can see. the PayPal option is now available along with the default Cash on Delivery.

    Once you confirm the order in the last step of the checkout process, you'll be redirected to the PayPal site for the payment. You'll be redirected back to your store after completing the payment at PayPal. It's a generic workflow for any payment gateway.

    Conclusion

    In this part, I've explained the basics of payment methods in OpenCart. You learned how to set up an existing payment method in the core, and enabled it for the front‑end checkout process. For more on OpenCart's payment methods and making your own custom payment methods, stay tuned for the other parts of this series!

    Of course, I would love to hear you in the form of queries and comments, so please use the feed below!

     

    0 Comments

    Leave a comment › Posted in: Daily

0 Comments

Got anything to add?

(Basic HTML is fine)