Plugin Directory

Changeset 3241843


Ignore:
Timestamp:
02/17/2025 11:32:19 AM (14 months ago)
Author:
camoo
Message:

Display buyer mobile Phone number added

Location:
camoo-pay-for-ecommerce/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • camoo-pay-for-ecommerce/trunk/camoo-pay-for-ecommerce.php

    r3240808 r3241843  
    66 * Plugin URI: https://github.com/camoo/camoo-woocommerce-gateway
    77 * Description: Receive Mobile Money payments on your store using CamooPay for WooCommerce.
    8  * Version: 1.0.4
     8 * Version: 1.0.5
    99 * Tested up to: 6.7.2
    1010 * Author: Camoo Sarl
     
    1919 *
    2020 * WC requires at least: 8.0
    21  * WC tested up to: 9.6.1
     21 * WC tested up to: 9.6.2
    2222 *
    2323 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
  • camoo-pay-for-ecommerce/trunk/changelog.txt

    r3240808 r3241843  
    11*** WooCommerce CamooPay Changelog ***
     2
     32025-02-17 - version 1.0.5
     4* Tweak - Missing translations added
     5* Added - Display the mobile money number on the order received page
     6* Fixed - Ensure FCFA amount is adjusted correctly. It's a valid multiple of 5
    27
    382025-02-14 - version 1.0.4
  • camoo-pay-for-ecommerce/trunk/includes/Gateway.php

    r3238396 r3241843  
    286286            $wcOrder->update_meta_data(MetaKeysEnum::PAYMENT_MERCHANT_TRANSACTION_ID->value, sanitize_text_field($merchantReferenceId));
    287287            $wcOrder->update_meta_data(MetaKeysEnum::PAYMENT_ORDER_STATUS->value, sanitize_text_field($status->value));
     288            $wcOrder->update_meta_data(
     289                MetaKeysEnum::BUYER_MOBILE_MONEY_NUMBER->value,
     290                sanitize_text_field(Plugin::anonymizePhoneNumber($orderData['phone_number']))
     291            );
    288292
    289293            // Add the notice if the payment is successful
     
    451455
    452456    /**
    453      * Normalize the amount for XAF (FCFA BEAC) to ensure it's a valid multiple of 25,
     457     * Normalize the amount for XAF (FCFA BEAC) to ensure it's a valid multiple of 5,
    454458     * but only adjust amounts that are not already divisible by 5.
    455459     *
     
    462466        // Check if the amount is divisible by 5
    463467        if ($amount % 5 !== 0) {
    464             // Round the amount to the nearest multiple of 25
    465             return round($amount / 25) * 25;
     468            // Round the amount to the nearest multiple of 5
     469            return round($amount / 5) * 5;
    466470        }
    467471
     
    470474    }
    471475
    472     private function cleanUpPhone(string $rawData): string
    473     {
    474         /** @var string $phone */
    475         $phone = wc_clean(wp_unslash($rawData));
    476 
    477         return preg_replace('/\D/', '', $phone);
    478     }
    479 
    480476    /** @return array<string, mixed> */
    481477    private function prepareOrderData(WC_Order $wcOrder, string $merchantReferenceId): array
     
    483479        $order_data = $wcOrder->get_data();
    484480        $post_data = $this->get_post_data();
    485         $phoneNumber = $this->cleanUpPhone($post_data['camoo_pay_phone_number']);
     481        $phoneNumber = Plugin::cleanUpPhone($post_data['camoo_pay_phone_number']);
    486482        $orderData = [
    487483            'external_reference' => $merchantReferenceId,
  • camoo-pay-for-ecommerce/trunk/includes/Plugin.php

    r3240808 r3241843  
    2626    class Plugin
    2727    {
    28         public const WC_CAMOO_PAY_DB_VERSION = '1.0.4';
     28        public const WC_CAMOO_PAY_DB_VERSION = '1.0.5';
    2929
    3030        public const DEFAULT_TITLE = 'CamooPay';
    3131
    3232        public const WC_CAMOO_PAY_GATEWAY_ID = 'wc_camoo_pay';
     33
     34        private const DEFAULT_COUNTRY_CODE = '237';
    3335
    3436        private const DOMAIN_TEXT = 'camoo-pay-for-ecommerce';
     
    322324        }
    323325
     326        public static function cleanUpPhone(string $number): string
     327        {
     328            /** @var string $phone */
     329            $phone = wc_clean(wp_unslash($number));
     330
     331            return preg_replace('/\D/', '', $phone);
     332        }
     333
     334        public static function anonymizePhoneNumber(string $number, ?string $phoneCountryCode = null): string
     335        {
     336            $phoneCountryCode = $phoneCountryCode ?: self::DEFAULT_COUNTRY_CODE;
     337            $cleanedNumber = self::cleanUpPhone($number);
     338            $pattern = '/^(\+' . $phoneCountryCode . '|' . $phoneCountryCode . '|00' . $phoneCountryCode . ')?/';
     339            $number = preg_replace($pattern, '', $cleanedNumber);
     340
     341            return substr($number, 0, 1) . str_repeat('*', strlen($number) - 3) . substr($number, -2);
     342        }
     343
    324344        /** @param bool|WC_Order|WC_Order_Refund $order */
    325345        private static function processWebhookConfirmed($order, string $merchantReferenceId, ?Payment $payment = null): void
  • camoo-pay-for-ecommerce/trunk/includes/admin/Enum/MetaKeysEnum.php

    r3237199 r3241843  
    1313    case PAYMENT_MERCHANT_TRANSACTION_ID = '_camoo_pay_merchant_transaction_id';
    1414    case PAYMENT_BUYER_IP = '_camoo_pay_buyer_ip';
     15    case BUYER_MOBILE_MONEY_NUMBER = '_camoo_pay_buyer_phone';
    1516}
  • camoo-pay-for-ecommerce/trunk/includes/admin/PluginAdmin.php

    r3238396 r3241843  
    8181                echo '<p class="form-field form-field-wide">
    8282                    <label for="wc_camoo_pay_fee">
    83                         <strong for="wc_camoo_pay_fee">' .
     83                        <strong>' .
    8484                            esc_attr__('CamooPay Fee', 'camoo-pay-for-ecommerce') . ':
    8585                        </strong> ' .
     
    8888
    8989            }
     90
     91            $mobileMoneyNumber = $order->get_meta(MetaKeysEnum::BUYER_MOBILE_MONEY_NUMBER->value, true);
     92            if (null !== $mobileMoneyNumber) {
     93
     94                echo '<p class="form-field form-field-wide">
     95                    <label for="wc_camoo_pay_mobile_money_number">
     96                        <strong>' .
     97                    esc_attr__('Buyer Mobile money number', 'camoo-pay-for-ecommerce') . ':
     98                        </strong> ' .
     99                    esc_html($mobileMoneyNumber) .
     100                    '</label></p>';
     101            }
     102
    90103        }
    91104
  • camoo-pay-for-ecommerce/trunk/readme.txt

    r3240808 r3241843  
    44Requires Plugins: woocommerce
    55Tested up to: 6.7.2
    6 Stable tag: 1.0.4
     6Stable tag: 1.0.5
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8989== Changelog ==
    9090
     91= 1.0.5: February 17, 2025 =
     92* Tweak - Missing translations added
     93* Added - Display the mobile money number on the order received page
     94* Fixed - Ensure FCFA amount is adjusted correctly. It's a valid multiple of 5
     95
    9196= 1.0.4: February 14, 2025 =
    9297* Fixed - avoid overwriting mobile money number icon CSS styles
Note: See TracChangeset for help on using the changeset viewer.