Example #1
0
)</h2>
	<img alt='Cryptocoin Pay Per Page Access' border='0' src='https://gourl.io/images/example9_2.jpg'>
	
	
<?php 
} 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; <?php 
    echo $languages_list;
    ?>
</div>
	<?php 
    echo $box->display_cryptobox(true, 530, 230, "padding:3px 6px;margin:10px");
    ?>
	
<?php 
}
?>
 	


</div><br><br><br><br><br><br>
<div style='position:absolute;left:0;'><a target="_blank" href="http://validator.w3.org/check?uri=<?php 
echo "https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
?>
"><img src="https://gourl.io/images/w3c.png" alt="Valid HTML 4.01 Transitional"></a></div>
</body>
</html>
<?php if ($box->is_paid()): ?>

	<!-- User already paid premium membership -->
	<!-- You can use this function - $box->is_paid() on all other your premium webpages, it will return true during all user paid period (1 month) --> 
	<!-- Your Premium Pages Code Here -->

	<br><br><br>
	<?= $message ?>
	<br><br><br>
	
	
<? else: ?>

	 <!-- Awaiting Payment -->
	<a href='#gourlcryptocoins'><img alt='Awaiting Payment - Cryptocoin Pay Per Membership' border='0' src='https://gourl.io/images/example10.png'></a>
	<br><br><br>	
	<h3>Upgrade Your Membership Now ( $<?= $amountUSD ?> per <?= $period ?> ) - </h3>
	
<? endif; ?> 	

	<br><br>
	<? if (!$box->is_paid()) echo $coins_list;  ?>
	<div style='font-size:12px;margin:50px 0 5px 370px'>Language: &#160; <?= $languages_list ?></div>
	<?= $box->display_cryptobox(true, 530, 230, "padding:3px 6px;margin:10px;border:10px solid #f7f5f2;") ?>

	
</div><br><br><br><br><br><br>
<div style='position:absolute;left:0;'><a target="_blank" href="http://validator.w3.org/check?uri=<?= "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ?>"><img src="https://gourl.io/images/w3c.png" alt="Valid HTML 4.01 Transitional"></a></div>
</body>
</html>
        echo "margin:5px 0 5px 390px;";
    } else {
        echo "margin:5px 0 5px 390px; position:absolute;";
    }
    ?>
'>Language: &#160; <?php 
    echo $languages_list;
    ?>
</div>
			<?php 
    if (!$box->is_paid()) {
        echo "<div align='left'>" . $coins_list . "</div>";
    }
    ?>
			<?php 
    echo $box->display_cryptobox();
    ?>
	</div>
	
	<br><br><br>
	<button onclick='document.form1.submit()' style='padding:6px 20px;font-size:18px;'>Post Your Article/Comment</button>
	
<?php 
}
?>
 	


</div><br><br><br><br><br><br>
<div style='position:absolute;left:0;'><a target="_blank" href="http://validator.w3.org/check?uri=<?php 
echo "https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
Example #4
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;
 }
?>
.png'>
<img alt='Invoice' border='0' height='500' src='https://gourl.io/images/invoice.png'>
<br><br>
<?php 
if (!$box->is_paid()) {
    echo $coins_list . "<br><br><h2>Pay Invoice Now - </h2>";
}
?>
<br><br>
<div style='margin:30px 0 5px 300px'>Language: &#160; <?php 
echo $languages_list;
?>
</div>
<?php 
echo $box->display_cryptobox(true, 560, 230, "border-radius:15px;border:1px solid #eee;padding:3px 6px;margin:10px;", "display:inline-block;max-width:580px;padding:15px 20px;border:1px solid #eee;margin:7px;line-height:25px;");
?>
<br><br><br>
<h3>Message :</h3>
<h2 style='color:#999'><?php 
echo $message;
?>
</h2>


</div><br><br><br><br><br><br>
<div style='position:absolute;left:0;'><a target="_blank" href="http://validator.w3.org/check?uri=<?php 
echo "https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
?>
"><img src="https://gourl.io/images/w3c.png" alt="Valid HTML 4.01 Transitional"></a></div>
</body>
	<div align='center' style='margin:40px;font-size:24px;color:#339e2e;font-weight:bold'>You have been successfully registered on our website!</div>
	
