Merge branch 'trunk' into pcp-157-blocks

This commit is contained in:
Alex P 2023-03-14 09:24:06 +02:00
commit 25b13e4467
No known key found for this signature in database
GPG key ID: 54487A734A204D71
40 changed files with 757 additions and 300 deletions

View file

@ -114,10 +114,13 @@ import {setVisibleByClass, isVisible} from "../../../ppcp-button/resources/js/mo
'integration-date': PayPalCommerceGatewaySettings.integration_date,
'components': ['buttons', 'funding-eligibility', 'messages'],
'enable-funding': ['venmo', 'paylater'],
'buyer-country': PayPalCommerceGatewaySettings.country,
};
if(payLaterButtonPreview?.length) {
if (PayPalCommerceGatewaySettings.environment === 'sandbox') {
settings['buyer-country'] = PayPalCommerceGatewaySettings.country;
}
if (payLaterButtonPreview?.length) {
disabledSources = Object.keys(PayPalCommerceGatewaySettings.all_funding_sources);
}

View file

@ -36,6 +36,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Endpoint\ReturnUrlEndpoint;
use WooCommerce\PayPalCommerce\WcGateway\FundingSource\FundingSourceRenderer;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\GatewayRepository;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\OXXO\OXXO;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\OXXO\OXXOEndpoint;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\OXXO\OXXOGateway;
@ -538,6 +539,23 @@ return array(
'requirements' => array(),
'gateway' => 'paypal',
),
'capture_on_status_change' => array(
'title' => __( 'Capture On Status Change', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'default' => false,
'desc_tip' => true,
'description' => __(
'The transaction will be captured automatically when the order status changes to Processing or Completed.',
'woocommerce-paypal-payments'
),
'label' => __( 'Capture On Status Change', 'woocommerce-paypal-payments' ),
'screens' => array(
State::STATE_START,
State::STATE_ONBOARDED,
),
'requirements' => array(),
'gateway' => 'paypal',
),
'capture_for_virtual_only' => array(
'title' => __( 'Capture Virtual-Only Orders ', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
@ -921,7 +939,8 @@ return array(
$settings,
$partner_endpoint,
$container->get( 'dcc.status-cache' ),
$container->get( 'api.helpers.dccapplies' )
$container->get( 'api.helpers.dccapplies' ),
$container->get( 'onboarding.state' )
);
},
@ -989,7 +1008,8 @@ return array(
return new PayUponInvoiceProductStatus(
$container->get( 'wcgateway.settings' ),
$container->get( 'api.endpoint.partners' ),
$container->get( 'pui.status-cache' )
$container->get( 'pui.status-cache' ),
$container->get( 'onboarding.state' )
);
},
'wcgateway.pay-upon-invoice' => static function ( ContainerInterface $container ): PayUponInvoice {
@ -1348,19 +1368,10 @@ return array(
OXXOGateway::ID,
);
},
'wcgateway.enabled-ppcp-gateways' => static function ( ContainerInterface $container ): array {
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
$ppcp_gateways = $container->get( 'wcgateway.ppcp-gateways' );
$enabled_ppcp_gateways = array();
foreach ( $ppcp_gateways as $gateway ) {
if ( ! isset( $available_gateways[ $gateway ] ) ) {
continue;
}
$enabled_ppcp_gateways[] = $gateway;
}
return $enabled_ppcp_gateways;
'wcgateway.gateway-repository' => static function ( ContainerInterface $container ): GatewayRepository {
return new GatewayRepository(
$container->get( 'wcgateway.ppcp-gateways' )
);
},
'wcgateway.is-fraudnet-enabled' => static function ( ContainerInterface $container ): bool {
$settings = $container->get( 'wcgateway.settings' );
@ -1375,7 +1386,7 @@ return array(
$container->get( 'wcgateway.fraudnet' ),
$container->get( 'onboarding.environment' ),
$container->get( 'wcgateway.settings' ),
$container->get( 'wcgateway.enabled-ppcp-gateways' ),
$container->get( 'wcgateway.gateway-repository' ),
$container->get( 'session.handler' ),
$container->get( 'wcgateway.is-fraudnet-enabled' )
);

View file

@ -14,6 +14,7 @@ use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Session\SessionHandler;
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
use WooCommerce\PayPalCommerce\WcGateway\FraudNet\FraudNet;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\GatewayRepository;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PayUponInvoiceGateway;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
@ -63,10 +64,17 @@ class FraudNetAssets {
/**
* The list of enabled PayPal gateways.
*
* @var string[]
* @var string[]|null
*/
protected $enabled_ppcp_gateways;
/**
* The GatewayRepository.
*
* @var GatewayRepository
*/
protected $gateway_repository;
/**
* The session handler
*
@ -84,14 +92,14 @@ class FraudNetAssets {
/**
* Assets constructor.
*
* @param string $module_url The url of this module.
* @param string $version The assets version.
* @param FraudNet $fraud_net The FraudNet entity.
* @param Environment $environment The environment.
* @param Settings $settings The Settings.
* @param string[] $enabled_ppcp_gateways The list of enabled PayPal gateways.
* @param SessionHandler $session_handler The session handler.
* @param bool $is_fraudnet_enabled true if FraudNet support is enabled in settings, otherwise false.
* @param string $module_url The url of this module.
* @param string $version The assets version.
* @param FraudNet $fraud_net The FraudNet entity.
* @param Environment $environment The environment.
* @param Settings $settings The Settings.
* @param GatewayRepository $gateway_repository The GatewayRepository.
* @param SessionHandler $session_handler The session handler.
* @param bool $is_fraudnet_enabled true if FraudNet support is enabled in settings, otherwise false.
*/
public function __construct(
string $module_url,
@ -99,18 +107,18 @@ class FraudNetAssets {
FraudNet $fraud_net,
Environment $environment,
Settings $settings,
array $enabled_ppcp_gateways,
GatewayRepository $gateway_repository,
SessionHandler $session_handler,
bool $is_fraudnet_enabled
) {
$this->module_url = $module_url;
$this->version = $version;
$this->fraud_net = $fraud_net;
$this->environment = $environment;
$this->settings = $settings;
$this->enabled_ppcp_gateways = $enabled_ppcp_gateways;
$this->session_handler = $session_handler;
$this->is_fraudnet_enabled = $is_fraudnet_enabled;
$this->module_url = $module_url;
$this->version = $version;
$this->fraud_net = $fraud_net;
$this->environment = $environment;
$this->settings = $settings;
$this->gateway_repository = $gateway_repository;
$this->session_handler = $session_handler;
$this->is_fraudnet_enabled = $is_fraudnet_enabled;
}
/**
@ -149,12 +157,12 @@ class FraudNetAssets {
* @return bool true if FraudNet script should be loaded, otherwise false.
*/
protected function should_load_fraudnet_script(): bool {
if ( empty( $this->enabled_ppcp_gateways ) ) {
if ( empty( $this->enabled_ppcp_gateways() ) ) {
return false;
}
$is_pui_gateway_enabled = in_array( PayUponInvoiceGateway::ID, $this->enabled_ppcp_gateways, true );
$is_only_standard_gateway_enabled = $this->enabled_ppcp_gateways === array( PayPalGateway::ID );
$is_pui_gateway_enabled = in_array( PayUponInvoiceGateway::ID, $this->enabled_ppcp_gateways(), true );
$is_only_standard_gateway_enabled = $this->enabled_ppcp_gateways() === array( PayPalGateway::ID );
if ( $this->context() !== 'checkout' || $is_only_standard_gateway_enabled ) {
return $this->is_fraudnet_enabled && $this->are_buttons_enabled_for_context();
@ -169,7 +177,7 @@ class FraudNetAssets {
* @return bool true if enabled, otherwise false.
*/
protected function are_buttons_enabled_for_context() : bool {
if ( ! in_array( PayPalGateway::ID, $this->enabled_ppcp_gateways, true ) ) {
if ( ! in_array( PayPalGateway::ID, $this->enabled_ppcp_gateways(), true ) ) {
return false;
}
try {
@ -188,4 +196,16 @@ class FraudNetAssets {
return in_array( $this->context(), $button_locations, true );
}
/**
* Returns IDs of the currently enabled PPCP gateways.
*
* @return string[]
*/
protected function enabled_ppcp_gateways(): array {
if ( null === $this->enabled_ppcp_gateways ) {
$this->enabled_ppcp_gateways = $this->gateway_repository->get_enabled_ppcp_gateway_ids();
}
return $this->enabled_ppcp_gateways;
}
}

View file

@ -9,6 +9,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Assets;
use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
/**
@ -58,6 +59,13 @@ class SettingsPageAssets {
*/
private $country;
/**
* The environment object.
*
* @var Environment
*/
private $environment;
/**
* Whether Pay Later button is enabled either for checkout, cart or product page.
*
@ -88,6 +96,7 @@ class SettingsPageAssets {
* @param string $client_id The PayPal SDK client ID.
* @param string $currency 3-letter currency code of the shop.
* @param string $country 2-letter country code of the shop.
* @param Environment $environment The environment object.
* @param bool $is_pay_later_button_enabled Whether Pay Later button is enabled either for checkout, cart or product page.
* @param array $disabled_sources The list of disabled funding sources.
* @param array $all_funding_sources The list of all existing funding sources.
@ -99,6 +108,7 @@ class SettingsPageAssets {
string $client_id,
string $currency,
string $country,
Environment $environment,
bool $is_pay_later_button_enabled,
array $disabled_sources,
array $all_funding_sources
@ -109,6 +119,7 @@ class SettingsPageAssets {
$this->client_id = $client_id;
$this->currency = $currency;
$this->country = $country;
$this->environment = $environment;
$this->is_pay_later_button_enabled = $is_pay_later_button_enabled;
$this->disabled_sources = $disabled_sources;
$this->all_funding_sources = $all_funding_sources;
@ -191,6 +202,7 @@ class SettingsPageAssets {
'client_id' => $this->client_id,
'currency' => $this->currency,
'country' => $this->country,
'environment' => $this->environment->current_environment(),
'integration_date' => PAYPAL_INTEGRATION_DATE,
'is_pay_later_button_enabled' => $this->is_pay_later_button_enabled,
'disabled_sources' => $this->disabled_sources,

View file

@ -0,0 +1,47 @@
<?php
/**
* Operations with the WC gateways.
*
* @package WooCommerce\PayPalCommerce\WcGateway\Gateway
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Gateway;
/**
* Class GatewayRepository
*/
class GatewayRepository {
/**
* IDs of our gateways.
*
* @var string[]
*/
protected $ppcp_gateway_ids;
/**
* GatewayRepository constructor.
*
* @param string[] $ppcp_gateway_ids IDs of our gateways.
*/
public function __construct( array $ppcp_gateway_ids ) {
$this->ppcp_gateway_ids = $ppcp_gateway_ids;
}
/**
* Returns IDs of the currently enabled PPCP gateways.
*
* @return array
*/
public function get_enabled_ppcp_gateway_ids(): array {
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
return array_filter(
$this->ppcp_gateway_ids,
function ( string $id ) use ( $available_gateways ): bool {
return isset( $available_gateways[ $id ] );
}
);
}
}

View file

@ -422,7 +422,7 @@ class PayUponInvoice {
*
* @psalm-suppress MissingClosureParamType
*/
function ( $methods ): array {
function ( $methods ) {
if ( ! is_array( $methods ) || State::STATE_ONBOARDED !== $this->state->current_state() ) {
return $methods;
}

View file

@ -14,6 +14,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnersEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Entity\SellerStatusProduct;
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
/**
@ -57,6 +58,13 @@ class DCCProductStatus {
*/
protected $dcc_applies;
/**
* The onboarding state.
*
* @var State
*/
private $onboarding_state;
/**
* DccProductStatus constructor.
*
@ -64,17 +72,20 @@ class DCCProductStatus {
* @param PartnersEndpoint $partners_endpoint The Partner Endpoint.
* @param Cache $cache The cache.
* @param DccApplies $dcc_applies The dcc applies helper.
* @param State $onboarding_state The onboarding state.
*/
public function __construct(
Settings $settings,
PartnersEndpoint $partners_endpoint,
Cache $cache,
DccApplies $dcc_applies
DccApplies $dcc_applies,
State $onboarding_state
) {
$this->settings = $settings;
$this->partners_endpoint = $partners_endpoint;
$this->cache = $cache;
$this->dcc_applies = $dcc_applies;
$this->onboarding_state = $onboarding_state;
}
/**
@ -83,6 +94,10 @@ class DCCProductStatus {
* @return bool
*/
public function dcc_is_active() : bool {
if ( $this->onboarding_state->current_state() < State::STATE_ONBOARDED ) {
return false;
}
if ( $this->cache->has( self::DCC_STATUS_CACHE_KEY ) ) {
return (bool) $this->cache->get( self::DCC_STATUS_CACHE_KEY );
}

View file

@ -13,6 +13,7 @@ use Throwable;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnersEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Entity\SellerStatusProduct;
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
/**
@ -49,21 +50,31 @@ class PayUponInvoiceProductStatus {
*/
private $partners_endpoint;
/**
* The onboarding status
*
* @var State
*/
private $onboarding_state;
/**
* PayUponInvoiceProductStatus constructor.
*
* @param Settings $settings The Settings.
* @param PartnersEndpoint $partners_endpoint The Partner Endpoint.
* @param Cache $cache The cache.
* @param State $onboarding_state The onboarding state.
*/
public function __construct(
Settings $settings,
PartnersEndpoint $partners_endpoint,
Cache $cache
Cache $cache,
State $onboarding_state
) {
$this->settings = $settings;
$this->partners_endpoint = $partners_endpoint;
$this->cache = $cache;
$this->onboarding_state = $onboarding_state;
}
/**
@ -72,6 +83,10 @@ class PayUponInvoiceProductStatus {
* @return bool
*/
public function pui_is_active() : bool {
if ( $this->onboarding_state->current_state() < State::STATE_ONBOARDED ) {
return false;
}
if ( $this->cache->has( self::PUI_STATUS_CACHE_KEY ) ) {
return (bool) $this->cache->get( self::PUI_STATUS_CACHE_KEY );
}

View file

@ -37,7 +37,6 @@ class SettingsStatus {
* Check whether Pay Later message is enabled either for checkout, cart or product page.
*
* @return bool true if is enabled, otherwise false.
* @throws NotFoundException When a setting was not found.
*/
public function is_pay_later_messaging_enabled(): bool {
$messaging_enabled = $this->settings->has( 'pay_later_messaging_enabled' ) && $this->settings->get( 'pay_later_messaging_enabled' );
@ -51,27 +50,15 @@ class SettingsStatus {
*
* @param string $location The location setting name.
* @return bool true if is enabled, otherwise false.
* @throws NotFoundException When a setting was not found.
*/
public function is_pay_later_messaging_enabled_for_location( string $location ): bool {
if ( ! $this->is_pay_later_messaging_enabled() ) {
return false;
}
$selected_locations = $this->settings->has( 'pay_later_messaging_locations' ) ? $this->settings->get( 'pay_later_messaging_locations' ) : array();
if ( empty( $selected_locations ) ) {
return false;
}
return in_array( $location, $selected_locations, true );
return $this->is_pay_later_messaging_enabled() && $this->is_enabled_for_location( 'pay_later_messaging_locations', $location );
}
/**
* Check whether Pay Later button is enabled either for checkout, cart or product page.
*
* @return bool true if is enabled, otherwise false.
* @throws NotFoundException When a setting was not found.
*/
public function is_pay_later_button_enabled(): bool {
$pay_later_button_enabled = $this->settings->has( 'pay_later_button_enabled' ) && $this->settings->get( 'pay_later_button_enabled' );
@ -85,45 +72,9 @@ class SettingsStatus {
*
* @param string $location The location.
* @return bool true if is enabled, otherwise false.
* @throws NotFoundException When a setting was not found.
*/
public function is_pay_later_button_enabled_for_location( string $location ): bool {
if ( ! $this->is_pay_later_button_enabled() ) {
return false;
}
$selected_locations = $this->settings->has( 'pay_later_button_locations' ) ? $this->settings->get( 'pay_later_button_locations' ) : array();
if ( empty( $selected_locations ) ) {
return false;
}
return in_array( $location, $selected_locations, true );
}
/**
* Check whether Pay Later button is enabled for a given context.
*
* @param string $context The context.
* @return bool true if is enabled, otherwise false.
* @throws NotFoundException When a setting was not found.
*/
public function is_pay_later_button_enabled_for_context( string $context ): bool {
if ( ! $this->is_pay_later_button_enabled() ) {
return false;
}
$selected_locations = $this->settings->has( 'pay_later_button_locations' ) ? $this->settings->get( 'pay_later_button_locations' ) : array();
if ( empty( $selected_locations ) ) {
return false;
}
$enabled_for_current_location = $this->is_pay_later_button_enabled_for_location( $context );
$enabled_for_product = $this->is_pay_later_button_enabled_for_location( 'product' );
$enabled_for_mini_cart = $this->is_pay_later_button_enabled_for_location( 'mini-cart' );
return $context === 'product' ? $enabled_for_product || $enabled_for_mini_cart : $enabled_for_current_location;
return $this->is_pay_later_button_enabled() && $this->is_enabled_for_location( 'pay_later_button_locations', $location );
}
/**
@ -133,7 +84,33 @@ class SettingsStatus {
* @return bool true if is enabled, otherwise false.
*/
public function is_smart_button_enabled_for_location( string $location ): bool {
$selected_locations = $this->settings->has( 'smart_button_locations' ) ? $this->settings->get( 'smart_button_locations' ) : array();
return $this->is_enabled_for_location( 'smart_button_locations', $location );
}
/**
* Adapts the context value to match the location settings.
*
* @param string $location The location/context.
* @return string
*/
protected function normalize_location( string $location ): string {
if ( 'pay-now' === $location ) {
$location = 'checkout';
}
return $location;
}
/**
* Checks whether the locations field in the settings includes the given location.
*
* @param string $setting_name The name of the enabled locations field in the settings.
* @param string $location The location.
* @return bool
*/
protected function is_enabled_for_location( string $setting_name, string $location ): bool {
$location = $this->normalize_location( $location );
$selected_locations = $this->settings->has( $setting_name ) ? $this->settings->get( $setting_name ) : array();
if ( empty( $selected_locations ) ) {
return false;

View file

@ -193,10 +193,7 @@ class SettingsListener {
*/
do_action( 'woocommerce_paypal_payments_onboarding_before_redirect' );
/**
* The URL opened at the end of onboarding after saving the merchant ID/email.
*/
$redirect_url = apply_filters( 'woocommerce_paypal_payments_onboarding_redirect_url', admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway&ppcp-tab=' . Settings::CONNECTION_TAB_ID ) );
$redirect_url = $this->get_onboarding_redirect_url();
if ( ! $this->settings->has( 'client_id' ) || ! $this->settings->get( 'client_id' ) ) {
$redirect_url = add_query_arg( 'ppcp-onboarding-error', '1', $redirect_url );
}
@ -347,9 +344,17 @@ class SettingsListener {
$this->dcc_status_cache->delete( DCCProductStatus::DCC_STATUS_CACHE_KEY );
}
$redirect_url = false;
if ( self::CREDENTIALS_ADDED === $credentials_change_status ) {
$redirect_url = $this->get_onboarding_redirect_url();
}
if ( isset( $_GET['ppcp-onboarding-error'] ) ) {
$url = remove_query_arg( 'ppcp-onboarding-error' );
wp_safe_redirect( $url, 302 );
$redirect_url = remove_query_arg( 'ppcp-onboarding-error', $redirect_url );
}
if ( $redirect_url ) {
wp_safe_redirect( $redirect_url, 302 );
exit;
}
@ -357,6 +362,18 @@ class SettingsListener {
// phpcs:enable WordPress.Security.NonceVerification.Recommended
}
/**
* Returns the URL opened at the end of onboarding.
*
* @return string
*/
private function get_onboarding_redirect_url(): string {
/**
* The URL opened at the end of onboarding after saving the merchant ID/email.
*/
return apply_filters( 'woocommerce_paypal_payments_onboarding_redirect_url', admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway&ppcp-tab=' . Settings::CONNECTION_TAB_ID ) );
}
/**
* The actual used client credentials are stored in 'client_secret', 'client_id', 'merchant_id' and 'merchant_email'.
* This method populates those fields depending on the sandbox status.

View file

@ -9,6 +9,8 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway;
use Psr\Log\LoggerInterface;
use Throwable;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
use WC_Order;
@ -174,6 +176,7 @@ class WCGatewayModule implements ModuleInterface {
$c->get( 'button.client_id_for_admin' ),
$c->get( 'api.shop.currency' ),
$c->get( 'api.shop.country' ),
$c->get( 'onboarding.environment' ),
$settings_status->is_pay_later_button_enabled(),
$settings->has( 'disable_funding' ) ? $settings->get( 'disable_funding' ) : array(),
$c->get( 'wcgateway.all-funding-sources' )
@ -306,6 +309,57 @@ class WCGatewayModule implements ModuleInterface {
$endpoint->handle_request();
}
);
add_action(
'woocommerce_order_status_changed',
static function ( int $order_id, string $from, string $to ) use ( $c ) {
$wc_order = wc_get_order( $order_id );
if ( ! $wc_order instanceof WC_Order ) {
return;
}
$settings = $c->get( 'wcgateway.settings' );
assert( $settings instanceof ContainerInterface );
if ( ! $settings->has( 'capture_on_status_change' ) || ! $settings->get( 'capture_on_status_change' ) ) {
return;
}
$intent = strtoupper( (string) $wc_order->get_meta( PayPalGateway::INTENT_META_KEY ) );
$captured = wc_string_to_bool( $wc_order->get_meta( AuthorizedPaymentsProcessor::CAPTURED_META_KEY ) );
if ( $intent !== 'AUTHORIZE' || $captured ) {
return;
}
/**
* The filter returning the WC order statuses which trigger capturing of payment authorization.
*/
$capture_statuses = apply_filters( 'woocommerce_paypal_payments_auto_capture_statuses', array( 'processing', 'completed' ), $wc_order );
if ( ! in_array( $to, $capture_statuses, true ) ) {
return;
}
$authorized_payment_processor = $c->get( 'wcgateway.processor.authorized-payments' );
assert( $authorized_payment_processor instanceof AuthorizedPaymentsProcessor );
try {
if ( $authorized_payment_processor->capture_authorized_payment( $wc_order ) ) {
return;
}
} catch ( Throwable $error ) {
$logger = $c->get( 'woocommerce.logger.woocommerce' );
assert( $logger instanceof LoggerInterface );
$logger->error( "Capture failed. {$error->getMessage()} {$error->getFile()}:{$error->getLine()}" );
}
$wc_order->update_status(
'failed',
__( 'Could not capture the payment.', 'woocommerce-paypal-payments' )
);
},
10,
3
);
}
/**