class WC_MobileMoney_Gateway extends WC_Payment_Gateway { public function __construct() { $this->id = 'mobilemoney'; $this->method_title = __('Mobile Money Payments', 'woocommerce-mobilemoney'); $this->method_description = __('Accept payments via MTN MoMo and Orange Money.', 'woocommerce-mobilemoney'); $this->has_fields = true; $this->init_form_fields(); $this->init_settings(); add_action('woocommerce_update_options_payment_gateways_' . $this->id, [$this, 'process_admin_options']); add_action('woocommerce_receipt_' . $this->id, [$this, 'receipt_page']); } public function init_form_fields() { $this->form_fields = [ 'enabled' => [ 'title' => __('Enable/Disable', 'woocommerce-mobilemoney'), 'type' => 'checkbox', 'label' => __('Enable Mobile Money Payments', 'woocommerce-mobilemoney'), 'default' => 'no', ], 'title' => [ 'title' => __('Title', 'woocommerce-mobilemoney'), 'type' => 'text', 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-mobilemoney'), 'default' => __('Mobile Money', 'woocommerce-mobilemoney'), 'desc_tip' => true, ], 'description' => [ 'title' => __('Description', 'woocommerce-mobilemoney'), 'type' => 'text', 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-mobilemoney'), 'default' => __('Pay with MTN MoMo or Orange Money', 'woocommerce-mobilemoney'), 'desc_tip' => true, ], 'mtm_enabled' => [ 'title' => __('MTN MoMo', 'woocommerce-mobilemoney'), 'type' => 'checkbox', 'label' => __('Enable MTN MoMo', 'woocommerce-mobilemoney'), 'default' => 'no', ], 'orange_enabled' => [ 'title' => __('Orange Money', 'woocommerce-mobilemoney'), 'type' => 'checkbox', 'label' => __('Enable Orange Money', 'woocommerce-mobilemoney'), 'default' => 'no', ], // MTN settings 'mtm_client_id' => [ 'title' => __('MTN Client ID', 'woocommerce-mobilemoney'), 'type' => 'text', 'description' => __('Your MTN MoMo Client ID from [MTN Developer Portal](https://developer.mtn.com/collection/docs/sandbox)', 'woocommerce-mobilemoney'), 'default' => '', 'desc_tip' => true, 'class' => 'mtm-settings', ], 'mtm_client_secret' => [ 'title' => __('MTN Client Secret', 'woocommerce-mobilemoney'), 'type' => 'password', 'description' => __('Your MTN MoMo Client Secret', 'woocommerce-mobilemoney'), 'default' => '', 'desc_tip' => true, 'class' => 'mtm-settings', ], 'mtm_subscription_key' => [ 'title' => __('MTN Subscription Key', 'woocommerce-mobilemoney'), 'type' => 'text', 'description' => __('Your MTN MoMo Subscription Key', 'woocommerce-mobilemoney'), 'default' => '', 'desc_tip' => true, 'class' => 'mtm-settings', ], 'mtm_environment' => [ 'title' => __('MTN Environment', 'woocommerce-mobilemoney'), 'type' => 'select', 'options' => [ 'sandbox' => __('Sandbox', 'woocommerce-mobilemoney'), 'production' => __('Production', 'woocommerce-mobilemoney'), ], 'default' => 'sandbox', 'class' => 'mtm-settings', ], 'mtm_country' => [ 'title' => __('MTN Country', 'woocommerce-mobilemoney'), 'type' => 'select', 'options' => [ 'cm' => __('Cameroon', 'woocommerce-mobilemoney'), 'ci' => __('Côte d\'Ivoire', 'woocommerce-mobilemoney'), 'sn' => __('Sénégal', 'woocommerce-mobilemoney'), ], 'default' => 'cm', 'class' => 'mtm-settings', ], 'mtm_merchant_id' => [ 'title' => __('MTN Merchant ID', 'woocommerce-mobilemoney'), 'type' => 'text', 'description' => __('Your MTN Merchant ID or Originator', 'woocommerce-mobilemoney'), 'default' => '', 'desc_tip' => true, 'class' => 'mtm-settings', ], // Orange settings 'orange_client_id' => [ 'title' => __('Orange Client ID', 'woocommerce-mobilemoney'), 'type' => 'text', 'description' => __('Your Orange Money Client ID from [Orange Developer Portal](https://developer.orange.com/api/webpay)', 'woocommerce-mobilemoney'), 'default' => '', 'desc_tip' => true, 'class' => 'orange-settings', ], 'orange_client_secret' => [ 'title' => __('Orange Client Secret', 'woocommerce-mobilemoney'), 'type' => 'password', 'description' => __('Your Orange Money Client Secret', 'woocommerce-mobilemoney'), 'default' => '', 'desc_tip' => true, 'class' => 'orange-settings', ], 'orange_environment' => [ 'title' => __('Orange Environment', 'woocommerce-mobilemoney'), 'type' => 'select', 'options' => [ 'sandbox' => __('Sandbox', 'woocommerce-mobilemoney'), 'production' => __('Production', 'woocommerce-mobilemoney'), ], 'default' => 'sandbox', 'class' => 'orange-settings', ], 'orange_country' => [ 'title' => __('Orange Country', 'woocommerce-mobilemoney'), 'type' => 'select', 'options' => [ 'cm' => __('Cameroon', 'woocommerce-mobilemoney'), 'ci' => __('Côte d\'Ivoire', 'woocommerce-mobilemoney'), 'sn' => __('Sénégal', 'woocommerce-mobilemoney'), ], 'default' => 'cm', 'class' => 'orange-settings', ], 'orange_merchant_id' => [ 'title' => __('Orange Merchant ID', 'woocommerce-mobilemoney'), 'type' => 'text', 'description' => __('Your Orange Merchant ID', 'woocommerce-mobilemoney'), 'default' => '', 'desc_tip' => true, 'class' => 'orange-settings', ], 'callback_url' => [ 'title' => __('Callback URL', 'woocommerce-mobilemoney'), 'type' => 'text', 'description' => __('This is the URL where callbacks will be sent. Ensure it is publicly accessible.', 'woocommerce-mobilemoney'), 'default' => home_url('/wc-api/woocommerce_mobilemoney'), 'desc_tip' => true, 'class' => 'orange-settings mtm-settings', ], ]; } public function process_admin_options() { parent::process_admin_options(); // Validate MTN credentials if enabled. if ('yes' === $this->get_option('mtm_enabled')) { $client_id = $this->get_option('mtm_client_id'); $client_secret = $this->get_option('mtm_client_secret'); $subscription_key = $this->get_option('mtm_subscription_key'); $environment = $this->get_option('mtm_environment'); $country = $this->get_option('mtm_country'); $api = new MTN_MoMo_API($client_id, $client_secret, $subscription_key, $environment, $country); $token = $api->get_token(); if (is_wp_error($token)) { wc_add_notice($token->get_error_message(), 'error'); $this->settings['mtm_enabled'] = 'no'; update_option('woocommerce_' . $this->id . '_settings', $this->settings); } } // Validate Orange credentials if enabled. if ('yes' === $this->get_option('orange_enabled')) { $client_id = $this->get_option('orange_client_id'); $client_secret = $this->get_option('orange_client_secret'); $environment = $this->get_option('orange_environment'); $country = $this->get_option('orange_country'); $api = new Orange_Money_API($client_id, $client_secret, $environment, $country); $token = $api->get_token(); if (is_wp_error($token)) { wc_add_notice($token->get_error_message(), 'error'); $this->settings['orange_enabled'] = 'no'; update_option('woocommerce_' . $this->id . '_settings', $this->settings); } } } public function payment_fields() { if ($this->get_option('enabled') !== 'yes') { return; } echo wpautop(wptexturize($this->description)); echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo '
'; if ('yes' === $this->get_option('mtm_enabled')) { echo ''; } if ('yes' === $this->get_option('orange_enabled')) { echo ''; } echo '
'; echo '
'; echo ''; wp_enqueue_script('mobilemoney-js', WC_MOBILEMONEY_PLUGIN_URL . 'assets/js/script.js', ['jquery'], WC_MOBILEMONEY_VERSION, true); wp_localize_script('mobilemoney-js', 'wc_mobilemoney_params', [ 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('initiate_mobilemoney_payment'), ]); } public function receipt_page($order_id) { $order = wc_get_order($order_id); echo '

' . __('Thank you for your order. Please check your phone to complete the payment.', 'woocommerce-mobilemoney') . '

'; } }class MTN_MoMo_API { private $client_id; private $client_secret; private $subscription_key; private $environment; private $country; public function __construct($client_id, $client_secret, $subscription_key, $environment, $country) { $this->client_id = $client_id; $this->client_secret = $client_secret; $this->subscription_key = $subscription_key; $this->environment = $environment; $this->country = $country; } public function get_token() { $token = get_option('mtm_token'); $expires = get_option('mtm_token_expires'); if ($token && $expires > time()) { return $token; } $url = $this->get_base_url() . '/collection/token'; $args = [ 'headers' => [ 'Ocp-Apim-Subscription-Key' => $this->subscription_key, 'Content-Type' => 'application/json', ], 'body' => json_encode([ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret ]) ]; $response = wp_remote_post($url, $args); if (is_wp_error($response)) { Logger::log('MTN Token Error: ' . $response->get_error_message(), 'error'); return new WP_Error('mtm_token_error', __('Failed to get token', 'woocommerce-mobilemoney') . ': ' . $response->get_error_message()); } $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); if (isset($data['access_token'])) { $expires_in = $data['expires_in']; $expires = time() + $expires_in; update_option('mtm_token', $data['access_token']); update_option('mtm_token_expires', $expires); return $data['access_token']; } Logger::log('MTN Token Response Error: ' . $body, 'error'); return new WP_Error('mtm_token_error', __('Invalid token response', 'woocommerce-mobilemoney')); } public function initiate_payment($order_id, $amount, $phone, $callback_url) { $token = $this->get_token(); if (is_wp_error($token)) { return $token; } $url = $this->get_base_url() . '/collection/v1_0/requesttopay'; $args = [ 'headers' => [ 'Authorization' => 'Bearer ' . $token, 'Ocp-Apim-Subscription-Key' => $this->subscription_key, 'Content-Type' => 'application/json', ], 'body' => json_encode([ 'amount' => $amount, 'currency' => 'XAF', 'externalId' => $order_id, 'payer' => [ 'partyIdType' => 'MSISDN', 'partyId' => $phone ], 'payerMessage' => "Paiement commande #$order_id", 'payeeNote' => "Paiement via MTN MoMo", 'callbackUrl' => $callback_url ]) ]; $response = wp_remote_post($url, $args); if (is_wp_error($response)) { Logger::log('MTN Payment Error: ' . $response->get_error_message(), 'error'); return new WP_Error('mtm_payment_error', __('Payment initiation failed', 'woocommerce-mobilemoney') . ': ' . $response->get_error_message()); } $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); $status_code = wp_remote_retrieve_response_code($response); if ($status_code === 202) { Logger::log("MTN RequestToPay initiated for order #$order_id | Amount: $amount XAF | Payer: $phone | Status: PENDING"); return $data; } Logger::log("MTN Payment Error: $body", 'error'); return new WP_Error('mtm_payment_error', __('Payment initiation failed', 'woocommerce-mobilemoney') . ': ' . $body); } private function get_base_url() { if ($this->environment === 'sandbox') { return 'https://sandbox.momodeveloper.mtn.com/collection'; } return 'https://api.mtn.com/collection'; } }class Orange_Money_API { private $client_id; private $client_secret; private $environment; private $country; public function __construct($client_id, $client_secret, $environment, $country) { $this->client_id = $client_id; $this->client_secret = $client_secret; $this->environment = $environment; $this->country = $country; } public function get_token() { $token = get_option('orange_token'); $expires = get_option('orange_token_expires'); if ($token && $expires > time()) { return $token; } $url = $this->get_base_url() . '/oauth2/token'; $auth = base64_encode($this->client_id . ':' . $this->client_secret); $args = [ 'headers' => [ 'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => 'Basic ' . $auth, ], 'body' => 'grant_type=client_credentials', ]; $response = wp_remote_post($url, $args); if (is_wp_error($response)) { Logger::log('Orange Token Error: ' . $response->get_error_message(), 'error'); return new WP_Error('orange_token_error', __('Failed to get token', 'woocommerce-mobilemoney') . ': ' . $response->get_error_message()); } $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); if (isset($data['access_token'])) { $expires_in = $data['expires_in']; $expires = time() + $expires_in; update_option('orange_token', $data['access_token']); update_option('orange_token_expires', $expires); return $data['access_token']; } Logger::log('Orange Token Response Error: ' . $body, 'error'); return new WP_Error('orange_token_error', __('Invalid token response', 'woocommerce-mobilemoney')); } public function initiate_payment($order_id, $amount, $phone, $callback_url) { $token = $this->get_token(); if (is_wp_error($token)) { return $token; } $url = $this->get_base_url() . '/payment/webpay/v1/requests'; $args = [ 'headers' => [ 'Authorization' => 'Bearer ' . $token, 'Content-Type' => 'application/json', ], 'body' => json_encode([ 'amount' => $amount, 'currency' => 'XAF', 'externalId' => $order_id, 'phoneNumber' => $phone, 'callbackUrl' => $callback_url, 'country' => $this->country ]) ]; $response = wp_remote_post($url, $args); if (is_wp_error($response)) { Logger::log('Orange Payment Error: ' . $response->get_error_message(), 'error'); return new WP_Error('orange_payment_error', __('Payment initiation failed', 'woocommerce-mobilemoney') . ': ' . $response->get_error_message()); } $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); $status_code = wp_remote_retrieve_response_code($response); if ($status_code === 201) { Logger::log("Orange WebPay initiated for order #$order_id | Amount: $amount XAF | Payer: $phone | Status: PENDING"); return $data; } Logger::log("Orange Payment Error: $body", 'error'); return new WP_Error('orange_payment_error', __('Payment initiation failed', 'woocommerce-mobilemoney') . ': ' . $body); } private function get_base_url() { if ($this->environment === 'sandbox') { return 'https://sandbox.api.orange.com/webpay'; } return 'https://api.orange.com/webpay'; } }class Logger { public static function log($message, $level = 'info') { $message = self::mask_sensitive_data($message); $log_file = 'mobilemoney-' . date('Y-m-d') . '.log'; $log_path = WC_LOG_DIR . '/' . $log_file; $log_message = '[' . current_time('mysql') . '] ' . strtoupper($level) . ': ' . $message . "\n"; error_log($log_message, 3, $log_path); } private static function mask_sensitive_data($message) { // Mask phone numbers: e.g., +237612345678 -> +2376XXXXXXX $message = preg_replace('/(\+\d{3}6)(\d{7})/', '$1XXXXXXX', $message); // Mask tokens: any string that looks like a token (alphanumeric, 10+ chars) $message = preg_replace('/(token|access_token|secret|subscription_key|client_id|client_secret|password|key)[\s:]*([a-zA-Z0-9\-_\.]{10,})/i', '$1: ****-****-****-****', $message); // Mask secrets: replace client_secret or subscription_key with REDACTED $message = preg_replace('/(client_secret|subscription_key)[\s:]*[a-zA-Z0-9\-_\.]{16,}/i', '$1: ***REDACTED***', $message); return $message; } }class Webhook_Handler { public function handle() { $raw_data = file_get_contents('php://input'); $payload = json_decode($raw_data, true); if (empty($payload)) { Logger::log('Empty payload received', 'error'); wp_die('Invalid payload', 400); } // Determine provider based on payload. $provider = null; if (isset($payload['transactionId'])) { $provider = 'mtm'; } elseif (isset($payload['reference'])) { $provider = 'orange'; } else { Logger::log('Unknown provider in payload', 'error'); wp_die('Unknown provider', 400); } // For MTN, check X-Reference-Id header. $x_ref_id = isset($_SERVER['HTTP_X_REFERENCE_ID']) ? sanitize_text_field($_SERVER['HTTP_X_REFERENCE_ID']) : ''; if ($provider === 'mtm' && empty($x_ref_id)) { Logger::log('Missing X-Reference-Id header for MTN', 'error'); wp_die('Invalid request', 400); } $order_id = null; if ($provider === 'mtm') { $order_id = $payload['externalId']; } elseif ($provider === 'orange') { $order_id = $payload['externalId']; } if (!$order_id) { Logger::log('Order ID not found in payload', 'error'); wp_die('Order ID missing', 400); } $order = wc_get_order($order_id); if (!$order) { Logger::log('Order not found for ID ' . $order_id, 'error'); wp_die('Order not found', 404); } $status = $payload['status']; if ($status === 'SUCCESS') { $order->update_status('completed', 'Payment completed via Mobile Money'); } elseif ($status === 'FAILED') { $order->update_status('failed', 'Payment failed via Mobile Money'); } else { $order->update_status('on-hold', 'Payment pending'); } $log_message = "{$provider} Webhook received | Ref: {$payload['reference'] ?? ''} | Status: {$status} | TransactionID: {$payload['transactionId'] ?? ''}"; Logger::log($log_message, 'success'); wp_die('OK', 200); } } Delliss – 1er site d'annonces Erotiques 100% vidéos pour Escorts et Masseuses de luxe.

Main Demo

Maxou – sexy girl

0%   0

Zombie Massacre

02:46 HD 4K

Aucune image disponible
0%   0

Zombie Massacre

  #37 02:46 HD 4K

Aucune image disponible
0%   0

Day of the Warrior

01:42 HD 4K

Aucune image disponible
0%   0

Day of the Warrior

  #22 01:42 HD 4K

Aucune image disponible
0%   0

Killer Mechanic

  #47 01:46

Aucune image disponible
0%   0

Killer Mechanic

01:46

Aucune image disponible
0%   0

Snipers Bulletproof

03:39

Aucune image disponible
0%   0
All Movies

New Movies

  Live
0%   0

Ashley

All Audios

New Audios

All Videos

Premium Videos

  Live
0%   0

Ashley

Powered By MemberPress WooCommerce Plus Integration
For Streamers

Live Streaming


You need to login to create a stream.You don't have permission to live stream.
Supports: *.png, *.jpg, *.gif, *.jpeg. Maximum upload file size: 3mb
Add your stream to a category so viewers can find it more easily.