Make your website payable by Bitcoin. Use our sample code to integrate in your website and earn directly to your wallet.
HTML Form
Config form to get paid in your website
<form action="https://coinzune.com/payment" method="POST">
<input type="hidden" name="merchant_account" value="merchant@email.com">
<input type="hidden" name="item_number" value="2">
<input type="hidden" name="item_name" value="iPhone 8 PLUS 64GB">
<input type="hidden" name="item_price" value="0.24256">
<input type="hidden" name="item_currency" value="BTC">
<input type="hidden" name="return_success" value="http://yourwebsite.com/success.php">
<input type="hidden" name="return_fail" value="http://yourwebsite.com/fail.php">
<input type="hidden" name="return_cancel" value="http://yourwebsite.com/cancel.php">
<button type="submit">Pay via Bitcoin</button>
</form>
String | Value | Decription |
---|---|---|
merchant_account | Eg: merchant@email.com | This field is required to verify your account and to transfer Bitcoin payment direct to your wallet. Enter your email address with which you are registered in our website. |
item_number | Eg: 2 | With this field, you can enter an order number, a product number, or any number that will be returned to your site upon successful payment to confirm the payment. |
item_name | Eg: iPhone 8 PLUS 64GB | This will be shown in our payment page, to know customer for what pay. |
item_price | Eg: 0.24256 | Here you can enter price in BTC or in USD which will be converted automatically to BTC. |
item_currency | Eg: BTC/USD | If you enter BTC will receive amount which you are entered, if you are enter price in USD will be converted automatically to BTC. |
return_success | Eg: http://yourwebsite.com/success.php | Enter page url addressfor IPN verification (php code is below) and successful payment message. |
return_fail | Eg: http://yourwebsite.com/fail.php | Enter page url address with message for failed payment. |
return_cancel | Eg: http://yourwebsite.com/cancel.php | Enter page url address with message for canceled payment. |
PHP Code
IPN Verification to run code when payment was successful.
success.php
<?php
$merchant_key = '...'; // Enter here your merchant API Key
$merchant_account = $_POST['merchant_account'];
$item_number = $_POST['item_number'];
$item_name = $_POST['item_name'];
$item_price = $_POST['item_price'];
$item_currency = $_POST['item_currency'];
$txid = $_POST['txid']; // Transaction ID
$btc_txid = $_POST['btc_txid']; // Bitcoin Transaction ID
$payment_time = $_POST['payment_time']; // Current time of payment
$payee_account = $_POST['payee_account']; // The account of payee or Bitcoin address
$verification_link = "https://coinzune.com/payment_status.php?merchant_key=$merchant_key&merchant_account=$merchant_account&txid=$txid";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$verification_link);
$results=curl_exec($ch);
curl_close($ch);
$results = json_decode($results);
if($results->status == "success") {
//Payment is successful
//Run your php code here
echo 'Payment is successful.';
} else {
echo 'Payment was failed.';
}
?>