Bitcoin Gateway Integration in Any WP Plugins

bitcoin api

Adding GoUrl Gateway to Other Wordpress Plugins

with Affiliate Bitcoin/Altcoin Program for You (plugin owner)



You can easily integrate Bitcoin payments to your own wordpress plugin using our official wordpress plugin bitcoin gateway (for example, if you have "membership plugin" - you can offer premium membership for bitcoins/altcoins using our wordpress bitcoin gateway). You need to add a few lines of code below to your plugin (gourl bitcoin payment gateway with Affiliate Program for you - 33.3% lifetime revenue share ) and bitcoin/bitcoin cash/litecoin/dogecoin/etc payments will be automatically used in your plugin. GoUrl Wordpress Payment Gateway will do all the work - display payment form, process received payments, etc and will submit that information to your plugin. Around 5 seconds after cryptocoin payment is made, user will see confirmation on webpage with your wordpress plugin that payment is received (i.e. very fast).

You can already use php code from other plugins - PHP source1 or PHP source2 codes - Bitcoin payments for AppThemes and WooCommerce, which uses GoUrl Wordpress Payment Gateway main plugin functionality.

Beneficial for your plugin and website owners - website owners/users will only need to enter bitcoin/bitcoin cash/litecoin wallet addresses once. No multiple times, for different plugins. Also user will see the bitcoin/altcoin payment statistics in one common table "All Payments" with details of all received payments. So it is easy to control everything. Of course, your plugin will have access and can also show bitcoin/altcoin transactions which link to your plugin. You will get 0.50% from each cryptocoin payment made by users through your plugin with GoUrl Payment Gateway installed on various websites.


To integrate Bitcoin Payments to your plugin, please do following -


Part 1. Use php code below in your plugin   (or use php code from other plugins example1 or example2)
Part 2. Create IPN function - pluginname."_gourlcallback" ($user_ID = 0, $order_ID = "", $payment_details = array(), $box_status = "").
That function will be called when a payment is received.
Done.


Part 1 - Place this code inside you wordpress plugin php file -

<?
	global $gourl; // use it if you place this code inside function
	 
	// .... .... your main code

	$YourPluginName = ""; // Please select and enter your unique plugin name. Users will see this name in bitcoin/altcoin payments table.
						// IMPORTANT - Don't change this name in any future your plugin releases! It use to identify all old/new orders from your plugin.
						// $YourPluginName Size: 5-17 characters. Allowed symbols: a-z0-9_-   
	$amount 	= 0; 	// Order amount in currency below
	$currency = "USD"; 	// Currency - USD, BTC, BCH, LTC, Dash, DOGE, SPD, RDD, VTC, FTC, etc. Use USD/EUR/Fiat to accept payments in multiple coins
						// Payment box will automatically convert that USD/Fiat amount to cryptocoin amount using today live cryptocurrency exchange rates
	$orderID	= ""; 	// order id, example: "12345A", "product23", "membership", etc. Max size: 32 characters. Allowed: A-Za-z0-9_- 
						// Different users can have the same orderID, example: orderID="pro_membership" but combination 'orderID'+'userID' should be unique
	$userID = "auto";	// Wordpress registered user id. "auto" - system will automatically get registered user id.  
	$period		= ""; 	// Period after which the payment becomes obsolete and new Payment Box will be shown (you can use it to take new payments 
						// from existing users periodically on daily/monthly basis). Read more - https://gourl.io/api-php.html#period 
						// Available values: NOEXPIRY, 1 MINUTE - 90 MINUTE, 1 HOUR - 90 HOURS, 1 DAY - 90 DAYS, 1 WEEK - 90 WEEKS, 1 MONTH - 90 MONTHS.
	$language	= "en";	// Optional, Default paymentbox localisation. Available: en - English, es - Spanish, fr - French, de - German, nl - Dutch, it - Italian, ru - Russian, pl - Polish, pt - Portuguese, fa - Persian, ko - Korean, ja - Japanese, id - Indonesian, tr - Turkish, ar - Arabic, cn - Simplified Chinese, zh - Traditional Chinese, hi - Hindi. 
						// ko - Korean, ar - Arabic, cn - Simplified Chinese, zh - Traditional Chinese, hi - Hindi. Example:  https://gourl.io/bitcoin-payment-gateway-api.html#live
	$coin = "bitcoin";  // Optional, Default payment coin. User will see list with all accepted cryptocoins on website
	$icon_width = 60;	// Icons width in "Select Payment Method". Default 60px
	$affiliate_key = ""; // Optional, Your affiliate key for lifetime commission. 

	if (!class_exists('gourlclass') || !defined('GOURL') || !is_object($gourl)) {
		echo "Please install and activate wordpress plugin 'GoUrl Bitcoin Gateway' (https://gourl.io/bitcoin-wordpress-plugin.html) ". 
			 "to accept Bitcoin/Altcoin Payments on your website";
	}
	elseif (($userID === "auto" && !is_user_logged_in()) || !is_numeric($userID) || $userID < 1) { 
			echo "<div align='center'><a href='".wp_login_url(get_permalink())."'><img title='You need first to login or register on website
				to make Bitcoin/Altcoin Payments' vspace='10' src='".$gourl->box_image()."' style='border:none;box-shadow:none;'></a></div>";
	}									
	else 
	{
	  // Convert to USD (optional, except cryptocurrencies)
	  // ---------------------------------------------------
	  if ($currency != "USD" && !array_key_exists($currency, $gourl->coin_names()))
	  {
			$amount = gourl_convert_currency($currency, "USD", $amount);
			$currency = "USD";
	  }

	  if ($amount <= 0) {
			echo "Sorry, but there was an error processing your order. Please try a different payment method.";
	  }
	  else
	  {
	  	// Generate payment box or return paid result
		$result = $gourl->cryptopayments ($YourPluginName, $amount, $currency, $orderID, $period, $language, $coin, $affiliate_key, $userID, $icon_width);
		if ($result["error"]) echo "<div style='color:red'>".$result["error"]."</div>";
		else
		{
			// Please note when payment received, IPN script call your function $YourPluginName."_gourlcallback" (if exists).
			// For example, if your plugin name = "myplugin", create new callback function inside your plugin php file - 
			//		function myplugin_gourlcallback ($user_ID = 0, $order_ID = "", $payment_details = array(), $box_status = "") { } with some actions
			
			// A. Process Received Payment
			if ($result["is_paid"]) 
			{
				// Your code here to handle a successful cryptocoin payment
				// In around 5 seconds after cryptocoin payment is made, user will see confirmation on webpage that payment is received
				echo "<br>A. Debug Info - User will see this successful message during $period period after payment has been made!";
				
				// Also you can use $result["is_confirmed"] - return true if payment confirmed 
				// Average transaction confirmation time - 10-60min for 6 confirmations
			}  
			else echo "<br>A. Debug Info - The payment has not been made yet";
	
			// Important: For update order status in database to paid, send email confirmation to user, etc - you need to create
			//		and place that actions in function IPN (instant payment notification) :  function $YourPluginName."_gourlcallback($arr) {}

			
			// B. Optional, One-time Action/Display Successfully Received Payment Message
			if ($result["is_paid"] && !$result["is_processed"]) 
			{
				echo "<br>B. Debug Info - User will see this message one time after payment has been made!";
				// for example, publish confirmation, order number for user online
				// $result["is_processed"] - first time after payment received return TRUE, later return FALSE
			}
			
			// C. Debug - display all payment values
			echo "<br><br>C. Debug Info - All payment values"; 
			echo "<pre>";
			print_r($result);
			echo "</pre>";
			
			// Display Payment Box OR display payment received result   
			echo $result["html_payment_box"];
	  	}
	 }
  }
	
  // .... .... your main code

