L o a d i n g

How to accept Paynow on your website (Ecocash/Onemoney/Telecash) in just 10 minutes

When I was building Welodge Marketplace, I wanted a way to receive local payments on the site, I tried Paynow, created an account, followed the docs, integration key what what, it didn't work. I don't know, maybe it was just me.

The only way that worked was to create a link that when clicked redirects the customer to Paynow to make a payment and then back to the merchant site, let's call that "the redirect route".

This is the method I've seen on most website that use Paynow today including, hit.ac.zw, name.co.zw and many others I can't remember off the top of my head.

This didn't work for me, I wanted the customer to stay on site and just enter their pin, you know like they do other sites that take credit cards n stuff

If you've been in a similar situation, this blog is for you. Even if you've been able to integrate Paynow successfully using their REST API, I'm sure this method will save you lines of code the next time you integrate it, or just refactor your code to this

Right where were we, yes, it didn't work, so I decided to build a simplified API on top of what was working already, the redirect route. All you have to do is make just one POST request, and you're all set!

Here is the step-by-step guide on how to easily setup Paynow and start receive local payments with Flixtechs Easy.

Step 1: Create a Paynow merchant account

If you already have a paynow merchant account you can skip to step 3.

The first step is to visit the Paynow merchant services site and create an account. During signup, you will be prompted for business name address tax stuff and what not, just fill in depending on your organization.

Step 2: Add banking information

After your account has been created, you will be prompted to add a bank account. If that's not the case, from the homepage, click on "Manage Payment Settings"

Once you have been redirected, select Ecocash and fill in the bank account that will receive the funds, do the same for OneMoney, Telecash.

After this, well, we're done, we are now ready to receive payments via Paynow.

Step 3: Create a Flixtechs Easy account

In order to easily receive payments through your application, you need an account from our custom solution that sits on top of Paynow to simplify the integration.

Head over to https://easy.flixtechs.co.zw and create an account.

Just after sign up you will be redirected to a profile page

At the bottom, click on "Generate Token" to generate an API token to use during integration,

Copy the token to somewhere safe, probably in your .env file,

From the navbar click on documentation for more information on how to use the API, it's just one request you need only.

Making a test payment

Okay let's just test to see if our API token is working correctly, I'm using a Node.js example with axios, so first just initialize a project

npm init

Then install axios

npm i axios

After installing axios create a file say, payment.js and paste the following snippet inside

var axios = require('axios');
var qs = require('qs');

var data = qs.stringify({
  'name': 'Customer-Name-goes-here',
  'merchant_email': 'your-merchant-email@here'
  'phone': 'customer-phone-number-goes-here',
  'reference': 'Oder-reference-goes-here',
  'amount': '2500' 
});

var config = {
  method: 'post',
maxBodyLength: Infinity,
  url: 'https://easy.flixtechs.co.zw/api/payments',
  headers: { 
    'Authorization': 'Bearer your-token-goes-here', 
    'Accept': 'application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

Save the file and run it with

node payment.js

Make sure you have internet connection and have provided the correct phone number for the phone field. You should receive a pop-up prompting your PIN, enter your pin to authorize payment, and it should reflect in your Paynow account, sadly they don't have a way of viewing your current balance, but you will receive an email soon as payment is received.

And that's it!, it's as simple as that, if you need any help to integrate Paynow or using our API just let me know via the contact form or reach out to me on Twitter @ncubegiven_

If you want to learn how to build an ecommerce site in Laravel, we have an ongoing series tutorial here

Happy coding!

Writer at Flixtechs Given Ncube's picture
Given Ncube