PHP code example of jebanany / lvlup

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

    

jebanany / lvlup example snippets


use Jebanany\Lvlup\ApiClient;
 = new ApiClient('apikey');
// bez używania cURL
$lvlup = new ApiClient('apikey', false, false);

// Sandbox
$lvlup = new ApiClient('sandboxapikey', true);
// bez używania cURL
$lvlup = new ApiClient('sandboxapikey', true, false);

use Jebanany\Lvlup\ApiClient;

ane do konta sandbox
    // zachowaj te dane do swoich następnych testów; nie generuj ich za każdym razem!
    $lvlupSandbox = new ApiClient(false, true);
    $sanboxUser = $lvlupSandbox->sandboxAccountCreate();

    echo "<pre>";
    echo "Dane dostępowe";
    echo "\n ID: " . $sanboxUser->id;
    echo "\n Username: " . $sanboxUser->username;
    echo "\n Password: " . $sanboxUser->password;
    echo "\n Email: " . $sanboxUser->email;
    echo "\n APIkey: " . $sanboxUser->apiKey;
    // zachowaj te dane do swoich następnych testów; nie generuj ich za każdym razem!

    // Mając dane konta sandbox tworzymy nową instancję klasy, tym razem z APIkey
    $lvlupSandbox = new ApiClient($sanboxUser->apiKey, true);

    // Generujemy nową płatność
    $payment = $lvlupSandbox->paymentsCreate(25.00);

    echo "\nDane o wygenerowanej płatności";
    echo "\n url: " . $payment->url;
    echo "\n id: " . $payment->id;

    // Sprawdzamy status płatności
    $status = $lvlupSandbox->paymentsStatus($payment->id);

    echo "\nStatus płatności przed opłaceniem";
    echo "\n payed: " . ($status->payed ? 'true' : 'false'); // false
    echo "\n amountStr: " . $status->amountStr;
    echo "\n amountInt: " . $status->amountInt;
    echo "\n amountWithFeeStr: " . $status->amountWithFeeStr;
    echo "\n amountWithFeeInt: " . $status->amountWithFeeInt;

    // Zmieniamy status płatności - opłacamy / ustawiamy jako opłacone
    $lvlupSandbox->sandboxPaymentAccept($payment->id);

    // Sprawdzamy status płatności ponownie
    $status = $lvlupSandbox->paymentsStatus($payment->id);
    echo "\nStatus płatności po opłaceniu";
    echo "\n payed: " . ($status->payed ? 'true' : 'false'); // true
    echo "\n amountStr: " . $status->amountStr;
    echo "\n amountInt: " . $status->amountInt;
    echo "\n amountWithFeeStr: " . $status->amountWithFeeStr;
    echo "\n amountWithFeeInt: " . $status->amountWithFeeInt;
    echo "</pre>";

} catch (Exception $e) {
    echo 'Kod błędu: <b>' . $e->getCode() . '</b> treść błędu: <b>' . $e->getMessage() . '</b>';
} catch (TypeError $e) {
    echo 'Kod błędu: <b>' . $e->getCode() . '</b> <br>treść błędu: <b>' . $e->getMessage() . '</b>';
}


use Jebanany\Lvlup\ApiClient;

lvlup = new ApiClient(false);
    $sanboxUser = $lvlup->userMe(); // generuje Exception

} catch (Exception $e) {
    echo 'Kod błędu: <b>' . $e->getCode() . '</b> treść błędu: <b>' . $e->getMessage() . '</b>';
   // 
   // Kod błędu: 401 treść błędu: Unauthorized Error (Probably invalid API key)
   // 
} catch (TypeError $e) {
    echo 'Kod błędu: <b>' . $e->getCode() . '</b> <br>treść błędu: <b>' . $e->getMessage() . '</b>';
}

// ordersList(int $limit = null, int $afterId = null, int $beforeId = null)
// return object
$lvlup->ordersList(); //return object

// partnerIpInfo($ip)
// return object
$lvlup->partnerIpInfo('203.0.113.24'); 

// paymentsBalance()
// return object
$lvlup->paymentsBalance(); //object

// paymentsCreate($amount, string $redirectUrl = '', string $webhookUrl = '')
// return object
$lvlup->paymentsCreate(1.5); 
$lvlup->paymentsCreate(1); 
$lvlup->paymentsCreate(1.62); 
$lvlup->paymentsCreate('1.56'); // string jako kwota również działa
$lvlup->paymentsCreate(17, 'http://example.com/redirect', 'http://example.com/webhook'); 

// paymentsList(int $limit = null, int $afterId = null, int $beforeId = null)
// return object
$lvlup->paymentsList(); 
$lvlup->paymentsList(50, 5); 
$lvlup->paymentsList(50, null, 5); 

// paymentsStatus($paymentId)
// return object
$lvlup->paymentsStatus('paymentId'); 

// reportPerformanceCreate($description = '')
// return NULL
$lvlup->reportPerformanceCreate('Problems with MC server. TPS: 9/20'); 
$lvlup->reportPerformanceCreate('TS packetloss: 24%'); 

// sandboxAccountCreate()
// return object
$lvlup->sandboxAccountCreate(); 

// sandboxPaymentAccept($paymentId)
// return NULL
$lvlup->sandboxPaymentAccept('paymentId'); 

// servicesAttacksList(int $vpsIds, int $limit = null, int $afterId = null, int $beforeId = null)
// return object
$lvlup->servicesAttacksList(123); 
$lvlup->servicesAttacksList(123, 50); 
// etc

// servicesList()
// return object
$lvlup->servicesList();

// servicesProxmoxGenerateCredentials($vpsId)
// return object
$lvlup->servicesProxmoxGenerateCredentials(123);

// servicesUdpFilterStatus($vpsId)
// return object
$lvlup->servicesUdpFilterStatus(123);

// servicesUdpFilterStatusSet(int $vpsId, bool $changeTo)
// return object
$lvlup->servicesUdpFilterStatusSet(123, true); //true - on; false - off

// servicesUdpFilterWhitelist(int $vpsId)
// return object
$lvlup->servicesUdpFilterWhitelist(123);

// servicesUdpFilterWhitelistRuleAdd(int $vpsId, int $portFrom, int $portTo, string $protocol)
// $allowedProtocols = ['arkSurvivalEvolved', 'arma', 'gtaMultiTheftAutoSanAndreas', 'gtaSanAndreasMultiplayerMod', 'hl2Source', 'minecraftPocketEdition', 'minecraftQuery', 'mumble', 'rust', 'teamspeak2', 'teamspeak3', 'trackmaniaShootmania', 'other'];
// return object
$lvlup->servicesUdpFilterWhitelistRuleAdd(123, 9987, 9987, 'teamspeak3');
$lvlup->servicesUdpFilterWhitelistRuleAdd(123, 9526, 10465, 'other');

// servicesUdpFilterWhitelistRuleDel(int $vpsId, int $ruleId)
// return object
$lvlup->servicesUdpFilterWhitelistRuleDel(123, 456);

// servicesVpsStart(int $vpsId)
// return object
$lvlup->servicesVpsStart(123);

// servicesVpsState(int $vpsId)
// return object
$lvlup->servicesVpsState(123);

// servicesVpsStop(int $vpsId)
// return object
$lvlup->servicesVpsStop(123);

// userMe()
// return object
$lvlup->userMe();

// userLogList(int $limit = null, int $afterId = null, int $beforeId = null)
// return object
$lvlup->userLogList();
$lvlup->userLogList(50);
// etc

// userReferralCreate()
// return object
$lvlup->userReferralCreate();

// userReferralList()
// return object
$lvlup->userReferralList();