PHP code example of munna / coin-payment

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

    

munna / coin-payment example snippets


. . .

use Munna\CoinPayment\CoinPayment;
$coinpaymnt = new Coinpayment();
$basic = $coinpaymnt->basicInfo();


//By Facade Class
use Munna\CoinPayment\Facade\CoinPayment;
$basic = CoinPayment::basicInfo();

// Return Data as json
. . .


use Munna\CoinPayment\CoinPayment;
$mc = new CoinPayment();

$envVariabl = $mc->checkEnv();
$checkProperty = $mc->checkProperty();
$checkSettings = $mc->checkSettings();
$address = $mc->getAddress("BTC"); // paramater is your targeted coin name
$txDetails = $mc->txnInfo("CPFJ5EA5DZI1KRY1KKX4CXHXQW");  // parameter is txn id
$rates = $mc->rates(); // get rates
$balances = $mc->balances(); // get balanace
$txnLists = $mc->txnLists(); // get transactions lists
$withdrawDetails = $mc->withdrawDetails("CWFJ007ZT8ZFEZFUWKIKA3WF6Q");  // parameter is withdraw id

// withdraw amount
$address = "mmGSjBhsqZBm68N1rJnM7MPTNx1KVkrMxT"; // your targeted address
$data = [ 
    'amount' => 0.5,
    'currency' => "LTCT",
    'address' => $address,
    'auto_confirm' => 1,  // auto confirm is withour email confirmation, 0 for email confirmation
];
$withdraw = $mc->withdraw($data); // withdraw method

// create tx fields are 


use Munna\CoinPayment\Facade\CoinPayment;

$envVariabl = CoinPayment::checkEnv();
$checkProperty = CoinPayment::checkProperty();
$checkSettings = CoinPayment::checkSettings();
$address = CoinPayment::getAddress("BTC"); // paramater is your targeted coin name
$txDetails = CoinPayment::txnInfo("CPFJ5EA5DZI1KRY1KKX4CXHXQW");  // parameter is txn id
$rates = CoinPayment::rates(); // get rates
$balances = CoinPayment::balances(); // get balanace
$txnLists = CoinPayment::txnLists(); // get transactions lists
$withdrawDetails = CoinPayment::withdrawDetails("CWFJ007ZT8ZFEZFUWKIKA3WF6Q");  // parameter is withdraw id

// withdraw amount
$address = "mmGSjBhsqZBm68N1rJnM7MPTNx1KVkrMxT"; // your targeted address
$data = [ 
    'amount' => 0.5,
    'currency' => "LTCT",
    'address' => $address,
    'auto_confirm' => 1,  // auto confirm is withour email confirmation, 0 for email confirmation
];
$withdraw = CoinPayment::withdraw($data); // withdraw method

// create tx fields are 

. . .
/**
  * The URIs that should be excluded from CSRF verification.
  * This URL must be post url
  * @var array
  */
protected $except = [
    '/coinpayment/ipn' //your ipn route
]; 


// in your web.php
// its just an example
$route->post('coinpayment/ipn', [IpnController::class, 'ipnWebHook']);

// in IpnController.php controller or class
public function ipnWebHook(Request $get){
    
    // $get instance should be return txn_id as transaction id
    
    $coinpayment = new CoinPayment();    
    // by txn_id call the txn Information
    $info = $coinpayment->txnInfo($get->txn_id);
    // here is your txn information to check txn is confirmed or not
    // here is the json format of txn info
    // and manage txn by its status
    // when status = 100 then txn is confirmed otherwise not confirmed
}
. . .