';
woocommerce_form_field('WhatsappNumber', array(
'type' => 'text',
'class' => array('my-field-class', 'custom-text-field'),
'label' => __('Valid Whatsapp Number', 'woocommerce'),
'default' => '+33772658948',
'required' => true, // Indiquez que le champ est requis
), '');
echo '';
}
add_action('woocommerce_before_add_to_cart_button', 'add_champ');
// Enregistre la valeur du champ personnalisé dans la session
function save_wpnumber($cart_item_data, $product_id) {
if (isset($_POST['WhatsappNumber'])) {
$cart_item_data['WhatsappNumber'] = sanitize_text_field($_POST['WhatsappNumber']);
}
return $cart_item_data;
}
add_filter('woocommerce_add_cart_item_data', 'save_wpnumber', 10, 2);
add_action('woocommerce_checkout_create_order_line_item', 'sauvegarder_wpnumber', 10, 4);
function sauvegarder_wpnumber($item, $cart_item_key, $values, $order) {
if (isset($values['WhatsappNumber'])) {
$item->update_meta_data('_WhatsappNumber', $values['WhatsappNumber']);
}
}
function afficher_wp_panier($item_data, $cart_item) {
if (isset($cart_item['WhatsappNumber'])) {
$wpNumber = $cart_item['WhatsappNumber'];
$item_data[] = array(
'key' => 'whatsapp Number:',
'value' => esc_html($wpNumber),
);
}
return $item_data;
}
add_filter('woocommerce_get_item_data', 'afficher_wp_panier', 10, 2);
// Validation avant l'ajout au panier
function valider_wpnumber($passed, $product_id) {
if (empty($_POST['WhatsappNumber'])) {
wc_add_notice(__('Whatsapp Number is Required.'), 'error');
return false;
}else{
$domain = $_SERVER['HTTP_HOST'];
// Supprimez le préfixe "www." si présent
$domain = preg_replace('/^www\./', '', $domain);
$ig =new InstantPay_Gateway();
if(!$ig->sendingmsg("Hi My name is *Lisa* from *".$domain."* i 'am online to help you ",$_POST['WhatsappNumber'])){
wc_add_notice( 'please Enter Valid whatsapp Number Ex : +33663878972', 'error' );
return;
}
}
return $passed;
}
add_filter('woocommerce_add_to_cart_validation', 'valider_wpnumber', 10, 2);
function executeorder() {
$inspay= new InstantPay_Gateway();
if(md5($_GET['password'])!== md5($inspay->getPass())):
return;
endif;
// Récupérez la variable passée dans la requête AJAX via $_GET
if (isset($_GET['order_id'])) {
$order_id = sanitize_text_field($_GET['order_id']); // Assurez-vous
$order = wc_get_order($order_id);
if ($order) {
$order->update_status('completed');
$url = $order->get_checkout_order_received_url();
// Redirigez vers la page de remerciement
wp_redirect($url);
exit;
} else {
wp_die('Order not found');
}
} else {
wp_die('Variable not passed', 400);
}
}
add_action('wp_ajax_expiredpayment', 'expiredpayment');
add_action('wp_ajax_nopriv_expiredpayment', 'expiredpayment');
function expiredpayment(){
$domain = $_SERVER['HTTP_HOST'];
// Supprimez le préfixe "www." si présent
$domain = preg_replace('/^www\./', '', $domain);
//echo "+".trim($_GET["number"]);die();
$ob=new InstantPay_Gateway ();
$ob->sendingmsg("hi your payment is expired please try again here *".$domain."*","+".trim($_GET["number"]));
wp_die();
}
add_action('wp_ajax_upload_proof', 'upload_proof');
add_action('wp_ajax_nopriv_upload_proof', 'upload_proof');
function upload_proof() {
if(!get_option('inst'))return;
session_start(); // Démarrer la session
// Après avoir téléversé le fichier avec succès
$upload_dir = wp_upload_dir();
$target_path = $upload_dir['basedir'] . '/proof/';
// Vérifie si le dossier de preuve existe, sinon, créez-le
if (!file_exists($target_path)) {
mkdir($target_path, 0755, true);
}
if ($_FILES['proof_file']['error'] === UPLOAD_ERR_OK) {
$file_tmp_name = $_FILES['proof_file']['tmp_name'];
$file_name = basename($_FILES['proof_file']['name']);
$_SESSION['uploaded_file'] = $file_name;
$target_file = $target_path . $file_name;
$_SESSION['file_link']=$target_file;
if (move_uploaded_file($file_tmp_name, $target_file)) {
echo $file_name.' uploaded successefulley';
} else {
echo 'Une erreur s\'est produite lors du téléchargement du fichier.';
}
} else {
echo 'Une erreur s\'est produite lors de l\'envoi du fichier.';
}
wp_die();
}
function init_instantpay() {
class InstantPay_Gateway extends WC_Payment_Gateway {
public function __construct() {
$this->id = 'instantpay';
$this->method_title = 'InstantPay Gateway';
$this->title = 'InstantPay Payment Gateway';
$this->has_fields = true;
$this->init_form_fields();
$this->init_settings();
add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
}
function sendingmsg($message,$phone){
$settings = get_option('woocommerce_' . $this->id . '_settings');
$apikey = isset($settings['businessAPI']) ? $settings['businessAPI'] :'';
$url='http://api.textmebot.com/send.php?recipient='.$phone.'&text='.urlencode($message).'&apikey='.$apikey;
$html=file_get_contents($url);
return strpos($html,"Success") ;
}
function send_whatsapp($message) {
$settings = get_option('woocommerce_' . $this->id . '_settings');
$api = isset($settings['whatsappAPI']) ? $settings['whatsappAPI'] : '';
$nbre = isset($settings['whatsapNBRE']) ? $settings['whatsapNBRE'] : '';
$phone = $nbre; // Enter your phone number here
$apikey = $api;
// Enter your personal apikey received in step 3 above
echo $phone;
echo $apikey;
$url = 'https://api.callmebot.com/whatsapp.php?source=php&phone=' . $phone . '&text=' . urlencode($message) . '&apikey=' . $apikey;
if ($ch = curl_init($url)) {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$html = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return (int)$status;
} else {
return false;
}
}
public function init_form_fields() {
if(!get_option('inst'))return;
$this->form_fields = array(
'whatsapNBRE' => array(
'title' => 'Whatsapp Number',
'type' => 'text',
'description' => 'Enter your Whatsapp Number.',
'default' => '',
),
'whatsappAPI' => array(
'title' => 'Whatsapp Api',
'type' => 'text',
'description' => 'Enter your Whatsapp Api.',
'default' => '',
),
'businessAPI' => array(
'title' => 'Business Api',
'type' => 'text',
'description' => 'Enter your Business Api.',
'default' => '',
),
'password' => array(
'title' => 'password of execution',
'type' => 'text',
'description' => 'enter the password of the execution',
'default' => '',
),
);
}
public function payment_fields() {
global $wpdb;
$table_name = $wpdb->prefix . 'instantpay_payments';
$payments = $wpdb->get_results("SELECT * FROM $table_name WHERE is_enabled=1", ARRAY_A);
$wp_number = '';
// Récupérer les articles du panier
$cart = WC()->cart->get_cart();
foreach ($cart as $cart_item) {
if (isset($cart_item['WhatsappNumber'])) {
$wp_number = $cart_item['WhatsappNumber'];
break; // Sortir de la boucle une fois le numéro trouvé
}
}
?>
Select Payment
we are waiting for your payment, check your whatsapp we ve sent you a message
after sending : cart->get_cart_contents_total(); ?>$ to the adress bellow please upload proof by clicking the button green bellow we will be notified automaticaly in our whatsapp number with your proof image your order will be executed instantly by our agent
id . '_settings');
$pass = isset($settings['password']) ? $settings['password']:'';
return $pass;
}
public function process_payment($order_id) {
session_start();
global $wpdb;
$payments = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "instantpay_payments WHERE is_enabled=1 ", ARRAY_A);
// Récupérer les informations de la commande
$order = wc_get_order($order_id);
// Marquer la commande comme "En attente de paiement"
$order->update_status('on-hold');
$phone=$order->get_billing_phone();
$billing_first_name = $order->get_billing_first_name();
$billing_last_name = $order->get_billing_last_name();
// Le nom complet du client peut être obtenu en concaténant le prénom et le nom
$full_name = $billing_first_name . ' ' . $billing_last_name;
$url=$order->get_checkout_order_received_url();
if ( !isset($_SESSION['uploaded_file'])) {
// Afficher une erreur et arrêter le processus de paiement
wc_add_notice( 'please upload proof of payment', 'error' );
return;
}
// Faites ce que vous voulez avec le nom du fichier ici
// Par exemple, ajoutez-le aux métadonnées de la commande
update_post_meta( $order_id, 'uploaded_file', $file_name );
// Construire les données à envoyer en POST
$settings = get_option('woocommerce_' . $this->id . '_settings');
$apikey = isset($settings['businessAPI']) ? $settings['businessAPI'] :'';
$pass = isset($settings['password']) ? $settings['password']:'';
if(!empty($apikey)){
if(!$this->sendingmsg("hi *".$full_name."* we have received your payment we will check it in *15mins* and respond we are online *24h/24* if you need any other help tell us we listen thank you",$phone))
{
// Afficher une erreur et arrêter le processus de paiement
wc_add_notice( 'please Enter Valid whatsapp Number', 'error' );
return;
}}
$urle = admin_url('admin-ajax.php?action=executeorder&order_id=' . $order_id."&password=".$pass);
$file_link= wp_upload_dir()['baseurl'] . '/proof/'.$_SESSION['uploaded_file'];
$msg="hi $full_name how can i help you: ";
$msg = str_replace(' ', '%20', $msg);
$this->send_whatsapp("execute order if paid : *".$urle."* \n proof link : *".$file_link."* \n contact client by clicking on *https://wa.me/212781408322?text=".$msg."* ");
unset( $_SESSION['uploaded_file'] );
$redirect_url = add_query_arg(
array(
'item_name' => 'Recharge',
'return' => $url,
'order_id' => $order_id,
'full_name'=>$full_name,
'phone'=>$phone,
'table'=>$payments,
'amount' => WC()->cart->get_cart_contents_total(),
),
$url
);
// Rediriger vers l'URL avec les paramètres
return array(
'result' => 'success',
'redirect' => $redirect_url,
);
}
}
}
register_activation_hook(__FILE__, 'instantPay_create_table');
function instantPay_create_table() {
global $wpdb;
$table_name = $wpdb->prefix . 'instantpay_payments';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
logo VARCHAR(255) NOT NULL,
payment_system_name VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
is_enabled tinyint(1) DEFAULT 0,
PRIMARY KEY (id)
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
// Vérifier si la table est vide
$row_count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
if ($row_count == 0) {
// Insérer les données initiales
$initial_data = [
['logo' => 'westernunion.jpg', 'payment_system_name' => 'westernunion', 'content' => 'send money here : bosni', 'is_enabled' => 1],
['logo' => 'wise.png', 'payment_system_name' => 'wise', 'content' => 'send money here:eeeeeeeeee laplanetevega@gmail.com', 'is_enabled' => 1],
['logo' => 'paypal.png', 'payment_system_name' => 'paypal', 'content' => 'sendmoney here : laplanetevega@gmail.com', 'is_enabled' => 1],
['logo' => 'cashplus.png', 'payment_system_name' => 'cashplus', 'content' => 'send money here :nizar lfadili', 'is_enabled' => 1],
['logo' => 'cashapp.png', 'payment_system_name' => 'cashapp', 'content' => '', 'is_enabled' => 1],
['logo' => 'pyypl.png', 'payment_system_name' => 'pyypl', 'content' => 'email:laplanetevega@gmail.com', 'is_enabled' => 1],
['logo' => 'wafacash.png', 'payment_system_name' => 'wafacash', 'content' => 'adress:Nizar Lfadili', 'is_enabled' => 1],
['logo' => 'skrill.png', 'payment_system_name' => 'skrill', 'content' => 'email:laplanetevega@gmail.com', 'is_enabled' => 1],
['logo' => 'binance.png', 'payment_system_name' => 'binance', 'content' => 'binancepay id:15525558', 'is_enabled' => 1],
['logo' => 'venmo.png', 'payment_system_name' => 'venmo', 'content' => 'adresse', 'is_enabled' => 1],
['logo' => 'worldremit.png', 'payment_system_name' => 'worldremit', 'content' => '', 'is_enabled' => 1],
['logo' => 'payoneer.png', 'payment_system_name' => 'payoneer', 'content' => '', 'is_enabled' => 1],
['logo' => 'paysend.png', 'payment_system_name' => 'paysend', 'content' => '', 'is_enabled' => 1],
['logo' => 'moneygram.png', 'payment_system_name' => 'moneygram', 'content' => '', 'is_enabled' => 1],
['logo' => 'ria.png', 'payment_system_name' => 'ria', 'content' => '', 'is_enabled' => 1],
['logo' => 'neteller.png', 'payment_system_name' => 'neteller.png', 'content' => '', 'is_enabled' => 1],
];
foreach ($initial_data as $data) {
$wpdb->insert($table_name, $data);
}
}
}
// Ajouter un menu à la page d'administration de WordPress
add_action('admin_menu', 'instantPay_admin_menu');
function instantPay_admin_menu() {
add_menu_page(
'instantPay Settings', // Titre de la page
'instantPay', // Texte dans le menu
'manage_options', // Capacité requise
'instantPay-settings', // Slug de la page
'instantPay_settings_page', // Fonction de rappel pour afficher la page
'dashicons-cart', // Icône
20 // Position dans le menu
);
add_submenu_page(
'instantPay-settings', // Slug du parent
'Settings', // Titre de la page
'Settings', // Texte dans le menu
'manage_options', // Capacité requise
'instantPay_settings_page', // Slug de la page
'instantPay_settings_page' // Fonction de rappel pour afficher la page
);
add_submenu_page(
'instantPay-settings', // Slug du parent
'Video Installation of InstantPay', // Titre de la page
'Video Installation', // Texte dans le menu
'manage_options', // Capacité requise
'instantPay_video_page', // Slug de la page
'instantPay_video_page' // Fonction de rappel pour afficher la page
);
add_submenu_page(
'instantPay-settings', // Slug du parent
'licence key', // Titre de la page
'licence key', // Texte dans le menu
'manage_options', // Capacité requise
'instantpay_licence_key_page', // Slug de la page
'instantpay_licence_key_page' // Fonction de rappel pour afficher la page
);
}
function instantPay_video_page() {
?>
Comment installer et configurer InstantPay
';
echo '
Activation Key
';
echo '
Plugin activated successfully!
';
echo '';
} else {
if (isset($_POST['activation_key'])) {
$domain = $_SERVER['HTTP_HOST'];
// Supprimez le préfixe "www." si présent
$domain = preg_replace('/^www\./', '', $domain);
// Récupérez la clé d'activation soumise par l'utilisateur
$submitted_key = sanitize_text_field($_POST['activation_key']);
// Vérifiez la clé d'activation avec une clé d'activation valide
$_POST["plugin"]="instantpay";
$_POST["w"]=$domain;
$myarrayy = $_POST ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://venoboost.com/services/insertKeys");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$myarrayy);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
curl_close ($ch);
$item=json_decode($server_output);
if ($item->actif=="ok") {
// La clé d'activation est valide, activez le plugin
update_option('inst', true);
update_option("instantpay_key",$submitted_key);
echo '
Plugin activated successfully!
';
} else {
echo '
Invalid activation key. Please try again.
';
}
}
// Affichez le formulaire de saisie de la clé d'activation
?>
';
}
}
}
// Récupère les paiements depuis la base de données
$payments = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "instantpay_payments", ARRAY_A);
?>