} // Current selected coin by user $coinName = cryptobox_selcoin($available_payments, $def_payment); // Current Coin public/private keys $public_key = $all_keys[$coinName]["public_key"]; $private_key = $all_keys[$coinName]["private_key"]; /** PAYMENT BOX **/ $options = array("public_key" => $public_key, "private_key" => $private_key, "webdev_key" => "", "orderID" => $orderID, "userID" => $userID, "userFormat" => $userFormat, "amount" => 0, "amountUSD" => $amountUSD, "period" => $period, "language" => $def_language); // Initialise Payment Class $box = new Cryptobox($options); // coin name $coinName = $box->coin_name(); // Successful Cryptocoin Payment received // Please use also IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") for update db records, etc if ($box->is_paid()) { if (!$box->is_confirmed()) { $message = "Thank you for payment (payment #" . $box->payment_id() . "). Awaiting transaction/payment confirmation"; } else { // payment confirmed (6+ confirmations) // one time action if (!$box->is_processed()) { // One time action after payment has been made/confirmed $message = "Thank you for order (order #" . $orderID . ", payment #" . $box->payment_id() . "). We will send soon"; // Set Payment Status to Processed $box->set_status_processed(); } else { $message = "Thank you. Your order is in process"; } // General message } } else {
private function check_payment_confirmation($paymentID) { global $wpdb; $res = $wpdb->get_row("SELECT * from crypto_payments WHERE paymentID = " . intval($paymentID), OBJECT); if (!$res) { return false; } if ($res->txConfirmed) { return true; } $public_key = $this->options[$this->coin_names[$res->coinLabel] . 'public_key']; $private_key = $this->options[$this->coin_names[$res->coinLabel] . 'private_key']; if (!$public_key || !$private_key) { return false; } if (!defined("CRYPTOBOX_PRIVATE_KEYS")) { define("CRYPTOBOX_PRIVATE_KEYS", $private_key); } $options = array("public_key" => $public_key, "private_key" => $private_key, "orderID" => $res->orderID, "userID" => $res->userID, "amount" => $res->amount, "period" => "NO EXPIRY"); include_once plugin_dir_path(__FILE__) . "includes/cryptobox.class.php"; $box = new Cryptobox($options); $box->is_paid(); return $box->is_confirmed(); }