-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrey Kashukov
committed
Jan 8, 2025
1 parent
9896ee2
commit f1cdae2
Showing
33 changed files
with
521 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.5.49 | ||
1.5.51 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
wp-content/plugins/unlimit/assets/js/admin_settings/airtel_tz_settings_unlimit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
window.addEventListener('load', function () { | ||
setupPaymentForm('woocommerce_woo-unlimit-airteltz_woocommerce_unlimit_airteltz_'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const AIRTELTZ_PHONE = '#ul-airteltz-phone'; | ||
|
||
(function ($) { | ||
'use strict'; | ||
|
||
$(function () { | ||
$('form.checkout').on('checkout_place_order_woo-unlimit-airteltz', function () { | ||
return validatePhoneNumber( | ||
AIRTELTZ_PHONE, | ||
'#ul-airteltz-phone-error', | ||
'#ul-airteltz-phone-error-second', | ||
/^\+255\d{9}$/, | ||
13, | ||
13, | ||
); | ||
}); | ||
}); | ||
}(jQuery)); | ||
|
||
function validateUlAirteltzInput() { | ||
autoFillCountryCode(jQuery(AIRTELTZ_PHONE), '+255'); | ||
|
||
setTimeout(validatePhoneNumber( | ||
AIRTELTZ_PHONE, | ||
'#ul-airteltz-phone-error', | ||
'#ul-airteltz-phone-error-second', | ||
/^\+255\d{9}$/, | ||
13, | ||
13, | ||
), 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,27 @@ | ||
(function ($) { | ||
'use strict'; | ||
|
||
$(function () { | ||
$('form.checkout').on('checkout_place_order_woo-unlimit-mbway', function () { | ||
return validateUlMbwayPhone(); | ||
}); | ||
'use strict'; | ||
|
||
$(function () { | ||
jQuery('form.checkout').on('checkout_place_order_woo-unlimit-mbway', function () { | ||
return validatePhoneNumber( | ||
'#ul-mbway-phone', | ||
'#ul-mbway-phone-error', | ||
'#ul-mbway-phone-error-second', | ||
/^\+?351\d{9}$|^(?!.*[a-zA-Z])\d{9}$/, | ||
12, | ||
13, | ||
); | ||
}); | ||
}); | ||
}(jQuery)); | ||
|
||
function validateUlMbwayInput() { | ||
setTimeout(validateUlMbwayPhone(), 1); | ||
} | ||
|
||
const validateUlMbwayPhone = function () { | ||
var phoneField = jQuery('#ul-mbway-phone'); | ||
var phoneErrField = jQuery('#ul-mbway-phone-error'); | ||
var phoneErrFieldSecond = jQuery('#ul-mbway-phone-error-second'); | ||
|
||
phoneField.val(phoneField.val().replace(/[^+\d]/g, '')); | ||
|
||
var numbersOnly = phoneField.val().trim(); | ||
var phonePattern = /^\+?351\d{9}$|^(?!.*[a-zA-Z])\d{9}$/; | ||
|
||
if (numbersOnly === '') { | ||
phoneErrField.hide(); | ||
phoneErrFieldSecond.show(); | ||
phoneField.addClass(UL_ERROR_CLASS); | ||
return false; | ||
} | ||
|
||
if (!numbersOnly.match(phonePattern)) { | ||
phoneErrFieldSecond.hide(); | ||
phoneErrField.show(); | ||
phoneField.addClass(UL_ERROR_CLASS); | ||
return false; | ||
} | ||
|
||
phoneField.removeClass(UL_ERROR_CLASS); | ||
phoneErrField.hide(); | ||
phoneErrFieldSecond.hide(); | ||
return true; | ||
setTimeout(validatePhoneNumber( | ||
'#ul-mbway-phone', | ||
'#ul-mbway-phone-error', | ||
'#ul-mbway-phone-error-second', | ||
/^\+?351\d{9}$|^(?!.*[a-zA-Z])\d{9}$/, | ||
12, | ||
13, | ||
), 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
function autoFillCountryCode(phoneField, countryCode) { | ||
const value = phoneField.val().trim().replace(/\s+/g, ''); | ||
|
||
if (value === "+") { | ||
phoneField.val(countryCode); | ||
} else if (value.startsWith(countryCode)) { | ||
console.debug('Value starts with the correct country code'); | ||
} else if (value.startsWith(countryCode.slice(1))) { | ||
phoneField.val('+' + value); | ||
} else if (value.startsWith('+')) { | ||
phoneField.val(countryCode + value.slice(value.indexOf(countryCode.slice(1)))); | ||
} else { | ||
phoneField.val(countryCode + value); | ||
} | ||
} | ||
|
||
function validatePhoneNumber(phoneFieldSelector, phoneErrFieldSelector, phoneErrFieldSecondSelector, phonePattern, minLength, maxLength) { | ||
const phoneField = jQuery(phoneFieldSelector); | ||
const phoneErrField = jQuery(phoneErrFieldSelector); | ||
const phoneErrFieldSecond = jQuery(phoneErrFieldSecondSelector); | ||
|
||
phoneField.val(phoneField.val().replace(/[^+\d]/g, '').trim()); | ||
const phoneNumber = phoneField.val(); | ||
|
||
const showError = (errorField) => { | ||
phoneErrField.hide(); | ||
phoneErrFieldSecond.hide(); | ||
errorField.show(); | ||
phoneField.addClass(UL_ERROR_CLASS); | ||
}; | ||
|
||
if (phoneNumber === '') { | ||
showError(phoneErrFieldSecond); | ||
return false; | ||
} | ||
|
||
if (phoneNumber.length < minLength || phoneNumber.length > maxLength || !phonePattern.test(phoneNumber)) { | ||
showError(phoneErrField); | ||
return false; | ||
} | ||
|
||
phoneField.removeClass(UL_ERROR_CLASS); | ||
phoneErrField.hide(); | ||
phoneErrFieldSecond.hide(); | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
wp-content/plugins/unlimit/includes/module/preference/WC_Unlimit_Module_Airteltz.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
use Automattic\WooCommerce\Admin\Overrides\Order; | ||
|
||
require_once __DIR__ . '/WC_Unlimit_Alt_Module.php'; | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
class WC_Unlimit_Module_Airteltz extends WC_Unlimit_Alt_Module { | ||
|
||
/** | ||
* @param WC_Unlimit_Gateway_Abstract $payment Payment | ||
* @param Order $order | ||
* @param array $post_fields | ||
* | ||
* @throws Exception | ||
*/ | ||
public function __construct( $payment, $order, $post_fields ) { | ||
parent::__construct( $payment, $order, $post_fields, 'AIRTELTZS', 'airteltz' ); | ||
|
||
$this->api_request['ewallet_account']['id'] = $this->post_fields['cardpay_airteltz']['phone_number']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
wp-content/plugins/unlimit/includes/payments/WC_Unlimit_Airteltz_Gateway.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
require_once __DIR__ . '/form_fields/WC_Unlimit_Admin_Airteltz_Fields.php'; | ||
require_once __DIR__ . '/hooks/WC_Unlimit_Hook_Airteltz.php'; | ||
require_once __DIR__ . '/../module/preference/WC_Unlimit_Module_Airteltz.php'; | ||
require_once __DIR__ . '/WC_Unlimit_Alt_Gateway.php'; | ||
|
||
/** | ||
* Unlimit Airteltz payment method | ||
*/ | ||
class WC_Unlimit_Airteltz_Gateway extends WC_Unlimit_Alt_Gateway { | ||
|
||
const GATEWAY_ID = 'woo-unlimit-airteltz'; | ||
const SHORT_GATEWAY_ID = 'airteltz'; | ||
|
||
public function __construct() { | ||
$this->id = self::GATEWAY_ID; | ||
|
||
parent::__construct( | ||
self::GATEWAY_ID, | ||
self::SHORT_GATEWAY_ID, | ||
'Airtel TZ', | ||
new WC_Unlimit_Admin_Airteltz_Fields(), | ||
new WC_Unlimit_Hook_Airteltz( $this ) | ||
); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
*/ | ||
public function get_module( $order, $post_fields ) { | ||
return new WC_Unlimit_Module_Airteltz( $this, $order, $post_fields ); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public static function get_id() { | ||
return self::GATEWAY_ID; | ||
} | ||
} |
Oops, something went wrong.