How to receive payment using Slydepay in php

So we are going to learn how to use Slydepay one of the best secured, stable payment processor with php. The plan of action is to avoid the use of any complex framework that would rather cloud the showcasing of the flow itself.This would just be a pure php project using html and plain old php files. In this tutorial I will use:

  • PDO library to handle the datalayer part
  • mysql database
  • simple php page to handle our request and querystrings
  • Netbeans as IDE(You can use any PDT, IntelliJ,sublime)
  • netbeans 8 server (You can use any nginx, apache2 etc)

Couple of assumption here, in this tutorial , I assume you already know how to work with php and how to call the database using either PDO: Php Data Object or mysqli object oriente stype.

Creation of a Merchant Account

That said, welcome to konohashop, kohona is the hidden ninja village of the leaf, I guess kohonamaru, the third grand son was not satisfied with the fact that Naruto walks all over the leaf to buy his ramen from the old man Teuchi the shop owner. To ease that process and enable people do their purchasing at the comfort of their house ,kohonamaru (apparently a techy ninja) contacted Slydepay in order to accept payment on the web application built for sale purposes using Slydepay. They were asked to create a merchant account.

After that quickly set up, Slydepay team verified the konohashop authenticity and then authorized the newly created account to do business on Slydepay (So to be a merchant you need to have a merchant account that needs approval or authorization). If you don’t have any by now then pause for 5mn , head to https://app.slydepay.com.gh to create a merchant account.

Slydepay Signup page

Slydepay Merchant Signup Page

According to the API at Slydepay Merchant API we need to have :

  • Our Merchant Email
  • Our Merchant Key
  • Set Integration Mode On
  • Set Callback to Our konohashop app

Below is how to get the merchant key, and set the callback url. After Slydepay takes the money out of the end users, Slydepay will use that callback url to contact our konohashop to inform us of the state of affairs.

Slydepay Account Dashboard

Slydepay Account Dashboard

Slydepay Paylive Settings

Slydepay Paylive Settings

Integrating with Slydepay

Now that we have our account created and validated, we can proceed with integrating the payment into our system. But we do not have the system yet. We will not attempt in creating an actual shopping cart but will build a mimic of it. Here is a proposal of a data model:

konohashop data model

sql file for the schema used is available here on pastie.org . In order to configure a user to use the database, run the following mysql command:

mysql> GRANT ALL PRIVILEGES ON konohashop.* TO 'teuchi'@localhost IDENTIFIED BY 'shoppu';
mysql> FLUSH PRIVILEGES;

Creating the shop web project

In Netbeans , create a php web project Slydepay-konohashop-php.

In our project what we will be doing is basically captured in this following flowchart. The flowchart tries to capture all the key steps with an effort not to make it too verbose.

Slydepay Integration flow

Slydepay Integration flow

Setting up dependencies

The only dependency needed is an Integration class for php called slydepay-php-connector located here . All we need to do is to get it in our project in classes folder. That said let’s create a folder called classed in the main source folder and put the Integrator.class.php file in it

Creating Needed classes

For the sake of simplicity , this project will not use a typical implementation of a cart using session etc but will rely on simple form and php files to simulate checkout process et al. We will use in total 4 php files and a php class.Let’s begin with our Data layer class, in classes folder create a php class DbLayer.class.php and make sure it looks like the following:

We will also need to create a php file/script that would be responsible of doing the following when Slydepay calls our application back as described in the API document:

  1. pull callback parameters
  2. verify authenticity of the payment
  3. process the order (what was paid for)
  4. complete the transaction by confirming or cancelling payment whether it’s success or failure

In netbeans source folder, create the file receivecallback.php and make sure it looks like shown below:

Creating Needed php files

Again, for the sake of simplicity this project would use only 3 php pages and I am pretty sure this is the most anaemic web application you have ever built. There is no javascript, no css, just the joy of pure php handling business here.

In your netbeans source folder create the 3 following php files:

  • fixtures.php a utility page for populating the database
  • index.php a very plain welcome page
  • viewitems.php page to display items in the database.

After creating the pages , make sure they look like shown below:

fixtures.php

index.php

viewitems.php

wiring up parameters through ini file

We are getting close to the finish line. The astute reader would have figured out that there is no information about konohashop database nor about our konohashop Slydepay merchant account. All the details are saved in properties file called local.ini. Create a folder config in Netbeans main source folder and create the local.ini file.

It should look like shown below expect the merchant email and key. You would need to use your own merchant email and key for it to work.

The project folder structure should look like shown below

netbeans file structure

slydepay-konohashop-php structure

running our konohashop application

I used netbeans internal apache server but any server should do the job I kept the port 8080 for consistency with the callback set in Slydepay already. let’s hit out app at http://localhost:8080/konohashop/fixtures.php to populate our database.Let’s then hit the url with http://localhost:8080/konohashop.

