lunawallet's Instant Payment Notification (IPN) makes it ridiculously easy to confirm payments automatically and reduce humans efforts involved in the process of confirming the payment. Whenever, anyone purchases a service or product at your website, we'll call out a ping request at your site to inform you about it. Before you start, generate an IPN key (Don't share it with anyone!). Once you generate a new IPN key, the previous key will become invalid.


define("MY_EMAIL","[email protected]");

// Do the verification else the site's security will be at a compromise.

if($_POST['recipient'] == MY_EMAIL AND $_POST['ipn_key'] == MY_IPN_KEY) {
// Assign post values their variables
$date = date("Y-m-d");
$custom1 = $_POST['custom1'];
$custom2 = $_POST['custom2'];
$currency = $_POST['currency'];
$amount = $_POST['amount'];

// Calculate the price

if($currency == "usd") {
	$final_amount = $amount;
} else {
	//Convert BTC to USD
	$fetch = fetch_content("");
    $fetch = json_decode($fetch, TRUE);
    $rate = $fetch[1]["rate"];
	$final_amount = round($amount*$rate, 8);

//Let's log it now.

mysqli_query($db,"INSERT INTO logs (date,custom1,custom2,amount) VALUES ('$date','$custom1','$custom2','$final_amount')");

echo 1;	//Means that you have received the ping successfully.
} else {
echo 0; //Means the payment wasn't handled properly.


Setting Buttons:

Once an user clicks on the button, they will be redirected to our website and asked to finalize the payment, once done finalizing the payment, an IPN will be issued to your site. Learn the correct way to make the button here.

<form action="" method="post">

<input type="hidden" name="merchant_email" value="[email protected]">
<input type="hidden" name="ipn_url" value="">
<input type="hidden" name="return_url" value="">
<input type="hidden" name="cancel_url" value="">
<input type="hidden" name="currency" value="usd">
<input type="hidden" name="amount" value="5">
<input type="hidden" name="user_id" value="1054">
<input type="hidden" name="product_id" value="14">
<input type="hidden" name="custom1" value="xyzxyzyxyz">
<input type="hidden" name="custom_inputs" value="user_id product_id custom1">
<input type="submit" name="send_payment" value="Pay via lunawallet">


Remember, in the above example, you have to fill your merchant_email, ipn_url, currency (either, usd or btc),return_url, cancel_url and custom_inputs. custom inputs field includes the name of the custom fields used for retrieving data later via IPN. It's necessary to mention the names of the custom fields in the custom_inputs field and be sure to separate them by one space.

Scroll Up