/**
  * Pay to list products
  *
  * @param mixed $userID
  * @param mixed $paymentType
  * @return bool|int|null|string|void
  */
 public function payListingFee($userID, $prodID, $paymentType = BuckysShopProduct::LIST_FEE_PAYMENT_TYPE_BTC)
 {
     $flag = false;
     if ($paymentType == BuckysShopProduct::LIST_FEE_PAYMENT_TYPE_CREDIT) {
         $transactionIns = new BuckysTransaction();
         $flag = $transactionIns->useCreditsInShop($userID, SHOP_PRODUCT_LISTING_FEE_IN_CREDIT);
     } else {
         if ($paymentType == BuckysShopProduct::LIST_FEE_PAYMENT_TYPE_BTC) {
             $flag = BuckysBitcoin::sendBitcoin($userID, SHOP_TNB_LISTING_FEE_RECEIVER_BITCOIN_ADDRESS, SHOP_PRODUCT_LISTING_FEE_IN_BTC);
             buckys_get_messages();
             // this will flash the messages
             if ($flag) {
                 //Create bitcoin transaction
                 BuckysBitcoinTransaction::addTransaction(BuckysBitcoinTransaction::TNB_BITCOIN_RECEIVER_ID, $userID, BuckysBitcoinTransaction::ACTIVITY_TYPE_LISTING_PRODUCT, $prodID, SHOP_PRODUCT_LISTING_FEE_IN_BTC);
             }
         }
     }
     return $flag;
 }
        $result[] = ["id" => $row['userID'], 'label' => $row['fullName'], 'value' => $row['fullName'], 'hash' => buckys_encrypt_id($row['userID'])];
    }
    echo json_encode($result);
    buckys_exit();
}
if (isset($_POST['action']) && $_POST['action'] == 'send-money') {
    if (!isset($_POST['receiverID']) || !isset($_POST['receiverIDHash']) || !isset($_POST['amount']) || !buckys_check_id_encrypted($_POST['receiverID'], $_POST['receiverIDHash'])) {
        buckys_redirect('/credits.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
    }
    $result = BuckysTransaction::sendCredits($_POST['receiverID'], $_POST['amount']);
    if ($result === true) {
        buckys_redirect('/credits.php', MSG_SENT_CREDITS_SUCCESSFULLY);
    } else {
        buckys_redirect('/credits.php', $result, MSG_TYPE_ERROR);
    }
    exit;
}
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$totalCount = BuckysTransaction::getNumOfCreditActivities($userID);
//Init Pagination Class
$pagination = new Pagination($totalCount, BuckysTransaction::$COUNT_PER_PAGE, $page);
$page = $pagination->getCurrentPage();
$activities = BuckysTransaction::getCreditActivities($TNB_GLOBALS['user']['userID'], $page);
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('credits.css');
buckys_enqueue_javascript('credits.js');
buckys_enqueue_javascript('payment.js');
$TNB_GLOBALS['content'] = 'credits';
$TNB_GLOBALS['title'] = "Credits - " . TNB_SITE_NAME;
$TNB_GLOBALS['payerID'] = $userID;
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
 /**
  * Use one credits
  *
  * @param integer $userID
  * @param double $credits
  */
 public function useCredit($userID, $credits = 1)
 {
     //Update credit activity table (credit has been used)
     $transactionIns = new BuckysTransaction();
     $transactionIns->useCreditsInTrade($userID, $credits);
     return $credits;
 }
 $txnId = $_POST['txn_id'];
 //unique transaction id
 $receiverEmail = $_POST['receiver_email'];
 $payerEmail = $_POST['payer_email'];
 $paymentCustom = $_POST['custom'];
 //custom value will be credit number, you may use this one
 $sellerPaypalEmail = TNB_PAYPAL_EMAIL;
 if (TNB_PAYPAL_MODE_LIVE == false) {
     $sellerPaypalEmail = TNB_PAYPAL_SANDBOX_EMAIL;
 }
 if ($receiverEmail == $sellerPaypalEmail && $paymentCurrency == TNB_PAYPAL_CURRENCY) {
     if ($paymentStatus == 'Completed') {
         //payment_status = Completed)
         //Update payment status as paid :), means creating transactions
         // Create Transaction in transaction table
         $transactionIns = new BuckysTransaction();
         $data['userID'] = $paymentCustom;
         $data['payer_email'] = $payerEmail;
         $data['amount'] = $paymentAmount;
         $data['currency'] = $paymentCurrency;
         $data['trackNumber'] = $txnId;
         $transactionIns->addPaypalTransaction($data);
         //Send notification, you may send email to clients
     } else {
         //status is not complete, // if status is not complete, then log this status
         //payment_status can be one of the following
         //Canceled_Reversal: A reversal has been canceled. For example, you won a dispute with the customer, and the funds for
         //                           Completed the transaction that was reversed have been returned to you.
         //Completed:            The payment has been completed, and the funds have been added successfully to your account balance.
         //Denied:                 You denied the payment. This happens only if the payment was previously pending because of possible
         //                            reasons described for the PendingReason element.