Fix merge conflicts

This commit is contained in:
emilicastells 2023-01-23 12:15:23 +01:00
commit 1d152bd6ba
No known key found for this signature in database
GPG key ID: 1520C07081754570
18 changed files with 112 additions and 734 deletions

View file

@ -72,7 +72,6 @@ return array(
$settings = $container->get( 'wcgateway.settings' );
$intent = $settings->has( 'intent' ) && strtoupper( (string) $settings->get( 'intent' ) ) === 'AUTHORIZE' ? 'AUTHORIZE' : 'CAPTURE';
$application_context_repository = $container->get( 'api.repository.application-context' );
$pay_pal_request_id_repository = $container->get( 'api.repository.paypal-request-id' );
$subscription_helper = $container->get( 'subscription.helper' );
return new OrderEndpoint(
$container->get( 'api.host' ),
@ -82,7 +81,6 @@ return array(
$intent,
$logger,
$application_context_repository,
$pay_pal_request_id_repository,
$subscription_helper,
$container->get( 'wcgateway.is-fraudnet-enabled' ),
$container->get( 'wcgateway.fraudnet' ),

View file

@ -99,6 +99,10 @@ class DisableGateways {
* @return bool
*/
private function disable_all_gateways() : bool {
if ( is_null( WC()->payment_gateways ) ) {
return false;
}
foreach ( WC()->payment_gateways->payment_gateways() as $gateway ) {
if ( PayPalGateway::ID === $gateway->id && $gateway->enabled !== 'yes' ) {
return true;

View file

@ -63,7 +63,15 @@ class OXXO {
add_filter(
'woocommerce_available_payment_gateways',
function ( array $methods ): array {
/**
* Param types removed to avoid third-party issues.
*
* @psalm-suppress MissingClosureParamType
*/
function ( $methods ) {
if ( ! is_array( $methods ) ) {
return $methods;
}
if ( ! $this->checkout_allowed_for_oxxo() ) {
unset( $methods[ OXXOGateway::ID ] );

View file

@ -10,9 +10,11 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Processor;
use Psr\Log\LoggerInterface;
use WC_Order;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory;
use WooCommerce\PayPalCommerce\ApiClient\Helper\OrderHelper;
use WooCommerce\PayPalCommerce\Button\Helper\ThreeDSecure;
@ -160,12 +162,27 @@ class OrderProcessor {
*
* @return bool
*/
public function process( \WC_Order $wc_order ): bool {
$order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY );
$order = $this->session_handler->order() ?? $this->order_endpoint->order( $order_id );
public function process( WC_Order $wc_order ): bool {
$order = $this->session_handler->order();
if ( ! $order ) {
$this->last_error = __( 'No PayPal order found in the current WooCommerce session.', 'woocommerce-paypal-payments' );
return false;
$order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY );
if ( ! $order_id ) {
$this->logger->warning(
sprintf(
'No PayPal order ID found in order #%d meta.',
$wc_order->get_id()
)
);
$this->last_error = __( 'Could not retrieve order. This browser may not be supported. Please try again with a different browser.', 'woocommerce-paypal-payments' );
return false;
}
try {
$order = $this->order_endpoint->order( $order_id );
} catch ( RuntimeException $exception ) {
$this->last_error = __( 'Could not retrieve PayPal order.', 'woocommerce-paypal-payments' );
return false;
}
}
$this->add_paypal_meta( $wc_order, $order, $this->environment );

View file

@ -16,7 +16,6 @@ use WooCommerce\PayPalCommerce\AdminNotices\Repository\Repository;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Capture;
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
use WooCommerce\PayPalCommerce\ApiClient\Repository\PayPalRequestIdRepository;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\WcGateway\Admin\FeesRenderer;
use WooCommerce\PayPalCommerce\WcGateway\Admin\OrderTablePaymentStatusColumn;
@ -215,7 +214,6 @@ class WCGatewayModule implements ModuleInterface {
'woocommerce_paypal_commerce_gateway_deactivate',
static function () use ( $c ) {
delete_option( Settings::KEY );
delete_option( PayPalRequestIdRepository::KEY );
delete_option( 'woocommerce_' . PayPalGateway::ID . '_settings' );
delete_option( 'woocommerce_' . CreditCardGateway::ID . '_settings' );
}
@ -237,6 +235,8 @@ class WCGatewayModule implements ModuleInterface {
add_action(
'woocommerce_paypal_payments_gateway_migrate',
static function () use ( $c ) {
delete_option( 'ppcp-request-ids' );
$settings = $c->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );