mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
Merge branch 'trunk' into PCP-1970-unify-conditional-display-logic-for-plugin-settings
# Conflicts: # modules/ppcp-wc-gateway/resources/js/SettingsHandler/SubElementsHandler.js
This commit is contained in:
commit
a9766c01e1
6 changed files with 39 additions and 5 deletions
|
@ -180,10 +180,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
'products',
|
||||
);
|
||||
|
||||
if (
|
||||
( $this->config->has( 'vault_enabled_dcc' ) && $this->config->get( 'vault_enabled_dcc' ) )
|
||||
|| ( $this->config->has( 'subscriptions_mode' ) && $this->config->get( 'subscriptions_mode' ) === 'subscriptions_api' )
|
||||
) {
|
||||
if ( $this->config->has( 'vault_enabled_dcc' ) && $this->config->get( 'vault_enabled_dcc' ) ) {
|
||||
array_push(
|
||||
$this->supports,
|
||||
'subscriptions',
|
||||
|
|
|
@ -543,6 +543,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
}
|
||||
|
||||
$wc_order->payment_complete();
|
||||
|
||||
return $this->handle_payment_success( $wc_order );
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ trait ProcessPaymentTrait {
|
|||
}
|
||||
|
||||
$this->session_handler->destroy_session_data();
|
||||
WC()->session->set( 'ppcp_subscription_id', '' );
|
||||
|
||||
wc_add_notice( $error->getMessage(), 'error' );
|
||||
|
||||
|
@ -100,6 +101,7 @@ trait ProcessPaymentTrait {
|
|||
}
|
||||
|
||||
$this->session_handler->destroy_session_data();
|
||||
WC()->session->set( 'ppcp_subscription_id', '' );
|
||||
|
||||
return array(
|
||||
'result' => 'success',
|
||||
|
|
|
@ -340,7 +340,20 @@ class SettingsListener {
|
|||
* phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||
* phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
*/
|
||||
if ( ! isset( $_POST['ppcp']['vault_enabled'] ) ) {
|
||||
$vault_enabled = wc_clean( wp_unslash( $_POST['ppcp']['vault_enabled'] ?? '' ) );
|
||||
$subscription_mode = wc_clean( wp_unslash( $_POST['ppcp']['subscriptions_mode'] ?? '' ) );
|
||||
|
||||
if ( $subscription_mode === 'vaulting_api' && $vault_enabled !== '1' ) {
|
||||
$this->settings->set( 'vault_enabled', true );
|
||||
$this->settings->persist();
|
||||
}
|
||||
|
||||
if ( $subscription_mode === 'disable_paypal_subscriptions' && $vault_enabled === '1' ) {
|
||||
$this->settings->set( 'vault_enabled', false );
|
||||
$this->settings->persist();
|
||||
}
|
||||
|
||||
if ( $vault_enabled !== '1' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,12 @@ class CreditCardGatewayTest extends TestCase
|
|||
$wc_order = Mockery::mock(WC_Order::class);
|
||||
when('wc_get_order')->justReturn($wc_order);
|
||||
|
||||
$woocommerce = Mockery::mock(\WooCommerce::class);
|
||||
$session = Mockery::mock(\WC_Session::class);
|
||||
when('WC')->justReturn($woocommerce);
|
||||
$woocommerce->session = $session;
|
||||
$session->shouldReceive('set')->andReturn([]);
|
||||
|
||||
$this->orderProcessor->shouldReceive('process')
|
||||
->with($wc_order)
|
||||
->andReturn(true);
|
||||
|
@ -95,6 +101,12 @@ class CreditCardGatewayTest extends TestCase
|
|||
$wc_order->shouldReceive('get_customer_id')->andReturn(1);
|
||||
when('wc_get_order')->justReturn($wc_order);
|
||||
|
||||
$woocommerce = Mockery::mock(\WooCommerce::class);
|
||||
$session = Mockery::mock(\WC_Session::class);
|
||||
when('WC')->justReturn($woocommerce);
|
||||
$woocommerce->session = $session;
|
||||
$session->shouldReceive('set')->andReturn([]);
|
||||
|
||||
$savedCreditCard = 'abc123';
|
||||
$_POST['saved_credit_card'] = $savedCreditCard;
|
||||
|
||||
|
|
|
@ -147,9 +147,11 @@ class WcGatewayTest extends TestCase
|
|||
when('WC')->justReturn($woocommerce);
|
||||
$woocommerce->cart = $cart;
|
||||
$cart->shouldReceive('empty_cart');
|
||||
|
||||
$session = Mockery::mock(\WC_Session::class);
|
||||
$woocommerce->session = $session;
|
||||
$session->shouldReceive('get');
|
||||
$session->shouldReceive('set');
|
||||
|
||||
$result = $testee->process_payment($orderId);
|
||||
|
||||
|
@ -164,6 +166,12 @@ class WcGatewayTest extends TestCase
|
|||
|
||||
$testee = $this->createGateway();
|
||||
|
||||
$woocommerce = Mockery::mock(\WooCommerce::class);
|
||||
$session = Mockery::mock(\WC_Session::class);
|
||||
when('WC')->justReturn($woocommerce);
|
||||
$woocommerce->session = $session;
|
||||
$session->shouldReceive('set')->andReturn([]);
|
||||
|
||||
expect('wc_get_order')
|
||||
->with($orderId)
|
||||
->andReturn(false);
|
||||
|
@ -227,6 +235,7 @@ class WcGatewayTest extends TestCase
|
|||
$session = Mockery::mock(\WC_Session::class);
|
||||
$woocommerce->session = $session;
|
||||
$session->shouldReceive('get');
|
||||
$session->shouldReceive('set');
|
||||
|
||||
$result = $testee->process_payment($orderId);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue