DNotes Pay custom cart and checkout integration
Import the dnotes.sql file into your site/store database from shell or with phpMyAdmin
Upload the following files to your site/store directory:
button.php
dnotes_ajax.php
dnotes_cron.php
dnotes_payment.php
dnotespay.css
header.png
left.png
Integration is completely dependent on the specific site's setup, the following is a general guideline.
Open button.php
and update the configuration settings at the top.
- $amount and $order_num should be dynamic and get their values from your store for the current order.
- $confirmation_url should point to your Success or Thank You store page. Or to a store page for any further processing before showing the user the Success/ThankYou page.
Include button.php
into your checkout page's PHP code:
require_once("button.php");
Copy the coding - including the configuration values - and place in parts into your checkout page where needed. The button calls the Javascript function PaymentpageShow()
when clicked to submit the form, creating the new window for DNotes payment. You can add additional functionality here as needed:
- Submit a separate, main form to a hidden iFrame
- Perform actions via AJAX (such as validating checkout data, submitting and saving cart/order info, etc)
A cronjob is neccessary to check the blockchain against the payment transaction to update the status to completed once NOTE is sent and confirmed (to $confirm_num confirmations before valid).
- Edit
dnotes_cron.php
and update with your database connection information. - Add your own code where commented to update your site/store order once complete. The cron will set the
state
field equal tocomplete
only in the dnotes transactions table created above. You should then update your own table(s) when confirmed to mark an order complete. Ex:
if ($confirmed){ $result = $conn->query("update myOrderTable set status='1' where ordersId='" . $row['order_num'] . "'"); }
- Create a cronjob (from shell, or often from hosting's cPanel or similar domain management) to run
dnotes_cron.php
on a regular basis. Ex:
*/15 * * * * php /path/to/my/store/dnotes_cron.php
Note: If you need help finding path todnotes_cron.php
, edit the file and addprint __FILE__;
near the top. Open http://my.website/dnotes_cron.php to see full path the script (then remember to delete that line :) )