PHP code example of moncasheasy / moncash-easy-sdk

1. Go to this page and download the library: Download moncasheasy/moncash-easy-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

moncasheasy / moncash-easy-sdk example snippets


{
    "  "moncasheasy/moncash-easy-sdk": "^2.0.1"
    }
}






use MoncashEasy\SDK\MoncashAPI;

$clientId = "<votre client id>";
$clientSecret = "<votre client secret>";

$moncash = new MoncashAPI($clientId, $clientSecret);



//Effectuer un paiement

$orderId = 93;//Une identification unique pour le paiement
$amount = 120;//Le montant du paiement

$payReq = $moncash->makePaymentRequest($orderId, $amount);


$payDetails = $moncash->getDetailsByOrderId(93);

echo "Date de la transaction : ".Date("d/m/Y", $payDetails->getTimestamp()/1000)."<br/>";

echo "Reference : ".$payDetails->getPayment()->getReference()."<br/>";
echo "No Transaction : ".$payDetails->getPayment()->getTransactionId()."<br/>";
echo "Prix : ".$payDetails->getPayment()->getCost()."<br/>";
echo "Message : ".$payDetails->getPayment()->getMessage()."<br/>";
echo "Numéro tél : ".$payDetails->getPayment()->getPayer()."<br/>";


try {

	$moncash = new MoncashAPI($id, $secret);

	//Les opérations qui s'en suivent

} catch(MoncashEasy\SDK\MoncashException $e) {
	echo "Erreur : ".$e->getMessage();
}


try {

	$moncash = new MoncashAPI($id, $secret);

	//Les opérations qui s'en suivent

	$newId = "<nouveau client id>";
	$newSecret = "<nouveau client secret>";

	$moncash->setCredentials($newId, $newSecret);

	var_dump($moncash);

} catch(MoncashEasy\SDK\MoncashException $e) {
	echo "Erreur : ".$e->getMessage();
}