Follow the instructions outlined below to ensure a seamless integration into your LFM, LFMTE, or LFMVM script.
public_html/inc/config.php
via File Manager)public_html/inc/config.php
via File Manager)Part 1:
A. Open phpMyAdmin via cPanel or your hosting provider.
B. Using the directory on the left side of the page open your LFM table.
C. Find and click on the table named PREFIX_ipn_merchants
.
D. There are five rows in this table all named accordingly to their payment processor.
E. Click Edit
on the row that you wish to replace with HivePay (It is not recommended to replace the Comms
row.
F. Change the name
to HivePay and click Go
.
Part 2:
A. While still in phpMyAdmin find and click on the table named PREFIX_ipn_transactions
.
B. Click Structure
on the menu above the table contents.
C. Identify Row 4 with the name of txn_id
.
D. Row 4 Type
should say varchar(100)
, if it does continue to Step 1 Part 3, if not continue reading.
E. Click Change
on Row 4.
F. Change the Length/Values
from 30 to 100 and click Save
.
Part 3:
A. While still in phpMyAdmin find and click on the table named PREFIX_sales
.
B. Click Structure
on the menu above the table contents.
C. Identify Row 9 with the name of txn_id
.
D. Row 9 Type
should say varchar(100)
, if it does continue to Step 1 Part 4, if not continue reading.
E. Click Change
on Row 9.
F. Change the Length/Values
from 30 to 100 and click Save
.
Part 4:
A. Exit out of phpMyAdmin and continue to Step 2.
Part 1:
A. Open File Manager via cPanel or your hosting provider.
B. Navigate to the public_html/ipn
folder.
C. Create a new file named: hivepay.php
.
D. Edit the hivepay.php
file and paste in the following code:
<?php
function convert_currency($amount,$base,$return='USD') {
$service_url = 'https://api.hivepay.io/';
$curl = curl_init($service_url);
$t='{
"hivepay.convert": {
"base_currency": "'.$base.'",
"return_currency": "'.$return.'",
"amount": "'.$amount.'"
}
}';
$data_string = json_encode($t);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $t);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($t))
);
$response=curl_exec($curl);
curl_close($curl);
$response=json_decode($response, true);
$amt=number_format($response["return_amount"], '2', '.', '');
if($amt==0.00) {
return '0.01';
}
return $amt;
}
$api_url='https://hivepay.io/verify/';
$ch = curl_init($api_url);
$verify = array(
'hivepay_ipn' => 'notification',
'txid' => $txid,
'token' => $token,
'token_amount' => $token_amount,
'buyer' => $buyer,
'merchant' => $merchant,
'amount_received' => $amount_received
);
$payload = json_encode(array("verify_data" => $verify));
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$result=json_decode($result, true);
if($result["error"]) {
processError($result["error"],$_POST);
http_response_code(300);
exit;
}
$qry="SELECT `payee` FROM `".$prefix."ipn_merchants` WHERE `name`='HivePay'";
$res=lfmsql_query($qry);
$row=lfmsql_fetch_array($res);
$hiveusername=$row["payee"];
if($txid==$result["verify_txid"] && $hiveusername==$merchant && $payment_successful==1) {
$fee=convert_currency($fee,$token);
$amount=convert_currency($amount_received,$token);
$total=($amount+$fee)+'1.00';
if($total>=$base_amount) {
$qry="SELECT `name` FROM `".$prefix."ipn_products` WHERE `id`='".$itemid."'";
$res=lfmsql_query($qry);
$row=lfmsql_fetch_array($res);
$item_name=$row["name"];
$qry="SELECT `firstname`,`lastname`,`email` FROM `".$prefix."members` WHERE `Id`='".$user_id."'";
$res=lfmsql_query($qry);
$row=lfmsql_fetch_array($res);
$member_name=$row["firstname"].' '.$row["lastname"];
$member_email=$row["email"];
$new=array();
$new['processor'] = 'hivepay';
$new['subscr_id'] = "none";
$new['date']=date("Y-m-d H:i:s");
$new['txn_id']=$txid;
$new['txn_type']='Hive Payment';
$new['item_name']=$item_name;
$new['item_number']=$itemid;
$new['name']=$member_name;
$new['email']=$member_email;
$new['amount']=$base_amount;
$new['fee']=$fee;
$new['user_id']=$user_id;
$new['payment_status']='OK';
$new['txn_type']='Hive Payment';
processOrder($new['txn_type'],$new);
http_response_code(200);
exit;
}
}
processError('Unable to process Transaction',$_POST);
http_response_code(300);
exit;
?>
E. Save and close the hivepay.php
file and continue to Part 2.
Part 2:
A. Navigate to the public_html/ipn
folder.
B. Find and open the code.php
file for editing.
C. Identify Line 13, it should start with either if(isset($firepay)) {
or if (isset($verify_sign)) {
D. If Line 13 does not look like the code above, find the code in your file and use that line.
E. Copy and Paste the code below at the beginning of the line you just identified:
if(isset($hivepay)) { include("ipn/hivepay.php"); } else
F. The line should look like one of these two examples now:
if(isset($hivepay)) { include("ipn/hivepay.php"); } elseif(isset($firepay)) {
if(isset($hivepay)) { include("ipn/hivepay.php"); } elseif(isset($verify_sign)) {
G. Save and Close the code.php
file and continue to Part 3.
Part 3:
A. Navigate to the public_html/inc
folder.
B. Find and open the sql_funcs.php
file for editing.
C. Identify Line 136, it should look like this: $merchant[$i]['subscribe']=$row['subscribe'];
D. If Line 136 does not look like the code above, find that code in your file and use that line.
E. At the end of the line you identified make a new line by hitting the Enter key on your keyboard.
F. You should be at the next line and it should be blank.
G. Paste the following code into the blank line that you just created:
$merchant[$i]['verify']=$row['verify'];
H. Identify Line 212, it should look like this: $buy=str_replace('[merchant_id]', $merchant[$f]['payee'], $buy);
I. If Line 212 does not look like the code above, find that code in your file and use that line.
J. At the end of the line you identified make a new line by hitting the Enter key on your keyboard.
K. You should be at the next line and it should be blank.
L. Paste the following code into the blank line that you just created:
$buy=str_replace('[verify]', $merchant[$f]['verify'], $buy);
M. Save and Close the sql_funcs.php
file and continue to Part 4.
Part 4:
A. Navigate to the public_html
folder.
B. Find and open the ipn.php
file for editing.
C. Identify Line 50, it should look like this: extract($_POST);
D. If Line 50 does not look like the code above, find that code in your file and use that line.
E. At the beginning of the line you identified make a new line by hitting the Enter key on your keyboard.
F. Navigate up one line and it should be blank.
G. Paste the following code into the blank line:
$input = file_get_contents('php://input');
if ($input) {
$data=json_decode($input, true);
$_POST["hivepay"]=1;
foreach($data as $k => $v) {
$_POST[$k]=$v;
}
}
H. Ensure extract($_POST)
is AFTER the code you just pasted in the file.
I. Save and Close the ipn.php
file and continue to Part 5.
Part 5:
A. Exit out of File Manager and cPanel and continue to Step 3.
Part 1:
A. Navigate and Login to the Admin section of your website (https://yoursite.com/admin/
).
B. Navigate to the Payment Settings Page (Settings->Payment Settings
).
C. You should see HivePay as one of the Merchants.
D. If you do not see HivePay as one of the Merchants, Go To Step 1 and follow ALL instructions.
E. For Merchant ID
fill in your Hive Username without the @ symbol (e.g. blainjones).
F. The Verify Code
will be the payments you would like to accept.
G. If you do not know what payments to accept use: CTP,HIVE,HBD,TOP10T
H. Delete what is in the Buy Now IPN
and Subscribe IPN
.
I. If you want to receive payment confirmation emails from HivePay, enter your email address below and click the button to update:
J. Ensuring you have clicked the button above if you want to receive payment confirmation emails from HivePay, copy and paste the code below into the Buy Now IPN
and Subscribe IPN
sections for HivePay:
<form action="https://hivepay.io/purchase/" method="post">
<input type="hidden" name="merchant" value="[merchant_id]">
<input type="hidden" name="item_name" value="[item_name]">
<input type="hidden" name="description" value="[sitename] Item [item_number]: [item_name]">
<input type="hidden" name="notify_url" value="[notify]">
<input type="hidden" name="return_url" value="[return]">
<input type="hidden" name="amount" value="[amount]">
<input type="hidden" name="base_currency" value="USD">
<input type="hidden" name="merchant_email" value="">
<input type="hidden" name="pay_currency" value="[verify]">
<input type="hidden" name="merchant_name" value="[sitename]">
<input type="hidden" name="cancel_url" value="[cancel]">
<input type="hidden" name="user_id" value="[user_id]">
<input type="hidden" name="itemid" value="[item_number]">
<input type="image" src="https://hivepay.io/buttons/23.png" style="width:200px;" alt="Pay With HivePay">
</form>
K. Looking at the form above, if you wish to replace the button image, change https://hivepay.io/buttons/23.png
to your new image.
L. Looking at the form above, the default size of the button is 200px
wide, to change this update width:200px;
to the width you want.
M. Once button adjustments are made, click the Save
button and continue to Part 2.
Part 2:
A. You should now be able to check HivePay in your Sales Packages to turn on HivePay.
B. Ensure you make a test purchase to verify everything is working properly before going live.
C. Once testing is complete and you have verified everything works properly you can go completely live with HivePay on your LFM site.
D. Congratulations! You have completed the HivePay Integration into the LFM Script.
E. Take a break and wipe away the tears!