Plugin Directory

Changeset 3113263


Ignore:
Timestamp:
07/05/2024 06:50:57 PM (20 months ago)
Author:
lipad
Message:

This update adds the functionality to dynamically check phone number operators.

Location:
lipad-checkout
Files:
14 added
3 edited

Legend:

Unmodified
Added
Removed
  • lipad-checkout/trunk/includes/LipadPaymentGatewayConstants.php

    r3112745 r3113263  
    9595        ],
    9696    ];
     97    const AIRTEL_REGEX = '/^(254)(([7]([38]{1}([0-9]{7})|(([5][0]|[5][1]|[5][2]|[5][3]|[5][4]|[5][5]|[5][6]|[6][0]|[6][2]){1})([0-9]{6}))|((100)|(101)|(102)|(103)|(104)|(105)|(106))([0-9]{6})))$/';
     98    const MPESA_REGEX = '/^(254)((([7])([0|1|2|9])([0-9]{7}))|(74)([0123456]{1})([0-9]{6})|(75)([789]{1})([0-9]{6})|(76)([89]{1})([0-9]{6})|((110)|(111)|(112)|(113)|(114)|(115))([0-9]{6}))$/';
    9799}
     100// Regular expressions
     101
  • lipad-checkout/trunk/lipad-payment-gateway.php

    r3112745 r3113263  
    77 * Plugin URI:  https://wordpress.org/plugins/lipad-checkout
    88 * Description: Collect payments from your customers with an express self-checkout interface.
    9  * Version:     1.0.4
     9 * Version:     1.0.5
    1010 * Author:      Lipad
    1111 * Author URI:  https://lipad.io
     
    5555        public $access_key;
    5656        public $secret_key;
    57         public $service_code;
    5857        public $payment_period;
    5958        public $client_code;
     
    9291            $this->access_key = $this->test_mode ? $this->get_option('test_access_key') : $this->get_option('access_key');
    9392            $this->checkout_url = $this->test_mode ? LipadWordPressConstants::CHECKOUT_REDIRECT_LINKS['uat'] : LipadWordPressConstants::CHECKOUT_REDIRECT_LINKS['live'];
    94             $this->service_code = $this->test_mode ? $this->get_option('test_service_code') : $this->get_option('service_code');
    9593            $this->payment_period = $this->test_mode ? $this->get_option('test_payment_period') : $this->get_option('payment_period');
     94//            $this->service_code = $this->test_mode ? $this->get_option('test_service_code') : $this->get_option('service_code');
    9695            $this->client_code = $this->test_mode ? $this->get_option('test_client_code') : $this->get_option('client_code');
    9796            $this->client_secret = $this->test_mode ? $this->get_option('test_client_secret') : $this->get_option('client_secret');
     
    162161                ),
    163162                'test_secret_key' => array(
    164                     'title' => 'Test Secret Key',
     163                    'title' => 'Test Airtel Money Secret Key',
    165164                    'type' => 'text'
    166165                ),
     
    258257            $order = wc_get_order($order_id);
    259258
     259            // Get the billing phone number
     260            $msisdn = preg_replace('/^(?:\+?0?(?:254)?)?/', '254', $order->get_billing_phone());
     261            if (preg_match(LipadWordPressConstants::AIRTEL_REGEX, $msisdn)) {
     262                $operator = 'airtelmoney';
     263                $service_code = $this->test_mode ? $this->get_option('test_service_code') : $this->get_option('service_code');
     264            } elseif (preg_match(LipadWordPressConstants::MPESA_REGEX, $msisdn)) {
     265                $operator = 'mpesa';
     266                $service_code = $this->test_mode ? $this->get_option('test_service_code') : $this->get_option('service_code');
     267            } else {
     268                wc_add_notice('The phone number is not valid for the supported operators!', 'error');
     269                return array(
     270                    'result' => 'failure'
     271                );
     272            }
    260273            // checkout transaction description
    261274            $order_excerpt = array_reduce($order->get_items(), function ($carry, $item) {
     
    273286            // array with parameters for API interaction
    274287            $payload = array(
    275                 "msisdn" => $order->get_billing_phone(),
    276                 "account_number"=> $order->get_billing_phone(),
     288                "msisdn" => $msisdn,
     289                "account_number"=> $msisdn,
    277290                "country_code" => !empty($country_code) ? $country_code : 'KEN',
    278291                "currency_code" => !empty($currency_code) ? $currency_code : 'KES',
     
    287300                "success_redirect_url" => $order->get_checkout_order_received_url(),
    288301                "fail_redirect_url" => get_permalink(get_page_by_path('shop')),
    289                 "service_code" => $this->service_code,
     302                "service_code" => $service_code,
    290303                "client_code" => $this->client_code,
    291304                "language_code" => 'en'
  • lipad-checkout/trunk/readme.txt

    r3112745 r3113263  
    55Tested up to: 6.5.5
    66Requires PHP: 5.2.4
    7 Stable tag: 1.0.4
     7Stable tag: 1.0.5
    88WC tested up to: 9.0.2
    99License: GPL2
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 Lipad Checkout simplifies the payment collection process for your WooCommerce store by seamlessly integrating with the Lipad payment gateway.
    13 With Lipad Checkout, you can provide your customers with a frictionless payment experience. Whether you're selling products or services, this plugin enables you to effortlessly receive payments via Lipad's own intuitive checkout interface.
     12Lipad Checkout integrates seamlessly with WooCommerce, offering a frictionless payment experience via Lipad's intuitive checkout interface.
    1413
    1514== Description ==
    1615
    17 Lipad Checkout is a plugin that integrates the Lipad payment gateway with WooCommerce, allowing you to collect payments from your customers through an express self-checkout interface. The plugin provides seamless integration between your WooCommerce store and the Lipad payment platform.
     16Lipad Checkout integrates the Lipad payment gateway with WooCommerce, enabling quick payments via an express self-checkout interface.
    1817
    1918== Installation ==
     
    4342== Changelog ==
    4443
     44= 1.0.5 =
     45
     46-**Fix**: Dynamically check the payer phone number for Airtel and Safaricom.
     47
    4548= 1.0.4 =
    4649
     
    6467
    6568= Upgrade Notice =
     69
     70= 1.0.5 =
     71
     72- This update adds the functionality to dynamically check phone number operators.
    6673
    6774= 1.0.4 =
Note: See TracChangeset for help on using the changeset viewer.