mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Fix merge conflicts
This commit is contained in:
commit
3c0e807758
55 changed files with 5170 additions and 202 deletions
|
@ -33,6 +33,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Admin\RenderAuthorizeAction;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Assets\FraudNetAssets;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Checkout\CheckoutPayPalAddressPreset;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Checkout\DisableGateways;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Cli\SettingsCommand;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Endpoint\ReturnUrlEndpoint;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\FundingSource\FundingSourceRenderer;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway;
|
||||
|
@ -1413,4 +1414,9 @@ return array(
|
|||
$container->get( 'wcgateway.is-fraudnet-enabled' )
|
||||
);
|
||||
},
|
||||
'wcgateway.cli.settings.command' => function( ContainerInterface $container ) : SettingsCommand {
|
||||
return new SettingsCommand(
|
||||
$container->get( 'wcgateway.settings' )
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
70
modules/ppcp-wc-gateway/src/Cli/SettingsCommand.php
Normal file
70
modules/ppcp-wc-gateway/src/Cli/SettingsCommand.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* WP-CLI commands for managing plugin settings.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\WcGateway\Cli
|
||||
*/
|
||||
|
||||
declare( strict_types=1 );
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Cli;
|
||||
|
||||
use WP_CLI;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
/**
|
||||
* Class SettingsCommand.
|
||||
*/
|
||||
class SettingsCommand {
|
||||
/**
|
||||
* The settings.
|
||||
*
|
||||
* @var Settings
|
||||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* SettingsCommand constructor.
|
||||
*
|
||||
* @param Settings $settings The settings.
|
||||
*/
|
||||
public function __construct( Settings $settings ) {
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the specified settings.
|
||||
*
|
||||
* ## OPTIONS
|
||||
*
|
||||
* <id>
|
||||
* : The setting key.
|
||||
*
|
||||
* <value>
|
||||
* : The setting value.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* wp pcp settings update description "Pay via PayPal."
|
||||
* wp pcp settings update vault_enabled true
|
||||
* wp pcp settings update vault_enabled false
|
||||
*
|
||||
* @param array $args Positional args.
|
||||
* @param array $assoc_args Option args.
|
||||
*/
|
||||
public function update( array $args, array $assoc_args ): void {
|
||||
$key = (string) $args[0];
|
||||
$value = $args[1];
|
||||
|
||||
if ( 'true' === strtolower( $value ) ) {
|
||||
$value = true;
|
||||
} elseif ( 'false' === strtolower( $value ) ) {
|
||||
$value = false;
|
||||
}
|
||||
|
||||
$this->settings->set( $key, $value );
|
||||
$this->settings->persist();
|
||||
|
||||
WP_CLI::success( "Updated '{$key}' to '{$value}'." );
|
||||
}
|
||||
}
|
|
@ -444,7 +444,13 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing
|
||||
$funding_source = wc_clean( wp_unslash( $_POST['ppcp-funding-source'] ?? '' ) );
|
||||
$funding_source = wc_clean( wp_unslash( $_POST['ppcp-funding-source'] ?? ( $_POST['funding_source'] ?? '' ) ) );
|
||||
|
||||
if ( $funding_source ) {
|
||||
$wc_order->set_payment_method_title( $this->funding_source_renderer->render_name( $funding_source ) );
|
||||
$wc_order->save();
|
||||
}
|
||||
|
||||
if ( 'card' !== $funding_source && $this->is_free_trial_order( $wc_order ) ) {
|
||||
$user_id = (int) $wc_order->get_customer_id();
|
||||
$tokens = $this->payment_token_repository->all_for_user_id( $user_id );
|
||||
|
|
|
@ -440,6 +440,7 @@ class PayUponInvoice {
|
|||
}
|
||||
|
||||
if (
|
||||
// phpcs:ignore WordPress.Security.NonceVerification
|
||||
isset( $_GET['pay_for_order'] ) && $_GET['pay_for_order'] === 'true'
|
||||
&& ! $this->pui_helper->is_pay_for_order_ready_for_pui()
|
||||
) {
|
||||
|
|
|
@ -98,6 +98,9 @@ class SettingsStatus {
|
|||
if ( 'pay-now' === $location ) {
|
||||
$location = 'checkout';
|
||||
}
|
||||
if ( 'checkout-block' === $location ) {
|
||||
$location = 'checkout-block-express';
|
||||
}
|
||||
return $location;
|
||||
}
|
||||
|
||||
|
|
|
@ -162,8 +162,13 @@ class OrderProcessor {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function process( WC_Order $wc_order ): bool {
|
||||
$order = $this->session_handler->order();
|
||||
public function process( \WC_Order $wc_order ): bool {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification
|
||||
$order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY ) ?: wc_clean( wp_unslash( $_POST['paypal_order_id'] ?? '' ) );
|
||||
$order = $this->session_handler->order();
|
||||
if ( ! $order && is_string( $order_id ) ) {
|
||||
$order = $this->order_endpoint->order( $order_id );
|
||||
}
|
||||
if ( ! $order ) {
|
||||
$order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY );
|
||||
if ( ! $order_id ) {
|
||||
|
|
|
@ -381,6 +381,13 @@ class WCGatewayModule implements ModuleInterface {
|
|||
10,
|
||||
3
|
||||
);
|
||||
|
||||
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
||||
\WP_CLI::add_command(
|
||||
'pcp settings',
|
||||
$c->get( 'wcgateway.cli.settings.command' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue