Changeset 3241843
- Timestamp:
- 02/17/2025 11:32:19 AM (14 months ago)
- Location:
- camoo-pay-for-ecommerce/trunk
- Files:
-
- 8 edited
-
camoo-pay-for-ecommerce.php (modified) (2 diffs)
-
changelog.txt (modified) (1 diff)
-
includes/Gateway.php (modified) (5 diffs)
-
includes/Plugin.php (modified) (2 diffs)
-
includes/admin/Enum/MetaKeysEnum.php (modified) (1 diff)
-
includes/admin/PluginAdmin.php (modified) (2 diffs)
-
includes/languages/camoo-pay-for-ecommerce-fr_FR.mo (modified) (previous)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
camoo-pay-for-ecommerce/trunk/camoo-pay-for-ecommerce.php
r3240808 r3241843 6 6 * Plugin URI: https://github.com/camoo/camoo-woocommerce-gateway 7 7 * Description: Receive Mobile Money payments on your store using CamooPay for WooCommerce. 8 * Version: 1.0. 48 * Version: 1.0.5 9 9 * Tested up to: 6.7.2 10 10 * Author: Camoo Sarl … … 19 19 * 20 20 * WC requires at least: 8.0 21 * WC tested up to: 9.6. 121 * WC tested up to: 9.6.2 22 22 * 23 23 * 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 1 1 *** WooCommerce CamooPay Changelog *** 2 3 2025-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 2 7 3 8 2025-02-14 - version 1.0.4 -
camoo-pay-for-ecommerce/trunk/includes/Gateway.php
r3238396 r3241843 286 286 $wcOrder->update_meta_data(MetaKeysEnum::PAYMENT_MERCHANT_TRANSACTION_ID->value, sanitize_text_field($merchantReferenceId)); 287 287 $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 ); 288 292 289 293 // Add the notice if the payment is successful … … 451 455 452 456 /** 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, 454 458 * but only adjust amounts that are not already divisible by 5. 455 459 * … … 462 466 // Check if the amount is divisible by 5 463 467 if ($amount % 5 !== 0) { 464 // Round the amount to the nearest multiple of 25465 return round($amount / 25) * 25;468 // Round the amount to the nearest multiple of 5 469 return round($amount / 5) * 5; 466 470 } 467 471 … … 470 474 } 471 475 472 private function cleanUpPhone(string $rawData): string473 {474 /** @var string $phone */475 $phone = wc_clean(wp_unslash($rawData));476 477 return preg_replace('/\D/', '', $phone);478 }479 480 476 /** @return array<string, mixed> */ 481 477 private function prepareOrderData(WC_Order $wcOrder, string $merchantReferenceId): array … … 483 479 $order_data = $wcOrder->get_data(); 484 480 $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']); 486 482 $orderData = [ 487 483 'external_reference' => $merchantReferenceId, -
camoo-pay-for-ecommerce/trunk/includes/Plugin.php
r3240808 r3241843 26 26 class Plugin 27 27 { 28 public const WC_CAMOO_PAY_DB_VERSION = '1.0. 4';28 public const WC_CAMOO_PAY_DB_VERSION = '1.0.5'; 29 29 30 30 public const DEFAULT_TITLE = 'CamooPay'; 31 31 32 32 public const WC_CAMOO_PAY_GATEWAY_ID = 'wc_camoo_pay'; 33 34 private const DEFAULT_COUNTRY_CODE = '237'; 33 35 34 36 private const DOMAIN_TEXT = 'camoo-pay-for-ecommerce'; … … 322 324 } 323 325 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 324 344 /** @param bool|WC_Order|WC_Order_Refund $order */ 325 345 private static function processWebhookConfirmed($order, string $merchantReferenceId, ?Payment $payment = null): void -
camoo-pay-for-ecommerce/trunk/includes/admin/Enum/MetaKeysEnum.php
r3237199 r3241843 13 13 case PAYMENT_MERCHANT_TRANSACTION_ID = '_camoo_pay_merchant_transaction_id'; 14 14 case PAYMENT_BUYER_IP = '_camoo_pay_buyer_ip'; 15 case BUYER_MOBILE_MONEY_NUMBER = '_camoo_pay_buyer_phone'; 15 16 } -
camoo-pay-for-ecommerce/trunk/includes/admin/PluginAdmin.php
r3238396 r3241843 81 81 echo '<p class="form-field form-field-wide"> 82 82 <label for="wc_camoo_pay_fee"> 83 <strong for="wc_camoo_pay_fee">' .83 <strong>' . 84 84 esc_attr__('CamooPay Fee', 'camoo-pay-for-ecommerce') . ': 85 85 </strong> ' . … … 88 88 89 89 } 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 90 103 } 91 104 -
camoo-pay-for-ecommerce/trunk/readme.txt
r3240808 r3241843 4 4 Requires Plugins: woocommerce 5 5 Tested up to: 6.7.2 6 Stable tag: 1.0. 46 Stable tag: 1.0.5 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 89 89 == Changelog == 90 90 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 91 96 = 1.0.4: February 14, 2025 = 92 97 * Fixed - avoid overwriting mobile money number icon CSS styles
Note: See TracChangeset
for help on using the changeset viewer.