PHP code example of paydotir / php-sdk

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

    

paydotir / php-sdk example snippets


$gateway = new \Payir\SDK\Services\Gateway('API-KEY');
$send = $gateway->send(10000, "https://callback-url", [
    // additional data goes here
]);
$paymentUrl = "https://pay.ir/pg/$send->token";

$gateway = new \Payir\SDK\Services\GatewayShare('API-KEY');
$send = $gateway->send(10000, "https://callback-url", [
    // additional data goes here
]);
$paymentUrl = "https://pay.ir/pg/$send->token";

$gateway = new \Payir\SDK\Services\Gateway('API-KEY');
$verify = $gateway->verify("token");
$paymentData = [
    "amount" => $verify->amount,
    "transId" => $verify->transId,
    "factorNumber" => $verify->factorNumber,
    "mobile" => $verify->mobile,
    "description" => $verify->description,
    "cardNumber" => $verify->cardNumber,
    "message" => $verify->message
];

$api = new \Payir\SDK\Services\Wallet("API-TOKEN");
$walletsList = $api->getList(); // this will return an object of \Payir\SDK\DTO\Wallet\WalletsDTO::class
foreach ($walletsList->wallets as $wallet) {
    // $wallet is an instance of \Payir\SDK\DTO\Wallet\WalletDTO::class
}

$api = new \Payir\SDK\Services\Wallet("API-TOKEN");
$wallet = $api->get("wallet-id"); // this will return an object of \Payir\SDK\DTO\Wallet\WalletDTO::class

$api = new \Payir\SDK\Services\Cashout("API-TOKEN");
$cashout = $api->track("uid"); // this will return an object of \Payir\SDK\DTO\Cashout\CashoutDTO::class or false

$api = new \Payir\SDK\Services\Cashout("API-TOKEN");
$cashout = $api->create(
    "wallet-id", 
    "amount-IRR", 
    "receiver-name", 
    "receiver-IBAN", 
    "uid" // a unique id from your application
); // this will return an object of \Payir\SDK\DTO\Cashout\CashoutDTO::class

$api = new \Payir\SDK\Services\Cashout("API-TOKEN");
$cashout = $api->get("cashout-id"); // this will return an object of \Payir\SDK\DTO\Cashout\CashoutDTO::class

$api = new \Payir\SDK\Services\Cashout("API-TOKEN");
$cashoutsList = $api->getList(); // this will return an object of \Payir\SDK\DTO\Cashout\CashoutsDTO::class
foreach ($cashoutsList->cashouts as $cashout) {
    // $cashout is an instance of \Payir\SDK\DTO\Cashout\CashoutDTO::class
}

$api = new \Payir\SDK\Services\Cashout("API-TOKEN");
$delete = $api->delete("cashout-id"); // this will return true or false

$api = new \Payir\SDK\Services\Cashout("API-TOKEN");
$inquiry = $api->ibanInquiry("IBAN-NUMBER"); // this will return an object of \Payir\SDK\DTO\Cashout\IbanInquiryDTO::class

$api = new \Payir\SDK\Services\Transaction("API-TOKEN");
$transactionsList = $api->getList([
    // [optional] supported filters here like below
    "fromDate" => "2022-02-02",
    "toDate" => "2022-03-02",
    "fromAmount" => "10000",
    "toAmount" => "20000",
    "transactionId" => "12345",
    "depositType" => 1, // 1 for Credit and -1 for Debit
    "transactionType" => \Payir\SDK\Enums\TransactionTypes::GATEWAY,
    "cardNumber" => "6219XXXXXXXXXXXX",
    "factorNumber" => "factor-number-in-your-app",
    "walletId" => "wallet-id",
    "sort" => \Payir\SDK\Enums\TransactionSort::ASC
]); // this will return an object of \Payir\SDK\DTO\Transaction\TransactionsDTO::class
foreach ($transactionsList->transactions as $transaction) {
    // $transaction is an instance of \Payir\SDK\DTO\Transaction\TransactionDTO::class
}

$api = new \Payir\SDK\Services\Transfer("API-TOKEN");
$transfer = $api->self(
    "from-wallet-id",
    "to-wallet-id",
    "amount",
    "description",
    "senders-ip-address" // you can pass your servers ip or your client's ip address
); // this will return an object of \Payir\SDK\DTO\Transfer\TransferDTO::class

$api = new \Payir\SDK\Services\Transfer("API-TOKEN");
$transfer = $api->other(
    "from-wallet-id",
    "receivers-mobile-number",
    "amount",
    "description",
    "senders-ip-address" // you can pass your servers ip or your client's ip address
); // this will return an object of \Payir\SDK\DTO\Transfer\TransferDTO::class