Handle handle_onepay_querydr

This commit is contained in:
Dat Hoang
2020-09-01 23:46:50 +07:00
parent d039192043
commit 9bc9726151
2 changed files with 32 additions and 12 deletions
+1 -1
View File
@@ -158,7 +158,7 @@ abstract class WooViet_OnePay_Abstract extends WC_Payment_Gateway {
wp_schedule_single_event(
time() + 20 * 60,
'wooviet_handle_onepay_querydr',
$this->id . '_handle_querydr', // wooviet_onepay_international_handle_querydr | wooviet_onepay_domestic_handle_querydr
array( $vpc_MerchTxnRef )
);
+31 -11
View File
@@ -170,12 +170,30 @@ class WooViet {
return $methods;
} );
// Add the action to check the cron job for handling queryDR
// It's not possible to add in the class "WooViet_OnePay_Domestic_Hook" because it's NOT always loadded
/**
* Add the action to check the cron job for handling queryDR
* It's not possible to add in the "WooViet_OnePay_Domestic" class
* because it's NOT always loaded in the 'woocommerce_payment_gateways' hook above
*/
if ( defined( 'DOING_CRON' ) and DOING_CRON ) {
$this->WooViet_OnePay_Domestic_Hook = new WooViet_OnePay_Domestic();
$wooviet_onepay_domestic = new WooViet_OnePay_Domestic();
/**
* @since 1.5.0
*/
add_action( 'wooviet_onepay_domestic_handle_querydr', array(
$wooviet_onepay_domestic,
'handle_onepay_querydr'
), 10, 1 );
/**
* Backward compatibility
* Actually, this does help for the short time (exactly 20 minutes) @see WooViet_OnePay_Abstract::set_onepay_querydr_cron()
* when upgrading to version 1.5.0
* as the previous cron jobs set by the previous versions has not run yet.
*
* TODO: May consider removing this completely after 2 major versions. Target: 1.7
*/
add_action( 'wooviet_handle_onepay_querydr', array(
$this->WooViet_OnePay_Domestic_Hook,
$wooviet_onepay_domestic,
'handle_onepay_querydr'
), 10, 1 );
}
@@ -196,17 +214,19 @@ class WooViet {
return $methods;
} );
/// TODO check this code - it may not work properly and duplicate of Domestic
// Add the action to check the cron job for handling queryDR
// It's not possible to add in the class "WooViet_OnePay_Domestic_Hook" because it's NOT always loadded
/**
* Add the action to check the cron job for handling queryDR
* It's not possible to add in the "WooViet_OnePay_International" class
* because it's NOT always loaded in the 'woocommerce_payment_gateways' hook above
*/
if ( defined( 'DOING_CRON' ) and DOING_CRON ) {
$this->WooViet_OnePay_International_Hook = new WooViet_OnePay_International();
add_action( 'wooviet_handle_onepay_querydr', array(
$this->WooViet_OnePay_International_Hook,
add_action( 'wooviet_onepay_international_handle_querydr', array(
new WooViet_OnePay_International(),
'handle_onepay_querydr'
), 10, 1 );
}
}
}
// Check if "Add provinces for Vietnam " is enabled.