<? else: ?>

	<form name='form1' style='font-size:14px;color:#444' action="pay-per-registration.php#i" method="post">
		<table cellspacing='20'>
			<tr><td colspan='2'><b>NEW USER</b><?= $error ?><input type='text' style='display: none'><input type='password' style='display: none'></td></tr>
			<tr><td width='100'>Name: </td><td width='300'><input style='padding:6px;font-size:18px;' size='30' type="text" name="fname" value="<?= $fname ?>"></td></tr>
			<tr><td>Email: </td><td><input style='padding:6px;font-size:18px;' size='40' type="text" name="femail" value="<?= $femail ?>"></td></tr>
			<tr><td>Password: </td><td><input style='padding:6px;font-size:18px;' size='35' type="password" name="fpassword" value="<?= $fpassword ?>"><br><br></td></tr>
		</table>
	</form>

	<div style='width:600px;padding-top:10px'>
			<div style='font-size:12px; margin:5px 0 5px 390px;'>Language: &#160; <?= $languages_list ?></div>
			<?= $box->display_cryptobox(true, 530, 230, "border-radius:15px;border:2px dashed #eee;padding:3px 6px;margin:10px") ?>
	</div>
	
	<?php if (!$box->is_paid()): ?>
		<br>* You need to pay <?= $coinName ?>s (~<?= $amountUSD ?> US$) for register on our website<br>
	<? endif; ?>	
	
	<br><br>
	<button onclick='document.form1.submit()' style='padding:6px 20px;font-size:18px;'>Register</button>
	
<? endif; ?> 	


</div><br><br><br><br><br><br>
<div style='position:absolute;left:0;'><a target="_blank" href="http://validator.w3.org/check?uri=<?= "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ?>"><img src="https://gourl.io/images/w3c.png" alt="Valid HTML 4.01 Transitional"></a></div>
</body>
        echo "margin:5px 0 5px 390px;";
    } else {
        echo "margin:5px 0 5px 390px; position:absolute;";
    }
    ?>
'>Language: &#160; <?php 
    echo $languages_list;
    ?>
</div>
			<?php 
    if (!$box->is_paid()) {
        echo "<div align='left'>" . $coins_list . "</div>";
    }
    ?>
			<?php 
    echo $box->display_cryptobox(true, 530, 230, "border-radius:15px;border:1px solid #eee;padding:3px 6px;margin:10px");
    ?>
	</div>
	
	<?php 
    if (!$box->is_paid()) {
        ?>
		<br>* You need to pay <?php 
        echo $coinName;
        ?>
s (~<?php 
        echo $amountUSD;
        ?>
 US$) for register on our website<br>
	<?php 
    }
<?php

/**
 * @category    Basic Example
 * @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()) {
<img alt='Invoice' border='0' height='500' src='https://gourl.io/images/invoice.png'>

<br><br>
<?php 
if (!$box->is_paid()) {
    echo "<h2>Pay Invoice Now - </h2>";
} else {
    echo "<br><br>";
}
?>
<div style='margin:30px 0 5px 300px'>Language: &#160; <?php 
echo $languages_list;
?>
</div>
<?php 
echo $box->display_cryptobox(true, 570, 230);
?>
<br><br><br>
<h3>Message :</h3>
<h2 style='color:#999'><?php 
echo $message;
?>
</h2>


</div><br><br><br><br><br><br>
<div style='position:absolute;left:0;'><a target="_blank" href="http://validator.w3.org/check?uri=<?php 
echo "https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
?>
"><img src="https://gourl.io/images/w3c.png" alt="Valid HTML 4.01 Transitional"></a></div>
</body>
	</div>	
	
<? else: ?>

	<form name='form1' style='font-size:14px;color:#444' action="pay-per-post-multi.php#i" method="post">
		<table cellspacing='20'>
			<tr><td colspan='2'><img alt='New Post' border='0' src='https://gourl.io/images/example7.png'><?= $error ?></td></tr>
			<tr><td width='100'>Title: </td><td width='300'><input style='padding:6px;font-size:18px;' size='40' type="text" name="ftitle" value="<?= $ftitle ?>"></td></tr>
			<tr><td>Text: </td><td><textarea style='padding:6px;font-size:18px;' rows="4" cols="40" name="ftext"><?= $ftext ?></textarea></td></tr>
			<?php if (!$box->is_paid()): ?>
				<tr><td colspan='2'>* You need to pay <?= $coinName ?>s (~<?= $amountUSD ?> US$) for posting your text on our website</td></tr>
			<? endif; ?>
		</table>
	</form>

	<div style='width:600px;background-color:#f9f9f9;padding-top:10px'>
			<div style='font-size:12px;<? if ($box->is_paid()) echo "margin:5px 0 5px 390px;"; else echo "margin:5px 0 5px 390px; position:absolute;" ?>'>Language: &#160; <?= $languages_list ?></div>
			<? if (!$box->is_paid()) echo "<div align='left'>".$coins_list."</div>";  ?>
			<?= $box->display_cryptobox() ?>
	</div>
	
	<br><br><br>
	<button onclick='document.form1.submit()' style='padding:6px 20px;font-size:18px;'>Post Your Article/Comment</button>
	
<? endif; ?> 	


</div><br><br><br><br><br><br>
<div style='position:absolute;left:0;'><a target="_blank" href="http://validator.w3.org/check?uri=<?= "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ?>"><img src="https://gourl.io/images/w3c.png" alt="Valid HTML 4.01 Transitional"></a></div>
</body>
</html>