How to create a payment module or extension in the Opencart 3? Developer guide Part I of III

In this Opencart tutorial developer guide, we are showing how to create a custom payment module or extension in the Opencart version 3. Opencart by default supports more than 45 payment modules. Log in into admin, go to Extensions >> Extensions >> Choose the extension type “Payments”, you can see the lists of payments module in Opencart.

Here is the flow of the most eCommerce website.

eCommerce flow diagram

Today we are showing you postmortem the payment gateway section.

Here are some of the normal steps that happen in the payment section:

ecommerce payment flow
  1. When the customer is ready to pay for goods or services on your website, they select the payment method on your website.
  2. There are two ways of payment gateway processing:
    • One is Off-site payment processing
      In the off-site payment, the website is redirected to the payment service website and payment is made on the payment service website.
      There will be no place to enter the credit card information or login to payment gateways.
      The payment gateway provides a Payment form in which we matched similar fields.
      Data are passed from Form.
      Need return URL or cancel URL so that when payment is a success it returns to that return URL and if the payment fails then it returns to the cancel URL.
      Skrill, Paypal Standard, Liqpay, etc. are the default payment modules for Off-site payment processing.
    • Another is on-site payment processing.
      In the on-site payment, the payment is made on the same site, the payment processing is done through APIs.
      The payment gateway provides a JSON request.
      There will be a form where they can enter the credit card details or bank information etc.
      Data are passed as JSON format.
      It will return success or failure messages through API in JSON format. Once you get the success or failure data then further processing can be done in the website server and the message can be shown or redirected to the success page.’s AIM, Paypal Pro, Square, etc. are the default payment modules for on-site payment processing.
  3. When the payment method is Off-side payment processing then data are passed on hidden fields in the form. If we check the documentation of NoChex you can see the form code like below:
    Off site payment form code page no. 5

    Mostly the payment gateway provides us with the form method type, action URL, and fields that we can pass to them for processing. Once you click the “Confirm Order” button, these hidden fields data are passed to the payment gateway and processing happens in their website.
  4. When a payment gateway process the payment and is successful then the customer is directed to the success URL.
  5. When the payment method is On-side payment processing then data are passed from website Server to payment gateway through API, as we are using Opencart which is builtin PHP so we use CURL to call the API.
  6. The website server passes the data to the payment gateway through API, mostly CURL is used to communicate with the APIs, we pass JSON-formatted HTTP requests to the API endpoint in either the sandbox or production environment of the payment gateway.
  7. Payment gateway requests authorization for the payment from the customer’s bank, third party provider, or card issuer.
  8. The bank/provider/card issuer approves or rejects the transaction.
  9. Payment gateway sends the success or failure response, containing the transaction result, and calls the Callback where the website server can process the data.
  10. The website server processes data returned by the payment gateway and it redirects to the success page.

These are the steps that happen on Opencart for payments. So we need to take each step into consideration while developing the payment extensions.

Checklist for Developers while integrating the payment extension

Here is the checklist for the developer while integrating the payment extension on the Opencart or custom platform

  1. Always make a google search if the Opencart payment extension is available, sometimes it is available for free.
  2. If free is not available then start by creating/asking an account and visiting the documentation.
  3. Mostly each payment gateway has a test environment so get test credentials. Create a playground account to get test credentials and get familiar with the test environment.
  4. Check out the PHP SDKs, with this, it will be easy to understand the code. Like for Paypal
  5. Follow the integration guide. Each of the product documentation provides an integration guide. Follow the instructions to make sure your payment process works as needed.
  6. Be sure to check if what ISO country codes (3‐digit or 4-digit), what language support, and what currencies support are available for that payment gateway.
  7. Check all your APIs in Postman to confirm everything, before development
  8. Test the system. Make sure everything works. Remember you can place a test order using test credentials on Postman.
  9. Be sure to read how error handling is done, how many rate limits, if any domains & IP address restrictions, policies, and compliance
  10. After reading the documentation, now you can decide whether you need to make the Off-site payment extension or on-site payment extension.
  11. Then start the development.

In our next post, we will show you how to create the off-site payment extensions, we start by cloning the Skrill or Opencart Paypal standard payment extension, which will help us to understand how we can create the Opencart payment extensions. Till then, please let us know if you need any help or custom development, and keep on learning Opencart.


Previous articleOpencart code snippets VSCode extensions
Next articleHow to create an off-site payment extension in Opencart 3? Part II of III


  1. Hi. Your tutorials are very helpfull and pleased. I have learened so much from you. I followed this payment methods lectures, but it is complicated for me please you can post video tutorial about either off-site payment or on-site payment via youtube or here? Thanks further knowledge.


Please enter your comment!
Please enter your name here