index page

To view items for sale , click on viewitems link
a
view items page

running our konohashop application

To test our payment integration let’s pick, a bowl of ramen and a kunai like shown in the screenshot below

 Items to purchase

Items to purchase

After the checkout button is clicked, our checkout servlet would have called Slydepay web service , gotten a valid token and redirects us to the following page which will notify us being in test or integration mode

Slydepay testing mode notification

Slydepay testing mode notification

After clicking on I am a tester, we are now allowed to see the order form page see the total cost of our purchases. According to the API document we ought to use :
username: [email protected]
password: paddypaddy

Slydepay order form page

Slydepay order form page


But just in Case we are curious about what makes our bill, a click on the cart icon would reveal details of the bill as shown below

Slydepay cart payment details

Slydepay cart payment details

After entering credentials as expected, we are redirected to our konohashop and we get a success message

order payment success message

order payment success message

Voila , I hope this tutorial gave you insight on how to use and interact with Slydepay and its SOAP payLIVE API. Project files are available on github.com

P.S : I used the same screenshot as for the java tutorial, so urls shown on the images here don’t match . These ones are .jsp and our own are .php. I thought I should call that out.

33 Comments

  1. Edward Selirah

    My problem is the fact that my website deals with users doing investments on projects that are displayed on my website by using slydepay as mode of payment of the investment.
    I do not know how to go about it. I tried to use this idea to see if I can follow it to do my project but I cannot

    Please I need help

    Reply
    1. kodjo-kuma djomeda (Post author)

      Hi Edward,
      Happy to see you reading this blog. Are you the owner, the developer (or both ) of the project. Can you please send an email to [email protected]? Kindly let me know where you have the issue.

      😉

      Reply
  2. Mustapha

    Yeah, this seems very much like a payment system in its infancy… If you compare the SDK to that of stripe you’ll notice how far slydepay has to go… It should at least have a composer library, and perhaps a Laravel Implementation… Anyway, maybe I’ll write it myself…

    Reply
    1. kodjo-kuma djomeda (Post author)

      Hello Mustapha Hamoui, composer has nothing to do with any payment system either slydepay or stripe which by the way has been in constant evolution. Composer is like maven for php. A tool to organize and distribute dependencies and a lot of people actually using it not just in frameworks of the likes of Lavarel. Lots of people still distribute packages, libraries on github , gitlab etc without using composer. I see clearly 2 unrelated concerns here . You are welcome to create your composer sdk and distribute it there. I might do one if I get the time or contribute to yours if you allow.

      Reply
      1. Mustapha Hamoui

        Hey,

        I took the time yesterday to look through the code. I may have been been too quick to comment, and I should have taken my time to explain. Of course I don’t mean that Slydepay should have a composer package. Composer is simply a means of distribution as you said. What I mean is: When a platform becomes popular and mature, you get many 3rd parties to write Libraries that provide syntactic sugar to the SDK to make it more accessible to developers ( as an example, look at how many 3rd PHP libraries Stripe has).

        As things are with Slydepay today (I used the word infancy, but I didn’t mean that as an insult), the SDK is still relatively low level and inaccessible to developers, because it’s still young. Not impossible, mind you (it didn’t take me that long to get the flow) but modern development tries to minimise friction and make implementing a service as easy as slotting in a lego piece. It’s in the platform’s owner interest to make the process as easy as possible. Developers nowadays have a lot of things to learn and a lot is expected of them, so they appreciate it when 3rd parties do the heavy lifting.

        I will let you know if I write a third party library for slydepay.. I may need it for my own projects..
        Cheers and keep up the good work.

        Reply
        1. kodjo-kuma djomeda (Post author)

          Hi Mustapha Hamoui, thanks for clarifying your point. There is a huge plan behind building more SDKs et al. As at now there are SDKs for php, java, python, nodejs, C#. They are all in their first iterations. There are plugins for shopping carts like PrestaShop, CS Cart, OpenCart , Magento, WooCommerce, Vitue Mart etc. Devs covered pretty much when it comes to carts. Hopefully there will be further releases of the API then we devs would build better SDKs for other devs. You are welcome to try slydepay, it will be awesome to have another maintainer for any other language out there.

          Reply
  3. Winfred Adrah

    HI, i want to create an webapp that will accept payment from the users using mobile money, but i don’t want the users to be redirected to slydepay website for them to create an account before making payment. So i want them to enter their phone number, secret code and other necessary details on my site and the money will be deducted from their mobile money accounts directly, even if they will be redirected to slydepay, they don’t have to go through the process of creating an account. I was playing with airty.me and Slydepay to see how it works. I realized that could not pay using MTN mobile money but i could use Airtel money and visa. I just want the user to make payments without going through so many steps. Thank you.

    Reply
    1. kodjo-kuma djomeda (Post author)

      Hello Winfred,

      I suggest you contact slydepay at [email protected]

      Best Regards,

      Reply
  4. Nate Greno

    I’m a your entrepreneur who just set up an digital downloads online store to sell digital products. I have been working on getting cool checkout page or payment gateway . I wanted to request a video tutorial on php integration.

    Please you can also check my store for any advice or suggestion at http://www.store.grenostudios.com. Thank you

    Best Regards
    …Nate

    Reply
    1. kodjo-kuma djomeda (Post author)

      hello Nate, thanks for passing by, I will have a look. cheers

      Reply
  5. Prince Charles Monney

    I am using Opencart v2.0.2.0 and have integrated the opencart plugin for version 2 x and entered all settings in the admin..
    but when I reach check out and use the opencart payment method I get “Ajax request error”

    Reply
    1. michael banson

      same issue for me, slydepay will not answer my mails or return my calls.

      Reply
  6. Shamim

    Hello,

    I am a php developer, integrating a slydepay payment gateway.

    My problem is How to remove the “In Test Mode” Screen. I make the config

    ‘slydepay’ => [
    ‘shippingcost’ =>00,
    ‘taxes’ =>00,
    ‘merchantEmail’ =>’[email protected]’,
    ‘merchantKey’ => ‘6664666,
    ‘integrationmode’ => 0,
    ‘redirecturl’ => ‘https://app.slydepay.com.gh/payLIVE/detailsnew.aspx?pay_token=’,
    ‘wsdl’ => ‘https://app.slydepay.com.gh/webservices/paymentservice.asmx?wsdl’,
    ‘serviceClass’ => ‘com.i_walletlive.paylive.PaymentServiceSoap’,
    ‘namespace’ => ‘http://www.i-walletlive.com/payLIVE’,
    ‘serviceType’ => ‘C2B’,
    ‘version’ => ‘1.4’,
    ]

    Any in my slydepay setting i put the API Integration Mode “On” checkbox. In this case. “pay_token” is generated but showing “in Test Mode” Screen. But when I disabled the API Integration Mode to “Off” checkbox. and use the old “pay_token” generated previously, It go to live. But when I am trying to generate “pay_token” with API Integration Mode to “Off”. It showing
    stdClass Object
    (
    [ProcessPaymentOrderResult] => Error 3
    )

    Please help.

    How to remove the “In Test mode” screen to Live.

    Thanks
    Shamim

    Reply
    1. George

      Hi Shamim,

      From my experience with slydepay, after you’ve successfully tested the integration you will need to contact slydepay support at [email protected] and provide them with copies of your company registration documents to approve and activate your live payments for you.

      Hope this helps someone else.

      Warm Regards.

      Reply
      1. kodjo-kuma djomeda (Post author)

        Good one there George!!

        Reply
        1. Abdul Majeed

          So if I haven’t register my company; it means I’m unavailable to get verified! if yes then it’s unfair and at this point slydepay is not been Professional system -:)

          Reply
          1. kodjo-kuma djomeda (Post author)

            This is a KYC policy and Bank Of Ghana requirement. You can reach out to support for more information. But it’s rather interesting that you say Slydepay is unprofessional when you are asked to provide your company registration so Slydepay knows you are a genuine business -:)

  7. Mascus

    please i need help with the database connection, I’m coding in Php and i keep getting this error

    Fatal error: Uncaught exception ‘PDOException’ with message ‘could not find driver’ in C:\xampp2\htdocs\slydepay\classes\DbLayer.class.php:33 Stack trace: #0 C:\xampp2\htdocs\slydepay\classes\DbLayer.class.php(33): PDO->__construct(‘mysql:host=loca…’, ‘root’, ”) #1 C:\xampp2\htdocs\slydepay\classes\DbLayer.class.php(27): DbLayer->getConnection(‘root’, ”, ‘localhost’, ‘konohashop’) #2 C:\xampp2\htdocs\slydepay\viewitems.php(17): DbLayer->__construct(‘root’, ”, ‘localhost’, ‘konohashop’) #3 {main} thrown in C:\xampp2\htdocs\slydepay\classes\DbLayer.class.php on line 33DbLayer->__construct(NULL, NULL, NULL, NULL) #3 {main} thrown in C:\xampp2\htdocs\slydepay\classes\DbLayer.class.php on line 33

    please help thank you

    Reply
    1. kodjo-kuma djomeda (Post author)

      Hello Mascus,

      It says clearly “COULD NOT FIND DRIVER” in your stack. Do you have pdo in your php installation? I think this is more an environment issue … 🙂

      Reply
  8. Ishmail

    Hello please I am a final year student working on my project.I am developing an online shop which require payment over the platform.I want to know how possible it would be to integrate slydepay on my website without a registered business.Thank you.

    Reply
    1. kodjo-kuma djomeda (Post author)

      Hello Ishmail,

      Addressing Slydepay support would have been the best thing to do. But since you asked here, I think as long as your are not making live payment you can go ahead without needing a business registration. 😎

      Reply
  9. Numaan Anjum

    Thanks for this tutorial .
    I am integrating this API with Codeignitor. i have got to the payment screen but it is not showing cart after clicking on it.and also its not accepting the user provided for testing integration i.e [email protected] with password paddypaddy. after providing the credentials it redirects me to the same page.
    Can somebody help me.
    Thanks

    Reply
    1. kodjo-kuma djomeda (Post author)

      Hello Numaan,

      Can you elaborate on this a little?

      Reply
  10. Sammy

    My question has to do with the banks integration,
    1. does slydepay use custom payment gateway api that interface with individual stanbic, Adb
    or
    2. slydepay use a third party payment processor that rides on Visa, Mastercards etc integrating easily with all banks
    how is that being done for now with slydepay?

    Reply
  11. Aldo

    I need to integrate slydepay with magento 2 website. I found that there is an api for magento 1.x. But are you working on a magento 2 extension?

    Reply
    1. kodjo-kuma djomeda (Post author)

      Hello Aldo,

      Could you please send email to [email protected] I will personally pick that up for you. Thanks for using Slydepay

      Reply
  12. sam

    hi am building an online store with wix store how can i integrate slypay to it

    Reply
    1. kodjo-kuma djomeda (Post author)

      Hello Sam,

      I hope you are fine. We have build anything for wix yet. Sorry man.

      Reply
  13. Ephraim Arthur

    Hello can i use mysqli() for my database connection…..i hardly use PDO im stick with mysqli……im confused with the database connection

    Reply
    1. kodjo-kuma djomeda (Post author)

      Hello Ephraim,

      Sorry for that, I hardly use anything else than PDO. But you can customize your connection. All you need to do is to make sure that you have a connection object. However that connection class is working internally, you can totally change that

      Reply
  14. Fuseini Basiru

    hello kodjo
    Am working on a project in school which involves a payment system and my supervisor asked i use slydepay API as the payment gateway. please could u help. would be grateful if you could.

    Reply
  15. CodeBoss

    Hi, I don’t find it enjoyable reading other people’s code and having to keep track of the logic. Kindly make it simple for me in this way:
    1. Which parameters is the Slydepay app expecting when a user is redirected to the Slydepay App
    e.g expected parameters are Total amount, subtotal, tax, merchant email, merchant API key etc

    2. Is the Slydepay App receiving these parameters via GET or POST method or which method?

    3. In which format should the expected parameters be sent to the Slydepay app?
    e.g All the parameters must be appended to a given URL as in GET method e.g https://slydepay.com/?token=8sh84848&orderid=84&totalamount=90 etc
    Or the Slydepay app expects the parameters in an array format? Which format please?

    4. The callback URL, how does it work? The callback URL will have some parameters appended to it and processed by my app right? So which parameters are expected? userID? statusCode or what?

    I think in order for a developer to process payment on Slydepay three goals must be achieved
    1. Developer must successfully send expected parameters to the Slydepay app.

    2. Slydepay processes the parameters and sends response to the developer’s app through callback URL which the developer’s app may receive using GET method.

    3. The developer’s app must process the callback URL and work with the developer’s database according to the developer’s logic

    The steps are not clear in your tutorial and honestly, it is not enjoyable for some of us to follow the logic of another person’s code. I prefer that you provide the explanation and leave the coding to us as we all have different ways of using code to arrive at different results.

    Thank you

    Reply
  16. kodjo-kuma djomeda (Post author)

    Ok CodeBoss,

    You know your choice of words can be offensive? I hope you realised that while writing this I didn’t have you in mind particularly? There are many devs who appreciated this. When you say enjoyable reading do you mean that your conception of what is enjoyable or not is a universal characteristics and thus anybody writing a post should care enough to suite your taste?

    If you really understand what a SOAP API is then you will know that by nature of a SOAP API the contract is what’s defined in the wsdl . When you read that wsdl , you will find answers to your questions 1, 2 , 3. https://app.slydepay.com.gh/webservices/paymentservice.asmx?wsdl . You see a wsdl document and you still manage not to understand that it defines in there , webmethods and their signature etc.

    For the interaction you can find documentation here https://s3.amazonaws.com/slydepay-public/docs/SlydepayMerchantApi_V_1.4.pdf that’s for your question 4.

    Maybe you are kind of a REST guy , maybe that’s the only thing they teach in school these days, can find the documentation of it with how the interaction is with payload examples here http://doc.slydepay.com/

    Next time you want to criticise someone’s job make sure you know you stuff well.

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

captcha * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.