PHP code example of digitalpaye / digitalpaye-sdk-php

1. Go to this page and download the library: Download digitalpaye/digitalpaye-sdk-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/ */

    

digitalpaye / digitalpaye-sdk-php example snippets



igitalpayeSdkPhp\Services\Digitalpaye;

$apikey = "live_digitalpaye129923061";
$apisecret = "d511e1f4-d932-32fcd-a804-371539700d60c";

$config = new Digitalpaye($apikey, $apisecret);
$balance = $config->getBalance();
echo $balance["data"]["amount"];


igitalpayeSdkPhp\Services\Digitalpaye;

$apikey = "live_digitalpaye129923061";
$apisecret = "d511e1f4-d932-32fcd-a804-371539700d60c";

$config = new Digitalpaye($apikey, $apisecret);

$dataCreateCollecteOrangeMoney = [
    "transactionId" => "DIGITAL-303311901120870",
    "customer" => [
        "lastName" => "GUEI",
        "firstName" => "HELIE",
        "phone" => "0777101308",
        "email" => "[email protected]",
        "address" => [
            "countryCode" => "CI",
            "city" => "Abidjan",
            "streetAddress" => "Plateau Cocody"
        ]
    ],
    "payer" => "0777101308",
    "otpCode" => "4008",
    "amount" => "2000",
    "currency" => "XOF",
    "operator" => "ORANGE_MONEY_CI"
];

$collecteOrangeMoney = $config->createPayment($dataCreateCollecteOrangeMoney);

if ($collecteOrangeMoney['data']["status"] == "PENDING") {
    echo "La transaction est en cours de confirmation";
} elseif ($collecteOrangeMoney['data']["status"] == "SUCCESSFUL") {
    echo "La transaction a été traitée avec succès.";
} else {
    echo $collecteOrangeMoney["message"];
}


igitalpayeSdkPhp\Services\Digitalpaye;

$apikey = "live_digitalpaye129923061";
$apisecret = "d511e1f4-d932-32fcd-a804-371539700d60c";

$config = new Digitalpaye($apikey, $apisecret);

$dataCreateCollecteWave = [
    "transactionId" => "DIGITAL-303311901120870",
    "customer" => [
        "lastName" => "GUEI",
        "firstName" => "HELIE",
        "phone" => "0777101308",
        "email" => "[email protected]",
        "address" => [
            "countryCode" => "CI",
            "city" => "Abidjan",
            "streetAddress" => "Plateau Cocody"
        ]
    ],
    "payer" => "0546573332",
    "amount" => "2000",
    "urlSuccess" => "https://digitalpaye.com",
    "urlError" => "https://digitalpaye.com",
    "currency" => "XOF",
    "operator" => "WAVE_MONEY_CI"
];

$collecteWave = $config->createPayment($dataCreateCollecteWave);

if ($collecteWave['data']["status"] == "PENDING") {
    header("Location: " . $collecteWave["data"]["waveLaunchUrl"]);
} else {
    echo $collecteWave["message"];
}


igitalpayeSdkPhp\Services\Digitalpaye;

$apikey = "live_digitalpaye129923061";
$apisecret = "d511e1f4-d932-32fcd-a804-371539700d60c";

$transactionId = "f511e4f4-d932-4fcd-a804-51539700d60c";
$config = new Digitalpaye($apikey, $apisecret);

$getStatusTransaction = $config->getStatus($transactionId);

if ($getStatusTransaction["data"]["status"] == "PENDING") {
    echo "La transaction est en cours de validation";
} elseif ($getStatusTransaction["data"]["status"] == "SUCCESSFUL") {
    echo "La transaction a été validée";
} else {
    echo $getStatusTransaction["message"];
}


igitalpayeSdkPhp\Services\Digitalpaye;

$apikey = "live_digitalpaye129923061";
$apisecret = "d511e1f4-d932-32fcd-a804-371539700d60c";

$config = new Digitalpaye($apikey, $apisecret);

$dataCreateTransfer = [
    "transactionId" => "DIGITAL-0139601181902",
    "customer" => [
        "lastName" => "GUEI",
        "firstName" => "HELIE",
        "phone" => "0777101308",
        "address" => [
            "countryCode" => "CI",
            "city" => "Abidjan",
            "streetAddress" => "Yopougon, Carrefour Canal"
        ]
    ],
    "recipient" => "0777101308",
    "amount" => "100",
    "currency" => "XOF",
    "operator" => "WAVE_MONEY_CI"
];

$transfer = $config->createTransfert($dataCreateTransfer);

if ($transfer['data']["status"] == "SUCCESSFUL") {
    echo "Le transfert a été validé";
} elseif ($transfer['data']["status"] == "PENDING") {
    echo "Le transfert est en cours";
} else {
    echo "Le transfert a échoué";
}
bash
composer