Fix lint and tests

This commit is contained in:
Pedro Silva 2023-10-26 10:58:05 +01:00
parent 889df4d88c
commit 46b47dc97b
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
8 changed files with 181 additions and 164 deletions

View file

@ -40,6 +40,7 @@ class ApplepayModule implements ModuleInterface {
* {@inheritDoc}
*/
public function run( ContainerInterface $c ): void {
$module = $this;
// Clears product status when appropriate.
add_action(
@ -51,38 +52,44 @@ class ApplepayModule implements ModuleInterface {
}
);
// Check if the module is applicable, correct country, currency, ... etc.
if ( ! $c->get( 'applepay.eligible' ) ) {
return;
}
add_action(
'init',
static function () use ( $c, $module ) {
// Load the button handler.
$apple_payment_method = $c->get( 'applepay.button' );
// add onboarding and referrals hooks.
assert( $apple_payment_method instanceof ApplepayButton );
$apple_payment_method->initialize();
// Check if the module is applicable, correct country, currency, ... etc.
if ( ! $c->get( 'applepay.eligible' ) ) {
return;
}
// Show notice if there are product availability issues.
$availability_notice = $c->get( 'applepay.availability_notice' );
assert( $availability_notice instanceof AvailabilityNotice );
$availability_notice->execute();
// Load the button handler.
$apple_payment_method = $c->get( 'applepay.button' );
// add onboarding and referrals hooks.
assert( $apple_payment_method instanceof ApplepayButton );
$apple_payment_method->initialize();
// Return if server not supported.
if ( ! $c->get( 'applepay.server_supported' ) ) {
return;
}
// Show notice if there are product availability issues.
$availability_notice = $c->get( 'applepay.availability_notice' );
assert( $availability_notice instanceof AvailabilityNotice );
$availability_notice->execute();
// Check if this merchant can activate / use the buttons.
// We allow non referral merchants as they can potentially still use ApplePay, we just have no way of checking the capability.
if ( ( ! $c->get( 'applepay.available' ) ) && $c->get( 'applepay.is_referral' ) ) {
return;
}
// Return if server not supported.
if ( ! $c->get( 'applepay.server_supported' ) ) {
return;
}
$this->load_assets( $c, $apple_payment_method );
$this->handle_validation_file( $c );
$this->render_buttons( $c, $apple_payment_method );
// Check if this merchant can activate / use the buttons.
// We allow non referral merchants as they can potentially still use ApplePay, we just have no way of checking the capability.
if ( ( ! $c->get( 'applepay.available' ) ) && $c->get( 'applepay.is_referral' ) ) {
return;
}
$apple_payment_method->bootstrap_ajax_request();
$module->load_assets( $c, $apple_payment_method );
$module->handle_validation_file( $c );
$module->render_buttons( $c, $apple_payment_method );
$apple_payment_method->bootstrap_ajax_request();
}
);
}
/**