Skip to content

lemonwaysas/php-client-directkit-json2

Repository files navigation

⚠️WARNING: This client is deprecated⚠️

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.

How to run

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

Time to play!

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

  1. 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.

  1. 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.

  2. Once you got to the payment page (via the Webkit) you can use one of the test cards to finish the payment process.

See also

You can also try other functions to understand our API:

Note

  • 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.

About

PHP example calling DirectKit Json2 API with simple HTTP request http://documentation.lemonway.fr/

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages