Skip to content

Commit 0f661b7

Browse files
authored
Merge pull request #3754 from woocommerce/PCP-5425-disable-sssc-when-pay-now-disabled
Do not use SSSC when Pay Now Experience is disabled
2 parents e7ab0c0 + 9a1c04d commit 0f661b7

File tree

16 files changed

+282
-196
lines changed

16 files changed

+282
-196
lines changed

modules/ppcp-button/src/Endpoint/CreateOrderEndpoint.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ private function create_paypal_order( ?WC_Order $wc_order = null, string $paymen
523523
->with_custom_return_url( $return_url )
524524
->with_custom_cancel_url( $return_url );
525525

526-
if ( $this->server_side_shipping_callback_enabled
526+
if ( $this->should_handle_shipping_in_paypal( $funding_source )
527+
&& $this->server_side_shipping_callback_enabled
527528
&& $shipping_preference === ExperienceContext::SHIPPING_PREFERENCE_GET_FROM_FILE ) {
528529
$experience_context = $experience_context->with_shipping_callback();
529530
}

modules/ppcp-settings/resources/js/Components/Screens/Settings/Components/Settings/Blocks/Troubleshooting.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ const Troubleshooting = () => {
2424
<SettingsBlock>
2525
<ControlToggleButton
2626
label={ __( 'Logging', 'woocommerce-paypal-payments' ) }
27-
description={ __(
28-
'Log additional debugging information in the WooCommerce logs that can assist technical staff to determine issues.',
29-
'woocommerce-paypal-payments'
27+
description={ sprintf(
28+
__(
29+
'Log additional debugging information in the WooCommerce logs that can assist technical staff to determine issues. <a href="%s" target="_blank" rel="noopener noreferrer">View logs</a>.',
30+
'woocommerce-paypal-payments'
31+
),
32+
'admin.php?page=wc-status&tab=logs'
3033
) }
3134
value={ logging }
3235
onChange={ setLogging }

tests/qa-legacy-ui/.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
playwright-utils/
3+
playwright-report/
4+
storage-states/
5+
test-results/

tests/qa-legacy-ui/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.vscode
33
node_modules
44
playwright-utils
5-
playwright-report
5+
playwright-report*
66
playwright/.cache
77
storage-states
88
test-results

tests/qa-legacy-ui/resources/pcp-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const standardPaymentsDefault: PcpSettings.StandardPayments = {
1616
};
1717

1818
export const pcpConfigDefault: PcpConfig = {
19-
clearPCPDB: false, // clear PCP DB
19+
clearPCPDB: true, // clear PCP DB
2020
merchant: merchants[ country ],
2121
standardPayments: standardPaymentsDefault,
2222
};

tests/qa-legacy-ui/tests/03-plugin-settings/connection.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ test.describe( 'Сonnection', () => {
1414
connection,
1515
} ) => {
1616
await connection.visit();
17-
await connection.disconnectMerchant();
18-
17+
const disconnectButton = connection.disconnectAccountButton();
18+
await expect( disconnectButton ).toBeVisible();
19+
await disconnectButton.click();
20+
await expect ( connection.page ).toHaveURL( connection.url );
1921
await expect(
2022
connection.toggleToManualCredentialInputButton()
2123
).toBeVisible();

tests/qa-legacy-ui/utils/admin/connection.ts

Lines changed: 40 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import urls from '../urls';
88
*/
99
import { PcpMerchant } from '../../resources';
1010
import { generateRandomString } from '../helpers';
11+
import { expect } from 'playwright/test';
1112

1213
export class Connection extends PcpSettingsPage {
1314
url = urls.pcp.connection;
@@ -36,13 +37,11 @@ export class Connection extends PcpSettingsPage {
3637
name: 'Test payments with PayPal sandbox',
3738
} );
3839
toggleToManualCredentialInputButton = () =>
39-
this.page.getByRole( 'button', {
40-
name: 'Toggle to manual credential input',
41-
} );
40+
this.page.locator( 'button[id="ppcp[toggle_manual_input]"]' );
4241
documentationLink = () =>
4342
this.page.getByRole( 'link', { name: 'documentation', exact: true } );
4443

45-
sandboxCheckbox = () => this.page.getByLabel( 'Sandbox', { exact: true } );
44+
sandboxCheckbox = () => this.page.locator( '#ppcp-sandbox_on' );
4645

4746
liveEmailAddressInput = () => this.page.getByLabel( 'Live Email address' );
4847
liveMerchantIdInput = () => this.page.getByLabel( 'Live Merchant Id' );
@@ -51,12 +50,13 @@ export class Connection extends PcpSettingsPage {
5150
this.page.locator( 'input[name="ppcp\\[client_secret_production\\]"]' );
5251

5352
sandboxEmailAddressInput = () =>
54-
this.page.getByLabel( 'Sandbox Email address' );
53+
this.page.locator( '#ppcp-merchant_email_sandbox' );
5554
sandboxMerchantIdInput = () =>
56-
this.page.getByLabel( 'Sandbox Merchant Id' );
57-
sandboxClientIdInput = () => this.page.getByLabel( 'Sandbox Client Id' );
55+
this.page.locator( '#ppcp-merchant_id_sandbox' );
56+
sandboxClientIdInput = () =>
57+
this.page.locator( '#ppcp-client_id_sandbox' );
5858
sandboxSecretKeyInput = () =>
59-
this.page.locator( 'input[name="ppcp\\[client_secret_sandbox\\]"]' );
59+
this.page.locator( 'input[name="ppcp[client_secret_sandbox]"]' );
6060

6161
statusConnected = () => this.page.getByText( 'Status: Connected' );
6262
disconnectAccountButton = () =>
@@ -101,43 +101,6 @@ export class Connection extends PcpSettingsPage {
101101
await this.saveChanges();
102102
};
103103

104-
/**
105-
* Checks if merchant is connected
106-
*
107-
* @param data
108-
*/
109-
isMerchantConnected = async ( data? ) => {
110-
if ( ! ( await this.disconnectAccountButton().isVisible() ) ) {
111-
return false;
112-
}
113-
114-
const emailInput = this.sandboxEmailAddressInput();
115-
const merchantIdInput = this.sandboxMerchantIdInput();
116-
const clientIdInput = this.sandboxClientIdInput();
117-
const secretKeyInput = this.sandboxSecretKeyInput();
118-
119-
const emailInputValue = ( await emailInput.inputValue() ).trim();
120-
const merchantIdValue = ( await merchantIdInput.inputValue() ).trim();
121-
const clientIdValue = ( await clientIdInput.inputValue() ).trim();
122-
const secretKeyValue = ( await secretKeyInput.inputValue() ).trim();
123-
124-
if ( ! data ) {
125-
return (
126-
emailInputValue !== '' &&
127-
merchantIdValue !== '' &&
128-
clientIdValue !== '' &&
129-
secretKeyValue !== ''
130-
);
131-
}
132-
133-
return (
134-
emailInputValue === data.email &&
135-
merchantIdValue === data.account_id &&
136-
clientIdValue === data.client_id &&
137-
secretKeyValue === data.client_secret
138-
);
139-
};
140-
141104
/**
142105
* Connects PayPal merchant with options
143106
*
@@ -150,23 +113,46 @@ export class Connection extends PcpSettingsPage {
150113
enablePayUponInvoice: false,
151114
}
152115
) => {
116+
await this.page.waitForLoadState();
153117
if ( options.enablePayUponInvoice ) {
154118
await this.onboardPayUponInvoiceCheckbox().check();
155119
} else if ( await this.onboardPayUponInvoiceCheckbox().isVisible() ) {
156120
await this.onboardPayUponInvoiceCheckbox().uncheck();
157121
}
158122

159-
await this.toggleToManualCredentialInputButton().click();
160-
await this.page.waitForTimeout( 500 );
161-
await this.sandboxCheckbox().check();
162-
await this.sandboxEmailAddressInput().fill( merchant.email );
163-
await this.sandboxMerchantIdInput().fill( merchant.account_id );
164-
await this.sandboxClientIdInput().fill( merchant.client_id );
165-
await this.sandboxSecretKeyInput().fill( merchant.client_secret );
166-
await this.saveChangesButton().click();
123+
const toggleToManualCredentialInputButton =
124+
this.toggleToManualCredentialInputButton();
125+
await expect( toggleToManualCredentialInputButton ).toBeVisible();
126+
await toggleToManualCredentialInputButton.click( { force: true } );
127+
128+
const sandboxCheckbox = this.sandboxCheckbox();
129+
await expect( sandboxCheckbox ).toBeVisible();
130+
await sandboxCheckbox.check({ force: true });
131+
await expect( this.sandboxCheckbox() ).toBeChecked();
132+
133+
const sandboxEmailAddressInput = this.sandboxEmailAddressInput();
134+
await expect( sandboxEmailAddressInput ).toBeVisible();
135+
await sandboxEmailAddressInput.fill( merchant.email );
136+
137+
const sandboxMerchantIdInput = this.sandboxMerchantIdInput();
138+
await expect( sandboxMerchantIdInput ).toBeVisible();
139+
await sandboxMerchantIdInput.fill( merchant.account_id );
140+
141+
const sandboxClientIdInput = this.sandboxClientIdInput();
142+
await expect( sandboxClientIdInput ).toBeVisible();
143+
await sandboxClientIdInput.fill( merchant.client_id );
144+
145+
const sandboxSecretKeyInput = this.sandboxSecretKeyInput();
146+
await expect( sandboxSecretKeyInput ).toBeVisible();
147+
await sandboxSecretKeyInput.fill( merchant.client_secret );
148+
149+
const saveChangesButton = this.saveChangesButton();
150+
await expect( saveChangesButton ).toBeVisible();
151+
await saveChangesButton.click();
167152
await this.page.waitForLoadState();
168153
// make sure Connection page has been loaded:
169-
await this.disconnectAccountButton().waitFor( { state: 'visible' } );
154+
155+
await expect( this.disconnectAccountButton() ).toBeVisible();
170156
await this.updateInvoicePrefix();
171157
};
172158

@@ -177,31 +163,5 @@ export class Connection extends PcpSettingsPage {
177163
await this.saveChanges();
178164
};
179165

180-
/**
181-
* Disconnects PayPal merchant
182-
*/
183-
disconnectMerchant = async () => {
184-
const disconnectButton = this.disconnectAccountButton();
185-
186-
if ( await disconnectButton.isVisible() ) {
187-
await disconnectButton.click();
188-
}
189-
await this.page.waitForLoadState();
190-
// make sure Account Setup page has been loaded:
191-
await this.toggleToManualCredentialInputButton().waitFor( {
192-
state: 'visible',
193-
} );
194-
};
195-
196-
clearDB = async () => {
197-
this.page.on( 'dialog', ( dialog ) => dialog.accept() );
198-
await this.clearNowButton().click();
199-
await this.page.waitForLoadState();
200-
// make sure Account Setup page has been loaded:
201-
await this.toggleToManualCredentialInputButton().waitFor( {
202-
state: 'visible',
203-
} );
204-
};
205-
206166
// Assertions
207167
}

tests/qa-legacy-ui/utils/frontend/paypal-ui.ts

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -719,46 +719,47 @@ export class PayPalUI {
719719
await this.debitOrCreditCardPayNowButton().click();
720720
await this.page.waitForTimeout( 2500 );
721721

722-
const firstName = this.debitOrCreditCardFirstNameInput();
723-
if ( await firstName.isVisible() ) {
724-
await firstName.fill( customer.first_name );
725-
}
726-
const lastName = this.debitOrCreditCardLastNameInput();
727-
if ( await lastName.isVisible() ) {
728-
await lastName.fill( customer.last_name );
729-
}
730-
const street = this.debitOrCreditCardStreetInput();
731-
if ( await street.isVisible() ) {
732-
await street.fill( customer.billing.address_1 );
733-
}
734-
const apartment = this.debitOrCreditCardApartmentInput();
735-
if ( await apartment.isVisible() ) {
736-
await apartment.fill( customer.billing.address_2 );
737-
}
738-
const city = this.debitOrCreditCardCityInput();
739-
if ( await city.isVisible() ) {
740-
await city.fill( customer.billing.city );
741-
}
742-
const state = this.debitOrCreditCardStateInput();
743-
if ( await state.isVisible() ) {
744-
await state.fill( customer.billing.state );
745-
}
746-
const postcode = this.debitOrCreditCardZipCodeInput();
747-
if ( await postcode.isVisible() ) {
748-
await postcode.fill( customer.billing.postcode );
749-
}
750-
const phone = this.debitOrCreditCardPhoneInput();
751-
if ( await phone.isVisible() ) {
752-
await phone.fill( customer.billing.phone );
753-
}
754-
const email = this.debitOrCreditCardEmailInput();
755-
if ( await email.isVisible() ) {
756-
await email.fill( customer.billing.email );
757-
}
758-
const payNow = this.debitOrCreditCardPayNowButton();
759-
if ( await payNow.isVisible() ) {
760-
await payNow.click();
761-
}
722+
// Commented by MUtkin on 30-09-2025 due to changed UI behavior by PayPal
723+
// const firstName = this.debitOrCreditCardFirstNameInput();
724+
// if ( await firstName.isVisible() ) {
725+
// await firstName.fill( customer.first_name );
726+
// }
727+
// const lastName = this.debitOrCreditCardLastNameInput();
728+
// if ( await lastName.isVisible() ) {
729+
// await lastName.fill( customer.last_name );
730+
// }
731+
// const street = this.debitOrCreditCardStreetInput();
732+
// if ( await street.isVisible() ) {
733+
// await street.fill( customer.billing.address_1 );
734+
// }
735+
// const apartment = this.debitOrCreditCardApartmentInput();
736+
// if ( await apartment.isVisible() ) {
737+
// await apartment.fill( customer.billing.address_2 );
738+
// }
739+
// const city = this.debitOrCreditCardCityInput();
740+
// if ( await city.isVisible() ) {
741+
// await city.fill( customer.billing.city );
742+
// }
743+
// const state = this.debitOrCreditCardStateInput();
744+
// if ( await state.isVisible() ) {
745+
// await state.fill( customer.billing.state );
746+
// }
747+
// const postcode = this.debitOrCreditCardZipCodeInput();
748+
// if ( await postcode.isVisible() ) {
749+
// await postcode.fill( customer.billing.postcode );
750+
// }
751+
// const phone = this.debitOrCreditCardPhoneInput();
752+
// if ( await phone.isVisible() ) {
753+
// await phone.fill( customer.billing.phone );
754+
// }
755+
// const email = this.debitOrCreditCardEmailInput();
756+
// if ( await email.isVisible() ) {
757+
// await email.fill( customer.billing.email );
758+
// }
759+
// const payNow = this.debitOrCreditCardPayNowButton();
760+
// if ( await payNow.isVisible() ) {
761+
// await payNow.click();
762+
// }
762763
};
763764

764765
/**

0 commit comments

Comments
 (0)