In this series, we are going to look at building a Bitcoin payment system into our installation of OpenCart. Before we get started, I recommend that you practice the basic OpenCart module development if you are not familiar with how to build your own modules.

Once done, you should have enough knowledge to continue with developing more advanced modules. In this series, that's exactly what we aim to do.

Getting Started

Before we begin building the extension, set up OpenCart on your local machine. Next, download the BitPay API Library from the article attachment and place it in your store root as shown in the following screenshot:

To configure and set up up our Bitcoin Payment Module, we need an admin interface. To do this, we'll follow the MVC pattern for implementing our admin panel.

1. Create the Admin Controller

Navigate to admin/controller/payment.

Create a PHP file and name it bitpay.php.

Open the file in your favorite IDE and create a class following the OpenCart class naming convention, for example: class ControllerPaymentBitpay extends Controller {}.

Inside the controller class, define the default index function.

Then, inside this function, start writing the code as featured below.

1.1 Loading Language & Models

$this->language->load('payment/bitpay');
$this->load->model('localisation/order_status'); // loading the model to get system Order Statuses

We are done creating the payment module layout for the dashboard, and you should be able to test-drive the admin panel. Remember to grant permission to the administration user before testing.

Conclusion

In this article, we introduced the administrative portion of the payment module. Note that it's a good idea to give the site administrator more control via an interface than, say, to require that they write in code.

In the next article, we'll implement the payment module with respect to the front-end. In the meantime, feel free to shoot any questions or comments via the form below.