// Optional - Coin selection list (html code)
$coins_list = display_currency_box($available_payments, $def_payment, $def_language, 60, "margin: 80px 0 0 0");
// Form Data
// --------------------------
$ftitle = isset($_POST["ftitle"]) ? $_POST["ftitle"] : "";
$ftext = isset($_POST["ftext"]) ? $_POST["ftext"] : "";
$error = "";
$successful = false;
if (isset($_POST) && isset($_POST["ftitle"])) {
    if (!$ftitle) {
        $error .= "<li>Please enter Title</li>";
    }
    if (!$ftext) {
        $error .= "<li>Please enter Text</li>";
    }
    if (!$box->is_paid()) {
        $error .= "<li>" . $coinName . "s have not yet been received</li>";
    }
    if ($error) {
        $error = "<br><ul style='color:#eb4847'>{$error}</ul>";
    }
    if ($box->is_paid() && !$error) {
        // Successful Cryptocoin Payment received
        // Your code here -
        // ...
        // ...
        // Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
        // Set Payment Status to Processed
        $successful = true;
        $box->set_status_processed();
        // Optional, cryptobox_reset() will delete cookies/sessions with userID and
Пример #2
0
</div>
<br>
<h1>Example - Pay Per View - Video/Page Access for Unregistered Visitors</h1>
<h3>Your Website Visitors have to pay for access to your premium video/webpage(s)</h3>
<br>
Price: ~<?php 
echo $amountUSD;
?>
 US$ for <?php 
echo $period;
?>
 access 
<br><br>

<?php 
if ($box->is_paid()) {
    ?>

	<!-- Successful Cryptocoin Payment received -->
	<!-- You can use the same payment gateway code for few your pages (section1) -->	 
	<!-- Your Premium Page(s) Code  -->
	 
	<h2 style='color:#339e2e;'>Cryptocoin Payment received<br>Successful Access to Premium Page (during <?php 
    echo $period;
    ?>
)</h2>
	<img alt='Cryptocoin Pay Per Page Access' border='0' src='https://gourl.io/images/example9_2.jpg'>
	
	
<?php 
} else {
	// Initialise Payment Class
	$box = new Cryptobox ($options);
	
	// coin name
	$coinName = $box->coin_name(); 
	

	
	// Optional - Language selection list for payment box (html code)
	$languages_list = display_language_box($def_language);
	
	
	
	// Successful Cryptocoin Payment received
	// Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
	if ($box->is_paid())
	{
		// one time action
		if (!$box->is_processed())
		{
			// One time action after payment has been made
					
			$message = "Thank you (order #".$orderID.", payment #".$box->payment_id()."). We upgraded your membership to Premium";
	
			// Set Payment Status to Processed
			$box->set_status_processed();
		}
		else $message = "You have a Premium Membership";
	}
	else
	{	
// Current selected coin by user
$coinName = cryptobox_selcoin($available_payments, $def_payment);
// Current Coin public/private keys
$public_key = $all_keys[$coinName]["public_key"];
$private_key = $all_keys[$coinName]["private_key"];
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Generate Download Link
$download_link = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" . (strpos($_SERVER["REQUEST_URI"], "?") ? "&" : "?") . "dd=1";
$download_link = "href='" . htmlspecialchars($download_link, ENT_QUOTES, 'UTF-8') . "'";
// Warning message if not paid
if (!$box->is_paid()) {
    $download_link = "onclick='alert(\"You need to send " . $coinName . "s first !\")' href='#a'";
}
// Check if file exists on your server
$file = rtrim($dir, "/ ") . "/" . $filename;
if (!file_exists($file)) {
    echo "<h1><center><font color=red>Warning: {$file} not exists</font></center></h1>";
}
// User Paid - Send file to user browser
if ($box->is_paid() && isset($_GET["dd"]) && $_GET["dd"] == "1") {
    // Starting Download
    $size = filesize($file);
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($file));
    header('Expires: 0');
// Current selected coin by user
$coinName = cryptobox_selcoin($available_payments, $def_payment);
// Current Coin public/private keys
$public_key = $all_keys[$coinName]["public_key"];
$private_key = $all_keys[$coinName]["private_key"];
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Optional - Language selection list for payment box (html code)
$languages_list = display_language_box($def_language);
// Successful Cryptocoin Payment received
// Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
if ($box->is_paid()) {
    // one time action
    if (!$box->is_processed()) {
        // One time action after payment has been made
        $message = "Thank you (order #" . $orderID . ", payment #" . $box->payment_id() . "). We upgraded your membership to Premium";
        // Set Payment Status to Processed
        $box->set_status_processed();
    } else {
        $message = "You have a Premium Membership";
    }
} else {
    // Optional - Coin selection list (html code)
    $coins_list = display_currency_box($available_payments, $def_payment, $def_language, 60, "margin: 80px 0 0 0");
}
?>
    }
}
// Current selected coin by user
$coinName = cryptobox_selcoin($available_payments, $def_payment);
// Current Coin public/private keys
$public_key = $all_keys[$coinName]["public_key"];
$private_key = $all_keys[$coinName]["private_key"];
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Successful Cryptocoin Payment received
// Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
if ($box->is_paid()) {
    if (!$box->is_confirmed()) {
        $message = "Thank you for payment (payment #" . $box->payment_id() . "). Awaiting transaction/payment confirmation";
    } else {
        // payment confirmed (6+ confirmations)
        // one time action
        if (!$box->is_processed()) {
            // One time action after payment has been made/confirmed
            $message = "Thank you for order (order #" . $orderID . ", payment #" . $box->payment_id() . "). We will send soon";
            // Set Payment Status to Processed
            $box->set_status_processed();
        } else {
            $message = "Thank you. Your order is in process";
        }
        // General message
    }
	
	// Form Data
	// --------------------------
	$fname	 	= (isset($_POST["fname"])) ? $_POST["fname"] : "";
	$femail  	= (isset($_POST["femail"])) ? $_POST["femail"] : "";
	$fpassword  = (isset($_POST["fpassword"])) ? $_POST["fpassword"] : "";
	
	$error = "";
	$successful = false;
	
	if (isset($_POST) && isset($_POST["fname"]))
	{
		if (!$fname)    		$error .= "<li>Please enter Your Name</li>";
		if (!$femail)   		$error .= "<li>Please enter Your Email</li>";
		if (!$fpassword)   		$error .= "<li>Please enter Your Password</li>";
		if (!$box->is_paid()) 	$error .= "<li>".$coinName."s have not yet been received</li>";
		if ($error)				$error  = "<br><ul style='color:#eb4847'>$error</ul>";
		
		if ($box->is_paid() && !$error)
		{
			// Successful Cryptocoin Payment received

			// Your code here - 
			// save user data in db / register new user ...
			// ...
			// ...
					
			// Set Payment Status to Processed
			$successful = true;
			$box->set_status_processed();
			
Пример #8
0
 public function cryptopayments($pluginName, $amount, $amountCurrency = "USD", $orderID, $period, $default_language = "en", $default_coin = "bitcoin", $affiliate_key = "", $userID = "auto", $icon_width = 60)
 {
     // Security Test
     // ---------------------
     if (!$pluginName) {
         return array("error" => __("Error. Please place in variable \$YourPluginName - your plugin name", GOURL));
     }
     if (preg_replace('/[^a-z0-9\\_\\-]/', '', $pluginName) != $pluginName || strlen($pluginName) < 5 || strlen($pluginName) > 17) {
         return array("error" => sprintf(__("Error. Invalid plugin name - %s. Size: 5-17 symbols. Allowed symbols: a..Z0..9_-", GOURL), $pluginName));
     }
     if (stripos($pluginName, "product") === 0 || stripos($pluginName, "file") === 0 || stripos($pluginName, "pay") === 0 || stripos($pluginName, "membership") === 0 || stripos($pluginName, "user") === 0) {
         return array("error" => __("Error. Please change plugin name. Plugin name can not begin with: 'file..', 'product..', 'pay..', 'membership..', 'user..'", GOURL));
     }
     if (stripos($pluginName, "gourl") !== false && $pluginName != "gourlwoocommerce" && $affiliate_key != "gourl") {
         return array("error" => __("Error. Please change plugin name. Plugin name can not use in name '..gourl..'", GOURL));
     }
     $pluginName = strtolower(substr($pluginName, 0, 17));
     $amountCurrency = trim(strtoupper($amountCurrency));
     if ($amountCurrency == "USD" && (!is_numeric($amount) || $amount < 0.01 || $amount > 1000000)) {
         return array("error" => sprintf(__("Error. Invalid amount value - %s. Min value for USD: 0.01", GOURL), $amount));
     }
     if ($amountCurrency != "USD" && (!is_numeric($amount) || $amount < 0.0001 || $amount > 50000000)) {
         return array("error" => sprintf(__("Error. Invalid amount value - %s. Min value: 0.0001", GOURL), $amount));
     }
     if ($amountCurrency != "USD" && !isset($this->coin_names[$amountCurrency])) {
         return array("error" => sprintf(__("Error. Invalid amountCurrency - %s. Allowed: USD, %s", GOURL), $amountCurrency, implode(", ", array_keys($this->coin_names))));
     }
     if (!$orderID || preg_replace('/[^A-Za-z0-9\\_\\-]/', '', $orderID) != $orderID || strlen($orderID) > 32) {
         return array("error" => sprintf(__("Error. Invalid Order ID - %s. Max size: 32 symbols. Allowed symbols: a..Z0..9_-", GOURL), $orderID));
     }
     $period = trim(strtoupper(str_replace(" ", "", $period)));
     if (substr($period, -1) == "S") {
         $period = substr($period, 0, -1);
     }
     for ($i = 1; $i <= 90; $i++) {
         $arr[] = $i . "MINUTE";
         $arr[] = $i . "HOUR";
         $arr[] = $i . "DAY";
         $arr[] = $i . "WEEK";
         $arr[] = $i . "MONTH";
     }
     if ($period != "NOEXPIRY" && !in_array($period, $arr)) {
         return array("error" => sprintf(__("Error. Invalid period value - %s. Allowed: NOEXPIRY, 1..90 HOUR, 1..90 DAY, 1..90 WEEK, 1..90 MONTH; example: 2 DAYS", GOURL), $period));
     }
     $period = str_replace(array("MINUTE", "HOUR", "DAY", "WEEK", "MONTH"), array(" MINUTE", " HOUR", " DAY", " WEEK", " MONTH", GOURL), $period);
     if (!$default_language) {
         $default_language = "en";
     }
     if (!in_array($default_language, array_keys($this->languages))) {
         return array("error" => sprintf(__("Error. Invalid language - %s. Allowed: %s"), GOURL), $default_language, implode(", ", array_keys($this->languages)));
     }
     if (!$default_coin) {
         $default_coin = "bitcoin";
     }
     if (!in_array($default_coin, $this->coin_names)) {
         return array("error" => sprintf(__("Error. Invalid Coin - %s. Allowed: %s", GOURL), $default_coin, implode(",", $this->coin_names)));
     }
     if ($affiliate_key == "gourl") {
         $affiliate_key = "";
     }
     if ($affiliate_key && (strpos($affiliate_key, "DEV") !== 0 || preg_replace('/[^A-Za-z0-9]/', '', $affiliate_key) != $affiliate_key)) {
         return array("error" => __("Error. Invalid affiliate_key, you can leave it empty", GOURL));
     }
     if (!$userID || $userID == "auto") {
         $userID = get_current_user_id();
     }
     if ($userID && $userID != "guest" && (!is_numeric($userID) || preg_replace('/[^0-9]/', '', $userID) != $userID)) {
         return array("error" => sprintf(__("Error. Invalid User ID - %s. Allowed numeric values or 'guest' value", GOURL), $userID));
     }
     if (!$userID) {
         return array("error" => __("Error.", GOURL) . __("You need first to login or register on the website to make Bitcoin/Altcoin Payments", GOURL));
     }
     if (!$this->payments) {
         return array("error" => __("Error. Please try a different payment method. GoUrl Bitcoin Plugin not configured - need setup payment box keys on GoUrl Bitcoin Gateway Options page", GOURL));
     }
     $icon_width = str_replace("px", "", $icon_width);
     if (!is_numeric($icon_width) || $icon_width < 30 || $icon_width > 250) {
         $icon_width = 60;
     }
     if ($amountCurrency == "USD") {
         $amountUSD = $amount;
         $amountCoin = 0;
         $default_show = false;
     } else {
         $amountUSD = 0;
         $amountCoin = $amount;
         $default_coin = $this->coin_names[$amountCurrency];
         $default_show = true;
     }
     // GoUrl Payments
     // --------------------------
     $all_keys = array();
     // Your payment boxes public / private keys from GoUrl.io
     $available_coins = array();
     // List of coins that you accept for payments
     $cryptobox_private_keys = array();
     // List Of your private keys
     $box_width = $this->options["box_width"];
     $box_height = $this->options["box_height"];
     $box_style = $this->payment_box_style();
     $message_style = $this->payment_message_style();
     foreach ($this->coin_names as $k => $v) {
         $public_key = $this->options[$v . 'public_key'];
         $private_key = $this->options[$v . 'private_key'];
         if ($public_key && !strpos($public_key, "PUB")) {
             return array("error" => sprintf(__('Invalid %s Public Key - %s', GOURL), $v, $public_key));
         }
         if ($private_key && !strpos($private_key, "PRV")) {
             return array("error" => sprintf(__('Invalid %s Private Key', GOURL), $v));
         }
         if ($private_key) {
             $cryptobox_private_keys[] = $private_key;
         }
         if ($private_key && $public_key && (!$default_show || $v == $default_coin)) {
             $all_keys[$v] = array("public_key" => $public_key, "private_key" => $private_key);
             $available_coins[] = $v;
         }
     }
     if (!defined("CRYPTOBOX_PRIVATE_KEYS")) {
         define("CRYPTOBOX_PRIVATE_KEYS", implode("^", $cryptobox_private_keys));
     }
     if (!$available_coins) {
         return array("error" => sprintf(__("Error. Please enter Payment Private/Public Keys on GoUrl Options page for %s", GOURL), $default_coin));
     }
     if (!in_array($default_coin, $available_coins)) {
         $vals = array_values($available_coins);
         $default_coin = array_shift($vals);
     }
     /// GoUrl Payment Class
     // --------------------------
     include_once plugin_dir_path(__FILE__) . "includes/cryptobox.class.php";
     // Current selected coin by user
     $coinName = cryptobox_selcoin($available_coins, $default_coin);
     // Current Coin public/private keys
     $public_key = $all_keys[$coinName]["public_key"];
     $private_key = $all_keys[$coinName]["private_key"];
     // PAYMENT BOX CONFIG
     $options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => $affiliate_key, "orderID" => $pluginName . "." . $orderID, "userID" => $userID == "guest" ? $pluginName . "." . $userID : "user" . $userID, "userFormat" => "MANUAL", "amount" => $amountCoin, "amountUSD" => $amountUSD, "period" => $period, "language" => $default_language);
     // Initialise Payment Class
     $box = new Cryptobox($options);
     // Coin name
     $coinName = $box->coin_name();
     // Paid or not
     $is_paid = $box->is_paid();
     // page anchor
     $anchor = "go" . $this->icrc32($pluginName . "." . $orderID);
     // Coins selection list (html code)
     $coins_list = count($available_coins) > 1 ? display_currency_box($available_coins, $default_coin, $default_language, $icon_width, "margin:10px 0 30px 0;text-align:center;font-weight:normal;", plugins_url('/images', __FILE__), $anchor) : "";
     // Language selection list for payment box (html code)
     $languages_list = display_language_box($default_language, $anchor);
     // Payment Box
     $box_html = $box->display_cryptobox(true, $box_width, $box_height, $box_style, $message_style, $anchor);
     $html = "";
     if (!$is_paid) {
         $html .= "<a id='" . $anchor . "' name='" . $anchor . "'></a>";
     }
     if ($is_paid) {
         $html .= "<br>";
     } else {
         $html .= $coins_list;
     }
     // Cryptocoin Payment Box
     if ($languages_list) {
         $html .= "<table cellspacing='0' cellpadding='0' border='0' width='100%' style='border:0;box-shadow:none;margin:0;padding:0;background-color:transparent'>";
         $html .= "<tr style='background-color:transparent'><td style='border:0;margin:0;padding:0;background-color:transparent'><div style='margin:" . ($coins_list ? 25 : 50) . "px 0 5px " . ($this->options['box_width'] / 2 - 115) . "px;min-width:100%;text-align:center;font-size:13px;color:#666;font-weight:normal;white-space:nowrap;'>" . __('Language', GOURL) . ": " . $this->space(1) . $languages_list . "</div></td></tr>";
         $html .= "<tr style='background-color:transparent'><td style='border:0;margin:0;padding:0;background-color:transparent'>" . $box_html . "</td></tr>";
         $html .= "</table>";
     } else {
         $html .= $box_html;
     }
     // Result
     $obj = $is_paid ? $box->payment_info() : "";
     $arr = array("status" => $is_paid ? "payment_received" : "payment_not_received", "error" => "", "is_paid" => $is_paid, "paymentID" => $is_paid ? $obj->paymentID : 0, "paymentDate" => $is_paid ? $obj->txDate : "", "paymentLink" => $is_paid ? GOURL_ADMIN . GOURL . "payments&s=payment_" . $obj->paymentID : "", "addr" => $is_paid ? $obj->addr : "", "tx" => $is_paid ? $obj->txID : "", "is_confirmed" => $is_paid ? $obj->txConfirmed : "", "amount" => $is_paid ? $obj->amount : "", "amountusd" => $amountUSD, "coinlabel" => $is_paid ? $obj->coinLabel : "", "coinname" => $is_paid ? strtolower($coinName) : "", "boxID" => $is_paid ? $obj->boxID : 0, "boxtype" => $is_paid ? $obj->boxType : "", "boxLink" => $is_paid ? "https://gourl.io/view/coin_boxes/" . $obj->boxID . "/statistics.html" : "", "orderID" => $orderID, "userID" => $userID, "usercountry" => $is_paid ? $obj->countryID : "", "userLink" => $userID == "guest" ? "" : admin_url("user-edit.php?user_id=" . $userID), "is_processed" => $is_paid ? $obj->processed : "", "processedDate" => $is_paid && $obj->processed ? $obj->processedDate : "", "callback_function" => $orderID . "_gourlcallback", "available_payments" => $this->payments, "html_payment_box" => $html);
     if ($is_paid && !$obj->processed) {
         $box->set_status_processed();
     }
     return $arr;
 }
Пример #9
0
 * @package     GoUrl Cryptocurrency Payment API 
 * copyright 	(c) 2014-2016 Delta Consultants
 * @crypto      Supported Cryptocoins -	Bitcoin, Litecoin, Paycoin, Dogecoin, Dash, Speedcoin, Reddcoin, Potcoin, Feathercoin, Vertcoin, Vericoin, Peercoin, MonetaryUnit
 * @website     https://gourl.io/api-php.html
 */
require_once "../cryptobox.class.php";
$options = array("public_key" => "", "private_key" => "", "webdev_key" => "", "orderID" => "your_product1_or_signuppage1_etc", "userID" => "", "userFormat" => "COOKIE", "amount" => 0, "amountUSD" => 2, "period" => "24 HOUR", "iframeID" => "", "language" => "EN");
// IMPORTANT: Please read description of options here - https://gourl.io/api-php.html#options
// Initialise Payment Class
$box1 = new Cryptobox($options);
// Display Payment Box or successful payment result
$paymentbox = $box1->display_cryptobox();
// Log
$message = "";
// A. Process Received Payment
if ($box1->is_paid()) {
    $message .= "A. User will see this message during 24 hours after payment has been made!";
    $message .= "<br>" . $box1->amount_paid() . " " . $box1->coin_label() . "  received<br>";
    // Your code here to handle a successful cryptocoin payment/captcha verification
    // For example, give user 24 hour access to your member pages
    // Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
    // ...
} else {
    $message .= "The payment has not been made yet";
}
// B. One-time Process Received Payment
if ($box1->is_paid() && !$box1->is_processed()) {
    $message .= "B. User will see this message one time after payment has been made!";
    // Your code here - for example, publish order number for user
    // ...
    // Also you can use $box1->is_confirmed() - return true if payment confirmed
Пример #10
0
<script src='../cryptobox.min.js' type='text/javascript'></script>
</head>
<body style='font-family:Arial,Helvetica,sans-serif;font-size:14px;color:#666;margin:0'>
<div align='center'>
<div style='width:100%;height:auto;line-height:50px;background-color:#f1f1f1;border-bottom:1px solid #ddd;color:#49abe9;font-size:18px;'>
	9. GoUrl <b>Pay-Per-View/Page</b> Example (<?= $coinName ?> payments). Use it on your website. 
	<div style='float:right;'><a style='font-size:15px;color:#389ad8;margin-right:20px' href='https://github.com/cryptoapi/Payment-Gateway/blob/master/Examples/pay-per-page.php'>View Source</a><a style='font-size:15px;color:#389ad8;margin-right:20px' href='<?= "//".$_SERVER["HTTP_HOST"].str_replace(".php", "-multi.php", $_SERVER["REQUEST_URI"]); ?>'>Multiple Crypto</a><a style='font-size:15px;color:#389ad8;margin-right:20px' href='https://gourl.io/<?= strtolower($coinName) ?>-payment-gateway-api.html'>Other Examples</a></div>
</div>
<br>
<h1>Example - Pay Per View - Video/Page Access for Unregistered Visitors</h1>
<h3>Your Website Visitors have to pay for access to your premium video/webpage(s)</h3>
<br>
Price: ~<?= $amountUSD ?> US$ for <?= $period ?> access 
<br><br>

<?php if ($box->is_paid()): ?>

	<!-- Successful Cryptocoin Payment received -->
	<!-- You can use the same payment gateway code for few your pages (section1) -->	 
	<!-- Your Premium Page(s) Code  -->
	 
	<h2 style='color:#339e2e;'>Cryptocoin Payment received<br>Successful Access to Premium Page (during <?= $period ?>)</h2>
	<img alt='Cryptocoin Pay Per Page Access' border='0' src='https://gourl.io/images/example9_2.jpg'>
	
	
<? else: ?>

	 <!-- Awaiting Payment -->
	<img alt='Awaiting Payment - Cryptocoin Pay Per Page Access' border='0' src='https://gourl.io/images/example9.jpg'>
	<div style='font-size:12px;margin:30px 0 5px 370px'>Language: &#160; <?= $languages_list ?></div>
	<?= $box->display_cryptobox(true, 530, 230, "padding:3px 6px;margin:10px") ?>
	// Initialise Payment Class
	$box = new Cryptobox ($options);
	
	// coin name
	$coinName = $box->coin_name(); 
	

	
	// Optional - Language selection list for payment box (html code)
	$languages_list = display_language_box($def_language);
	
	
	
	// Optional - Coin selection list (html code)
	if (!$box->is_paid()) $coins_list = display_currency_box($available_payments, $def_payment, $def_language, 60, "margin: 80px 0 0 0");
	
	
	
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title>Pay-Per-View / Page Access Cryptocoin (payments in multiple cryptocurrencies) Payment Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='Expires' content='-1'>
<meta name='robots' content='all'>
<script src='../cryptobox.min.js' type='text/javascript'></script>
</head>
    }
}
// Current selected coin by user
$coinName = cryptobox_selcoin($available_payments, $def_payment);
// Current Coin public/private keys
$public_key = $all_keys[$coinName]["public_key"];
$private_key = $all_keys[$coinName]["private_key"];
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Successful Cryptocoin Payment received
// Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
if ($box->is_paid()) {
    if (!$box->is_confirmed()) {
        $message = "Thank you for payment (payment #" . $box->payment_id() . "). Awaiting transaction/payment confirmation";
    } else {
        // payment confirmed (6+ confirmations)
        // one time action
        if (!$box->is_processed()) {
            // One time action after payment has been made/confirmed
            $message = "Thank you for order (order #" . $orderID . ", payment #" . $box->payment_id() . "). We will send soon";
            // Set Payment Status to Processed
            $box->set_status_processed();
        } else {
            $message = "Thank you. Your order is in process";
        }
        // General message
    }
	
	
	
	// Form Data
	// --------------------------
	$ftitle	 = (isset($_POST["ftitle"])) ? $_POST["ftitle"] : "";
	$ftext 	 = (isset($_POST["ftext"])) ? $_POST["ftext"] : "";
	
	$error = "";
	$successful = false;
	
	if (isset($_POST) && isset($_POST["ftitle"]))
	{
		if (!$ftitle)    		$error .= "<li>Please enter Title</li>";
		if (!$ftext)   			$error .= "<li>Please enter Text</li>";
		if (!$box->is_paid()) 	$error .= "<li>".$coinName."s have not yet been received</li>";
		if ($error)				$error  = "<br><ul style='color:#eb4847'>$error</ul>";
		
		if ($box->is_paid() && !$error)
		{
			// Successful Cryptocoin Payment received
			// Your code here - 
			// ...
			// ...
					
			// Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc

			// Set Payment Status to Processed
			$successful = true;
			$box->set_status_processed();
			
// default Payment Box Language
$public_key = "-your public key for coin box-";
// from gourl.io
$private_key = "-your private key for coin box-";
// from gourl.io
// IMPORTANT: Please read description of options here - https://gourl.io/api-php.html#options
/********************************/
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Successful Cryptocoin Payment received
// Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc
if ($box->is_paid()) {
    if (!$box->is_confirmed()) {
        $message = "Thank you for payment (payment #" . $box->payment_id() . "). Awaiting transaction/payment confirmation";
    } else {
        // payment confirmed (6+ confirmations)
        // one time action
        if (!$box->is_processed()) {
            // One time action after payment has been made/confirmed
            $message = "Thank you for order (order #" . $orderID . ", payment #" . $box->payment_id() . "). We will send soon";
            // Set Payment Status to Processed
            $box->set_status_processed();
        } else {
            $message = "Thank you. Your order is in process";
        }
        // General message
    }
// Current selected coin by user
$coinName = cryptobox_selcoin($available_payments, $def_payment);
// Current Coin public/private keys
$public_key = $all_keys[$coinName]["public_key"];
$private_key = $all_keys[$coinName]["private_key"];
/** PAYMENT BOX **/
$options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language);
// Initialise Payment Class
$box = new Cryptobox($options);
// coin name
$coinName = $box->coin_name();
// Generate Download Link
$download_link = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" . (strpos($_SERVER["REQUEST_URI"], "?") ? "&" : "?") . "dd=1";
$download_link = "href='" . htmlspecialchars($download_link, ENT_QUOTES, 'UTF-8') . "'";
// Warning message if not paid
if (!$box->is_paid()) {
    $download_link = "onclick='alert(\"You need to send " . $coinName . "s first !\")' href='#a'";
}
// Check if file exists on your server
$file = rtrim($dir, "/ ") . "/" . $filename;
if (!file_exists($file)) {
    echo "<h1><center><font color=red>Warning: {$file} not exists</font></center></h1>";
}
// User Paid - Send file to user browser
if ($box->is_paid() && isset($_GET["dd"]) && $_GET["dd"] == "1") {
    // Starting Download
    $size = filesize($file);
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($file));
    header('Expires: 0');