?>


Function $gourl->cryptopayments() in code above will return to your plugin current payment status -
payment received (image2) or payment not received yet (image1)

bitcoin api screenshot   bitcoin api screenshot





Part 2 - Create IPN function - pluginname."_gourlcallback" ($user_ID = 0, $order_ID = "", $payment_details = array(), $box_status = "")

This function called every time when a new payment from any user is received successfully. Function gets user_ID - user who made payment, current order_ID (the same value as you provided), payment details as array and box_status - 'cryptobox_newrecord' OR 'cryptobox_updated'

Usually the function will automatically appear for each new payment two times :
a) when a new payment is received, with values: $box_status = cryptobox_newrecord, $payment_details[is_confirmed] = 0
b) and a second time when existing payment is confirmed (6+ confirmations) with values: $box_status = cryptobox_updated, $payment_details[is_confirmed] = 1.

But sometimes if the payment notification is delayed for 20-30min, the payment/transaction will already be confirmed and the function will appear once with values: $box_status = cryptobox_newrecord, $payment_details[is_confirmed] = 1

<?   
	function $pluginname.'_gourlcallback' ($user_ID = 0, $order_ID = "", $payment_details = array(), $box_status = "")
	{
		// For example, user with ID = 11 made the payment for your order_ID = product_8
		// Your Function will receive -  
	$user_ID = 11;
	$order_ID = "product_8";
	$payment_details = Array
	{
		"error":"",
		"status":"payment_received",
		"is_paid":1,
		"paymentID":17,
		"paymentDate":"2014-12-12 14:10:46",
		"paymentLink":"https://www.example.com/wp-admin/admin.php?page=gourlpayments&s=payment_17",
		"addr":"BTutorcSLL8PQbfTT3Hahc23fJc8bxD1Wz", // your wallet address on gourl.io
		"tx":"b605bdc2d0e4954f3ffe29c00046c9ce823a756a012248dc137a483a215a5643",
		"is_confirmed":0,
		"amount":"0.00694415",
		"amountusd":"12.5",
		"coinlabel":"BTC",
		"coinname":"bitcoin",
		"boxID":"34",
		"boxtype":"paymentbox",
		"boxLink":"https://gourl.io/view/coin_boxes/34/statistics.html",
		"orderID":"product_8",
		"userID":"11",
		"usercountry":"CAN",
		"userLink":"https://www.example.com/wp-admin/user-edit.php?user_id=11"
	} 
	$box_status = "cryptobox_newrecord"; // or "cryptobox_updated"
	?>


Done. Your wordpress plugin will successfully process bitcoin/altcoin payments and you will get lifetime bitcoin/altcoin commission




Our Other Bitcoin Affiliate Programs »









CONTACT US


We offer Free Support. Please feel free to contact us if you have any questions

Contact Us







Back to Top