Merge branch 'trunk' into PCP-4254-mexico-installments-new-ux-updates-todos-features-part-2

This commit is contained in:
Emili Castells Guasch 2025-05-26 16:16:49 +02:00
commit 9b4476a5dc
No known key found for this signature in database
8 changed files with 75 additions and 29 deletions

View file

@ -24,6 +24,8 @@
* Fix - BCDC not enabled by default when cards selected during onboarding #3366
* Fix - Block checkout - Address form missing after payment on Product and Cart pages #3371
* Fix - Payments with Debit & Credit Cards failing #3376
* Fix - PayPalGateway::process_payment on completed order leads to order failure #3374
* Fix - Can not save payments if subscriptions is not selected when onboarding #3408
= 3.0.5 - 2025-04-23 =
* Fix - Onboarding screen blank when WooPayments plugin is active #3312

View file

@ -55,9 +55,11 @@ class PartnerReferralsData {
* @return array
*/
public function data( array $products = array(), string $onboarding_token = '', bool $use_subscriptions = null, bool $use_card_payments = true ) : array {
$in_acdc_country = $this->dcc_applies->for_country_currency();
if ( ! $products ) {
$products = array(
$this->dcc_applies->for_country_currency() ? 'PPCP' : 'EXPRESS_CHECKOUT',
$in_acdc_country ? 'PPCP' : 'EXPRESS_CHECKOUT',
);
}
@ -87,14 +89,12 @@ class PartnerReferralsData {
'TRACKING_SHIPMENT_READWRITE',
);
if ( true === $use_subscriptions ) {
if ( $this->dcc_applies->for_country_currency() ) {
$capabilities[] = 'PAYPAL_WALLET_VAULTING_ADVANCED';
}
$first_party_features[] = 'BILLING_AGREEMENT';
if ( $in_acdc_country ) {
$capabilities[] = 'PAYPAL_WALLET_VAULTING_ADVANCED';
}
$first_party_features[] = 'BILLING_AGREEMENT';
// Backwards compatibility. Keep those features in the #legacy-ui (null-value).
// Move this into the previous condition, once legacy code is removed.
if ( false !== $use_subscriptions ) {
@ -102,14 +102,6 @@ class PartnerReferralsData {
$first_party_features[] = 'VAULT';
}
if ( false === $use_subscriptions ) {
// Only use "ADVANCED_VAULTING" product for onboarding with subscriptions.
$products = array_filter(
$products,
static fn( $product ) => $product !== 'ADVANCED_VAULTING'
);
}
$payload = array(
'partner_config_override' => array(
'return_url' => $return_url,

View file

@ -5,7 +5,7 @@
.ppcp-r-welcome-docs__title {
text-align: center;
@include font(20, 28, 700);
margin: 32px 0 32px 0;
margin: 32px 0 32px 0 !important;
}
.ppcp-r-welcome-docs__wrapper {

View file

@ -2,6 +2,12 @@ body:has(.ppcp-r-container--settings),
body:has(.ppcp-r-container--onboarding) {
background-color: var(--ppcp-color-app-bg) !important;
// WC 9.9+.
#mainform,
#wpcontent {
background-color: var(--ppcp-color-app-bg) !important;
}
.woocommerce-layout,
#woocommerce-layout__primary {
padding: 0 !important;

View file

@ -228,6 +228,13 @@ class OrderProcessor {
}
}
// Do not continue if PayPal order status is completed.
$order = $this->order_endpoint->order( $order->id() );
if ( $order->status()->is( OrderStatus::COMPLETED ) ) {
$this->logger->warning( 'Could not process PayPal completed order #' . $order->id() . ', Status: ' . $order->status()->name() );
return;
}
$this->add_paypal_meta( $wc_order, $order, $this->environment );
if ( $this->order_helper->contains_physical_goods( $order ) && ! $this->order_is_ready_for_process( $order ) ) {

View file

@ -180,6 +180,8 @@ If you encounter issues with the PayPal buttons not appearing after an update, p
* Fix - BCDC not enabled by default when cards selected during onboarding #3366
* Fix - Block checkout - Address form missing after payment on Product and Cart pages #3371
* Fix - Payments with Debit & Credit Cards failing #3376
* Fix - PayPalGateway::process_payment on completed order leads to order failure #3374
* Fix - Can not save payments if subscriptions is not selected when onboarding #3408
= 3.0.5 - 2025-04-23 =
* Fix - Onboarding screen blank when WooPayments plugin is active #3312

View file

@ -97,11 +97,12 @@ class PartnerReferralsDataTest extends TestCase {
/**
* Data provider for testing flag combinations.
*
* @return array[] Test cases with [has_subscriptions, has_cards, is_acdc_eligible, expected_changes]
* @return array[] Test cases with [has_subscriptions, has_cards, is_acdc_eligible,
* expected_changes]
*/
public function flagCombinationsProvider() : array {
return [
'with subscriptions and cards, ACDC eligible' => [
'with subscriptions and cards, ACDC eligible' => [
true, // With subscription?
true, // With cards?
true, // ACDC eligible?
@ -111,7 +112,7 @@ class PartnerReferralsDataTest extends TestCase {
'has_vault_features' => true,
],
],
'with subscriptions, no cards, ACDC eligible' => [
'with subscriptions, no cards, ACDC eligible' => [
true, // With subscription?
false, // With cards?
true, // ACDC eligible?
@ -121,20 +122,22 @@ class PartnerReferralsDataTest extends TestCase {
'has_vault_features' => true,
],
],
'no subscriptions, with cards, ACDC eligible' => [
'no subscriptions, with cards, ACDC eligible' => [
false, // With subscription?
true, // With cards?
true, // ACDC eligible?
[
'capabilities' => [ 'PAYPAL_WALLET_VAULTING_ADVANCED' ],
'show_add_credit_card' => true,
'has_vault_features' => false,
],
],
'no subscriptions, no cards, ACDC eligible' => [
'no subscriptions, no cards, ACDC eligible' => [
false, // With subscription?
false, // With cards?
true, // ACDC eligible?
[
'capabilities' => [ 'PAYPAL_WALLET_VAULTING_ADVANCED' ],
'show_add_credit_card' => false,
'has_vault_features' => false,
],
@ -166,7 +169,7 @@ class PartnerReferralsDataTest extends TestCase {
'has_vault_features' => false,
],
],
'no subscriptions, no cards, ACDC is not eligible' => [
'no subscriptions, no cards, ACDC is not eligible' => [
false, // With subscription?
false, // With cards?
false, // ACDC eligible?
@ -206,20 +209,23 @@ class PartnerReferralsDataTest extends TestCase {
* core params present in the legacy and new UI.
*/
public function testDataStructure() : void {
$this->dccApplies->shouldReceive( 'for_country_currency' )->andReturn( true );
/**
* Undefined subscription: Keep vaulting in first-party, but don't add the capability.
*/
$result = $this->testee->data( [ 'PPCP' ], self::TOKEN );
$this->dccApplies->shouldNotHaveReceived( 'for_country_currency' );
$expected = $this->getBaseExpectedArray();
$expected['products'] = [ 'PPCP' ];
$expected['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['features'][] = 'BILLING_AGREEMENT';
$expected['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['features'][] = 'FUTURE_PAYMENT';
$expected['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['features'][] = 'VAULT';
$this->assertArrayNotHasKey( 'capabilities', $expected );
$expected['capabilities'][] = 'PAYPAL_WALLET_VAULTING_ADVANCED';
$this->assertEquals( $expected, $result );
}
@ -230,7 +236,7 @@ class PartnerReferralsDataTest extends TestCase {
* @dataProvider flagCombinationsProvider
*/
public function testDataStructureWithFlags( bool $has_subscriptions, bool $has_cards, bool $is_acdc_eligible, array $expected_changes ) : void {
$this->dccApplies->shouldReceive('for_country_currency')->andReturn($is_acdc_eligible);
$this->dccApplies->shouldReceive( 'for_country_currency' )->andReturn( $is_acdc_eligible );
$result = $this->testee->data( [ 'PPCP' ], self::TOKEN, $has_subscriptions, $has_cards );
$expected = $this->getBaseExpectedArray();
@ -245,9 +251,7 @@ class PartnerReferralsDataTest extends TestCase {
$expected['partner_config_override']['show_add_credit_card'] = $expected_changes['show_add_credit_card'];
if ( $has_subscriptions ) {
$expected['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['features'][] = 'BILLING_AGREEMENT';
}
$expected['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['features'][] = 'BILLING_AGREEMENT';
if ( $expected_changes['has_vault_features'] ) {
$expected['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['features'][] = 'FUTURE_PAYMENT';

View file

@ -73,7 +73,11 @@ class OrderProcessorTest extends TestCase
$orderStatus
->shouldReceive('is')
->with(OrderStatus::COMPLETED)
->andReturn(true);
->andReturn(false);
$orderStatus
->shouldReceive('is')
->with(OrderStatus::COMPLETED)
->andReturn(true);
$orderId = 'abc';
$orderIntent = 'AUTHORIZE';
@ -82,6 +86,9 @@ class OrderProcessorTest extends TestCase
$currentOrder
->expects('id')
->andReturn($orderId);
$currentOrder
->expects('id')
->andReturn($orderId);
$currentOrder
->shouldReceive('intent')
->andReturn($orderIntent);
@ -106,6 +113,9 @@ class OrderProcessorTest extends TestCase
->andReturn($currentOrder);
$orderEndpoint = Mockery::mock(OrderEndpoint::class);
$orderEndpoint->shouldReceive('order')->andReturn($currentOrder);
$orderEndpoint
->expects('patch_order_with')
->with($currentOrder, $currentOrder)
@ -209,6 +219,10 @@ class OrderProcessorTest extends TestCase
->shouldReceive('is')
->with(OrderStatus::APPROVED)
->andReturn(true);
$orderStatus
->shouldReceive('is')
->with(OrderStatus::COMPLETED)
->andReturn(false);
$orderStatus
->shouldReceive('is')
->with(OrderStatus::COMPLETED)
@ -219,6 +233,9 @@ class OrderProcessorTest extends TestCase
$currentOrder
->expects('id')
->andReturn($orderId);
$currentOrder
->expects('id')
->andReturn($orderId);
$currentOrder
->shouldReceive('intent')
->andReturn($orderIntent);
@ -242,7 +259,11 @@ class OrderProcessorTest extends TestCase
$sessionHandler
->expects('order')
->andReturn($currentOrder);
$orderEndpoint = Mockery::mock(OrderEndpoint::class);
$orderEndpoint->shouldReceive('order')->andReturn($currentOrder);
$orderEndpoint
->expects('patch_order_with')
->with($currentOrder, $currentOrder)
@ -327,12 +348,18 @@ class OrderProcessorTest extends TestCase
->andReturn($payments);
$wcOrder = Mockery::mock(\WC_Order::class);
$wcOrder->expects('update_meta_data')
->with(PayPalGateway::ORDER_PAYMENT_MODE_META_KEY, 'live');
$wcOrder->shouldReceive('set_transaction_id')
->with($transactionId);
$orderStatus = Mockery::mock(OrderStatus::class);
$orderStatus
->shouldReceive('is')
->with(OrderStatus::COMPLETED)
->andReturn(false);
$orderStatus
->expects('is')
->with(OrderStatus::APPROVED)
@ -347,6 +374,9 @@ class OrderProcessorTest extends TestCase
$currentOrder
->expects('id')
->andReturn($orderId);
$currentOrder
->expects('id')
->andReturn($orderId);
$currentOrder
->shouldReceive('intent')
->andReturn($orderIntent);
@ -370,7 +400,10 @@ class OrderProcessorTest extends TestCase
$sessionHandler
->expects('order')
->andReturn($currentOrder);
$orderEndpoint = Mockery::mock(OrderEndpoint::class);
$orderEndpoint->shouldReceive('order')->andReturn($currentOrder);
$orderFactory = Mockery::mock(OrderFactory::class);
$threeDSecure = Mockery::mock(ThreeDSecure::class);
$authorizedPaymentProcessor = Mockery::mock(AuthorizedPaymentsProcessor::class);