Blog Logo

PTM & Tuti Soap Integration

This is one of the more complex projects that I’ve built for a client.

The main idea of the project was to integrate Tuti’s WordPress E-commerce with PTM’s WebService.

Tronex is a Colombian company that started as a battery factory, and now is changing its focus to provision small neighborhood stores with products like milk, eggs, batteries, lighters, snacks, etc. without the need of the store owner to contact hundreds of providers.

Tuti is an e-commerce platform created by Tronex so this small store owners could make quotes and orders in an E-commerce like environment with the main difference being the payment was done offline directly to a Tronex representative 20 days after the delivery. Also, this e-commerce can only be accessed by pre-registered store owners.

One of the products that this small owners sell very frequently to its clients are “minutes plans”.

Minute Plans allows a user to purchase something like “10 minutes of talk time on my phone”. And that’s where PTM comes in: PTM allows any person to sell minutes to any kind of client.

For a store owner to be able to sell “minute plans” he/she needs to create an account in PTM recharge a balance using an special document with personal barcode directly on a bank or authorized “minutes resellers”.

The main idea of this integration was to sell PTM minute plans directly in Tuti’s e-commerce.

The initial requirements for this project where:

Technologies used

For the development environment I used a Vagrant Machine with Ubuntu 18.04 installed inside of it.

Also, I used a pre-created script to install WordPress using WP-CLI from the command line. This script installs Wordpress and a short list of required plugins like ACF, Code Snippets and a basic template.

Coding Standards

This project followed WordPress coding standards almost to a 100%. To achieve that I used the following packagist packages:

Testing

A project of this magnitude has to have testing

Mainly on the integration steps. Its very hard to have a good integration without some kind of tests.

I used for testing the following packages.

Soap Integration

SOAP is something that PHP does not handle very well. Specially when you want to convert SOAP calls to PHP objects.

To achieve that, I used wsdl2phpgenerator/wsdl2phpgenerator which is a project that analyzes a local or remote WSDL file and creates a hierarchy of PHP classes so you can make calls to a remote server just by creating and calling methods on PHP objects.

PDF Generation from HTML

For the PDF generation I used mpdf/mpdf since it allows you to create PDF files from correctly formatted html.

And since I was creating a PDF from HTML, I also needed a template system. The client already had experience with Shopify’s Liquid system, so I used liquid/liquid template system.

Barcodes

Also, the PDF file needed custom barcodes that where different for each of the e-commerce clients. So the barcode needed to be created on the fly. I ended up using picqer/php-barcode-generator, which generates a PNG file that could be embedded in the PDF.

Currency format

Finally, I used indibeast/currency-formatter version 1.0 to display balances in currency format.

Screenshots

Settings Page

The settings page for this project was somewhat long since you needed to configure the following:

Settings Page

Account Page

In the account page we added a new path for showing the last sells recorded in PTM and the PTM Balance:

Account Balances

List of products

PTM offered almost 150. But only 20 where configured in Tuti’s system.

List of PTM products

Sell minute plans

For each PTM product, there was a form to sell minute plans.

Sell minutes

The form had to send information using ajax requests and the number and type of fields changed from product to product.

Username/Password error on the remote service

If the username password is wrong on the remote server, the business owner could not sell minutes.

PDF Generation

The system generates a PDF with a barcode.

The content and placement of the barcode is configured in the settings page by using a liquid template

PDF Generation