Skip to content

Commit

Permalink
Fix inconsistent instance of AppleProductStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrosilva-pt committed Feb 2, 2024
1 parent 6e78c87 commit 42f3e57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
19 changes: 11 additions & 8 deletions modules/ppcp-applepay/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use WooCommerce\PayPalCommerce\Applepay\Assets\PropertiesDictionary;
use WooCommerce\PayPalCommerce\Applepay\Helper\ApmApplies;
use WooCommerce\PayPalCommerce\Applepay\Helper\AvailabilityNotice;
use WooCommerce\PayPalCommerce\Common\Pattern\SingletonDecorator;
use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
Expand Down Expand Up @@ -72,14 +73,16 @@
return $settings->has( 'applepay_validated' ) ? $settings->get( 'applepay_validated' ) === true : false;
},

'applepay.apple-product-status' => static function( ContainerInterface $container ): AppleProductStatus {
return new AppleProductStatus(
$container->get( 'wcgateway.settings' ),
$container->get( 'api.endpoint.partners' ),
$container->get( 'onboarding.state' ),
$container->get( 'api.helper.failure-registry' )
);
},
'applepay.apple-product-status' => SingletonDecorator::make(
static function( ContainerInterface $container ): AppleProductStatus {
return new AppleProductStatus(
$container->get( 'wcgateway.settings' ),
$container->get( 'api.endpoint.partners' ),
$container->get( 'onboarding.state' ),
$container->get( 'api.helper.failure-registry' )
);
}
),
'applepay.available' => static function ( ContainerInterface $container ): bool {
if ( apply_filters( 'woocommerce_paypal_payments_applepay_validate_product_status', true ) ) {
$status = $container->get( 'applepay.apple-product-status' );
Expand Down
3 changes: 2 additions & 1 deletion modules/ppcp-wc-gateway/src/Settings/SettingsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,10 @@ private function onboarding_redirect( bool $success = true ): void {
/**
* Prevent enabling both Pay Later messaging and PayPal vaulting
*
* @return void
* @throws RuntimeException When API request fails.
*/
public function listen_for_vaulting_enabled() {
public function listen_for_vaulting_enabled(): void {
if ( ! $this->is_valid_site_request() || State::STATE_ONBOARDED !== $this->state->current_state() ) {
return;
}
Expand Down

0 comments on commit 42f3e57

Please sign in to comment.