1. Go to this page and download the library: Download feexpay/feexpay-php 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/ */
feexpay / feexpay-php example snippets
ut Composer: pay\FeexpayPhp\FeexpayClass("shop's id", "token key API", "callback_url", "mode (LIVE, SANDBOX)");
// Using the mobile network payment method (MTN, MOOV, MTN CG, ...)
// paiementLocal(amount, phoneNumber, network, fullname, email, callback_info, custom_id, otp = "")
// phoneNumber: country code + local number, e.g. Benin 229 + 0166000000 => "2290166000000"
$reference = $skeleton->paiementLocal(100, "2290166000000", "MTN", "Jon Doe", "[email protected]", "order 123", "my-ref-123");
if ($reference === null) {
// The API refused the payment: show the real reason
$error = $skeleton->getLastError();
echo $error["message"]; // message returned by the API
var_dump($error["response"]); // full API response, useful for support
} else {
$status = $skeleton->getPaiementStatus($reference);
var_dump($status);
}
// requestToPayWeb(amount, phoneNumber, network, fullname, email, callback_info, custom_id, cancel_url, return_url)
$response = $skeleton->requestToPayWeb(100, "2250700000000", "network", "Jon Doe", "[email protected]", "order 123", "my-ref-124", "https://your-site.com/cancel", "https://your-site.com/return");
if ($response === false || empty($response["payment_url"])) {
echo "Payment could not be initialized";
} else {
// $response["reference"] and $response["order_id"] identify the payment
header("Location: " . $response["payment_url"]);
exit();
}
// paiementCard(amount, currency, firstName, lastName, email, phoneNumber, city, zip, country) - all arguments are "BJ");
if ($responseCard !== null) {
// $responseCard["reference"] identifies the payment
header("Location: " . $responseCard["payment_url"]);
exit();
} else {
// The API refused the payment: show the real reason
echo $skeleton->getLastError()["message"];
}