The LemonWay API (called Directkit) has two implementations: DirectkitJson2 and DirectkitXml.
The DirectkitJson2 is recommended over the DirectkitXml because It is the simplest and the most network-efficient way.
To call the directkitJson2 in PHP: use the curl_init
to send a POST request (See also the Postman example in our documentation).
This tutorial show how simple it is.
After downloading this project (git clone
), run:
php GetWalletDetailsExample.php
Out of the box it will call the demo
environment. If you have your own test environment. You should fix the configuration in LemonWay.php
, put your own environment configuration.
Tips: the Quickest way to get PHP running on a Windows PC
In the GetWalletDetailsExample.php
you succefully called the GetWalletDetails
function to get details information of the wallet sc
:
require_once "./LemonWay.php";
try {
$response = callService("GetWalletDetails", array(
"wallet" => "sc"
));
//print the response
echo json_encode($response, JSON_PRETTY_PRINT);
}
catch (Exception $e)
{
echo ($e);
}
Following the example, let try to create a new wallet project001
with the RegisterWallet
function
require_once "./LemonWay.php";
$response = callService("RegisterWallet", array(
"wallet" => "project001",
"clientMail" => "[email protected]",
"clientFirstName" => "Peter",
"clientLastName" => "PAN",
"clientTitle" => "M"
));
//print the response
echo json_encode($response, JSON_PRETTY_PRINT);
Now try to credit the wallet project001
with a test card using the MoneyInWebInit
function:
require_once "./LemonWay.php";
$response = callService("MoneyInWebInit", array(
"wallet" => "project001",
"amountTot" => "10.50"
));
//print the response
echo json_encode($response, JSON_PRETTY_PRINT);
You will get a Business Error if the wallet sc
is 0. In order to make this example working, you will have to
- Credit the wallet
sc
first or put a reasonable amout of commission in the request
- you can credit the wallet sc in your BackOffice (on test environment) or by contacting the LemonWay Staff (on production)
- or you can put a reasonable amout of commission in the request. Eg:
require_once "./LemonWay.php";
$response = callService("MoneyInWebInit", array(
"wallet" => "project001",
"amountTot" => "10.50",
"amountCom" => "2.00"
));
//print the response
echo json_encode($response, JSON_PRETTY_PRINT);
Your commercial support will explain more in detail about the commission system.
-
Read the documentation on
MoneyInWebInit
to get an idea how it works. Basicly, it will return a token that you will have to combine with the Webkit to get to the payment page. -
Once you got to the payment page (via the Webkit) you can use one of the test cards to finish the payment process.
You can also try other functions to understand our API:
- Create a new wallet
- Create a payment link to credit a wallet
- Create a payment form to credit a wallet
- Register an IBAN to the wallet
- Transfer money from wallet to a bank account
- Transfer money from wallet to other wallet
- The code only use PHP basic to stay framework-neutral. It only show you how easy to access to our service. In real project you might change it a litte, for example: wrap the
callService
in a service class in your Laravel project, or make a Symfony component for yourself. - A good practices is to log any request / response (with Monolog for example) to our service in Development mode.