[insert_php]

ob_start();
$pgg_api_url = ‘https://paygateglobal.com/api/v1/pay’;
$amount = $_POST[‘amount2’];
$pgg_curl_init = curl_init($pgg_api_url);

$pgg_auth_token = $_POST[‘auth_token’];
$pgg_phone_number =$_POST[‘phone_number’];
$pgg_amount = $_POST[‘amount’];
$pgg_description = $_POST[‘description’];
$pgg_identifier = $_POST[‘identifier’];
if($amount!=””){
$pgg_amount = $amount;
}
$pgg_jsonData = array(
‘auth_token’ => $pgg_auth_token,
‘phone_number’ => $pgg_phone_number,
‘amount’ => $pgg_amount,
‘description’ => $pgg_description,
‘identifier’ => $pgg_identifier );

$pgg_jsonDataEncoded = json_encode($pgg_jsonData);

curl_setopt($pgg_curl_init, CURLOPT_POST, 1);

curl_setopt($pgg_curl_init, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($pgg_curl_init, CURLOPT_POSTFIELDS, $pgg_jsonDataEncoded);

curl_setopt($pgg_curl_init, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’));

//curl_exec($pgg_curl_init);
//Execute the request
$pgg_result = curl_exec($pgg_curl_init);

//close PayGateGlobal curl session
curl_close($pgg_curl_init);

//Decode the result JSON data
$pgg_array = json_decode($pgg_result, true);

//getting data from result
$pgg_tx_reference = $pgg_array[“tx_reference”];
$pgg_status = $pgg_array[“status”];

//checking pgg status code values
switch($pgg_status)
{
case 0:
echo “La transaction “;
echo ““.$pgg_tx_reference.” sur CAFE est réussie.
“;

echo “Un message vous a été envoyé sur votre numéro de téléphone pour confirmation.“;
break;
case 2:
echo “Code erreur 2 “;

break;

case 4:
echo “Code erreur 4 “;
break;

case 6:
echo “Code erreur 6 “;
break;

default:
echo “Code erreur TEMPORAIRE “;

}
//EF
ob_flush();

[/insert_php]