Add failure registry to API module.

Add product status failure handling to GooglePay.
This commit is contained in:
Pedro Silva 2023-09-22 16:27:43 +01:00
parent 904beafa1f
commit 1581f34a44
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
8 changed files with 177 additions and 30 deletions

View file

@ -40,6 +40,17 @@ class GooglepayModule implements ModuleInterface {
*/
public function run( ContainerInterface $c ): void {
// Clears product status when appropriate.
add_action(
'woocommerce_paypal_payments_clear_apm_product_status',
function( Settings $settings = null ) use ( $c ): void {
$apm_status = $c->get( 'googlepay.helpers.apm-product-status' );
assert( $apm_status instanceof ApmProductStatus );
$apm_status->clear( $settings );
}
);
// Check if the module is applicable, correct country, currency, ... etc.
if ( ! $c->get( 'googlepay.eligible' ) ) {
return;
@ -113,22 +124,6 @@ class GooglepayModule implements ModuleInterface {
return $settings;
}
);
// Clears product status when appropriate.
add_action(
'woocommerce_paypal_payments_clear_apm_product_status',
function( Settings $settings = null ) use ( $c ): void {
$apm_status = $c->get( 'googlepay.helpers.apm-product-status' );
assert( $apm_status instanceof ApmProductStatus );
if ( ! $settings instanceof Settings ) {
$settings = null;
}
$apm_status->clear( $settings );
}
);
}
/**