Skip to content

Commit

Permalink
Merge branch 'develop' into add/new-process-payment-exception
Browse files Browse the repository at this point in the history
  • Loading branch information
hsingyuc committed May 24, 2024
2 parents ff13605 + 7e80354 commit e7a457f
Show file tree
Hide file tree
Showing 40 changed files with 315 additions and 232 deletions.
4 changes: 4 additions & 0 deletions changelog/dev-bump-wc-tested-up-to-8.9.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Bump tested up to version for WP to 6.5 and WC to 8.9.1.
4 changes: 4 additions & 0 deletions changelog/fix-8416-klarna-e2e-tests-final
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Fix Klarna E2E tests.
5 changes: 5 additions & 0 deletions changelog/fix-8804-source-identifier-spacing
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Small visual change to transactions list.


5 changes: 5 additions & 0 deletions changelog/fix-rule-exclusion
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: PHPCS rules only


4 changes: 4 additions & 0 deletions changelog/fix-settings-notices-consistency
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

fix: settings notices consistency
4 changes: 4 additions & 0 deletions changelog/fix-store-api-tokenized-cart-nonce-verification
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

fix: Store API tokenized cart nonce verification
4 changes: 4 additions & 0 deletions changelog/try-add-woo-share-key-stripe
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: add

Add share key query param when sending data to Stripe KYC
5 changes: 5 additions & 0 deletions client/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ declare global {
woocommerce_default_country: string;
};
};
siteVisibilitySettings: {
woocommerce_share_key: string;
woocommerce_coming_soon: string;
woocommerce_private_link: string;
};
};
adminUrl: string;
countries: Record< string, string >;
Expand Down
16 changes: 15 additions & 1 deletion client/onboarding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,27 @@ const OnboardingStepper = () => {
);
};

const getComingSoonShareKey = () => {
const {
woocommerce_share_key: shareKey,
woocommerce_coming_soon: comingSoon,
woocommerce_private_link: privateLink,
} = wcSettings?.admin?.siteVisibilitySettings || {};

if ( comingSoon !== 'yes' || privateLink === 'no' ) {
return '';
}

return shareKey ? '?woo-share=' + shareKey : '';
};

const initialData = {
business_name: wcSettings?.siteTitle,
mcc: getMccFromIndustry(),
url:
location.hostname === 'localhost'
? 'https://wcpay.test'
: wcSettings?.homeUrl,
: wcSettings?.homeUrl + getComingSoonShareKey(),
country: wcpaySettings?.connect?.country,
};

Expand Down
6 changes: 0 additions & 6 deletions client/settings/express-checkout-settings/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,6 @@
}
}

.express-checkout__notice {
margin-left: 0;
margin-right: 0;
border: 0;
}

.payment-method-settings {
&__option-help-text {
color: #757575;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ describe( 'PaymentRequestSettings', () => {

expect(
screen.queryByText(
'One or more of your extensions alters checkout fields. This might cause issues with this payment method.'
'Your custom checkout fields may not be compatible with these payment methods.'
)
).toBeInTheDocument();
} );
Expand All @@ -276,7 +276,7 @@ describe( 'PaymentRequestSettings', () => {

expect(
screen.queryByText(
'One or more of your extensions alters checkout fields. This might cause issues with this payment method.'
'Your custom checkout fields may not be compatible with these payment methods.'
)
).not.toBeInTheDocument();
} );
Expand Down
6 changes: 0 additions & 6 deletions client/settings/express-checkout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
padding: 24px;
background: #fff;

.gridicons-notice-outline {
fill: #f0b849;
margin-bottom: -5px;
margin-right: 16px;
}

&__label-container {
display: flex;
flex-wrap: wrap;
Expand Down
2 changes: 1 addition & 1 deletion client/settings/express-checkout/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ describe( 'ExpressCheckout', () => {

expect(
screen.queryByText(
'One or more of your extensions alters checkout fields. This might cause issues with this payment method.'
'Your custom checkout fields may not be compatible with these payment methods.'
)
).toBeInTheDocument();
} );
Expand Down
60 changes: 21 additions & 39 deletions client/settings/settings-warnings/incompatibility-notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,30 @@ import interpolateComponents from '@automattic/interpolate-components';
/**
* Internal dependencies
*/
import { Notice } from '@wordpress/components';
import NoticeOutlineIcon from 'gridicons/dist/notice-outline';
import './style.scss';
import InlineNotice from 'wcpay/components/inline-notice';

const IncompatibilityNotice = ( { message, learnMoreLinkHref } ) => (
<Notice
status="warning"
isDismissible={ false }
className="express-checkout__notice express-checkout__incompatibility-warning"
>
<span>
<NoticeOutlineIcon
style={ {
color: '#F0B849',
fill: 'currentColor',
marginBottom: '-5px',
marginRight: '10px',
} }
size={ 20 }
/>
</span>
<span>
{ message }
<br />
{ interpolateComponents( {
mixedString: __(
'{{learnMoreLink}}Learn More{{/learnMoreLink}}',
'woocommerce-payments'
<InlineNotice status="warning" icon={ true } isDismissible={ false }>
{ message }
<br />
{ interpolateComponents( {
mixedString: __(
'{{learnMoreLink}}Learn More{{/learnMoreLink}}',
'woocommerce-payments'
),
components: {
learnMoreLink: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
<a
target="_blank"
rel="noreferrer"
href={ learnMoreLinkHref }
/>
),
components: {
learnMoreLink: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
<a
target="_blank"
rel="noreferrer"
href={ learnMoreLinkHref }
/>
),
},
} ) }
</span>
</Notice>
},
} ) }
</InlineNotice>
);

export const WooPayIncompatibilityNotice = () => (
Expand All @@ -64,7 +46,7 @@ export const WooPayIncompatibilityNotice = () => (
export const ExpressCheckoutIncompatibilityNotice = () => (
<IncompatibilityNotice
message={ __(
'One or more of your extensions alters checkout fields. This might cause issues with this payment method.',
'Your custom checkout fields may not be compatible with these payment methods.',
'woocommerce-payments'
) }
// eslint-disable-next-line max-len
Expand Down
3 changes: 3 additions & 0 deletions client/tokenized-payment-request/cart-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export default class PaymentRequestCartApi {

this.cartRequestHeaders = {
Nonce: response.headers.get( 'Nonce' ),
// this header will be overwritten by a filter in the backend to overcome nonce overwrites in this middleware:
// https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce-blocks/assets/js/middleware/store-api-nonce.js
'X-WooPayments-Store-Api-Nonce': response.headers.get( 'Nonce' ),
'Cart-Token': response.headers.get( 'Cart-Token' ),
'X-WooPayments-Express-Payment-Request-Nonce': response.headers.get(
'X-WooPayments-Express-Payment-Request-Nonce'
Expand Down
3 changes: 2 additions & 1 deletion client/transactions/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ const getPaymentSourceDetails = ( txn: Transaction ) => {

switch ( txn.source ) {
case 'giropay':
return <Fragment>{ txn.source_identifier }</Fragment>;
return <Fragment>&nbsp;&nbsp;{ txn.source_identifier }</Fragment>;
case 'p24':
return (
<Fragment>
&nbsp;&nbsp;
{ p24BankList[ txn.source_identifier ] ?? '' }
</Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This sniff prohibits the use of add_action and add_filter in __construct.
*/

namespace WCPay\CodingStandards\Sniffs;
namespace WCPay\Sniffs\Hooks;

use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Files\File;
Expand Down Expand Up @@ -60,7 +60,7 @@ public function process( File $phpcsFile, $stackPtr ) {
$phpcsFile->addError(
"Usage of $currentTokenContent in __construct() is not allowed",
$i,
'WCPay.CodingStandards.DisallowHooksInConstructor',
'Found',
[ $token['content'] ]
);
}
Expand Down
27 changes: 27 additions & 0 deletions dev/phpcs/WCPay/ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<ruleset name="WCPay">
<description>WCPay custom coding standards.</description>

<rule ref="WCPay.Hooks.DisallowHooksInConstructor">
<!-- https://github.com/Automattic/woocommerce-payments/issues/7259 -->
<exclude-pattern>*/includes/subscriptions/*</exclude-pattern>
<exclude-pattern>*/includes/compat/subscriptions/*</exclude-pattern>

<!-- https://github.com/Automattic/woocommerce-payments/issues/7266 -->
<exclude-pattern>*/includes/emails/*</exclude-pattern>

<!-- https://github.com/Automattic/woocommerce-payments/issues/7260 -->
<exclude-pattern>*/includes/class-woopay-tracker.php</exclude-pattern>
<exclude-pattern>*/includes/woopay/*</exclude-pattern>
<exclude-pattern>*/includes/woopay-user/*</exclude-pattern>

<exclude-pattern>*/includes/class-wc-payments-order-success-page.php</exclude-pattern>

<!-- https://github.com/Automattic/woocommerce-payments/issues/7264 -->
<exclude-pattern>*/includes/class-wc-payments-customer-service.php</exclude-pattern>
<exclude-pattern>*/includes/class-wc-payments-token-service.php</exclude-pattern>

<!-- https://github.com/Automattic/woocommerce-payments/issues/7265 -->
<exclude-pattern>*/includes/class-wc-payments-webhook-reliability-service.php</exclude-pattern>
</rule>
</ruleset>
24 changes: 0 additions & 24 deletions dev/phpcs/ruleset.xml

This file was deleted.

35 changes: 18 additions & 17 deletions includes/class-wc-payments-customer-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ class WC_Payments_Customer_Service {
* Class constructor
*
* @param WC_Payments_API_Client $payments_api_client Payments API client.
* @param WC_Payments_Account $account WC_Payments_Account instance.
* @param Database_Cache $database_cache Database_Cache instance.
* @param WC_Payments_Session_Service $session_service Session Service class instance.
* @param WC_Payments_Account $account WC_Payments_Account instance.
* @param Database_Cache $database_cache Database_Cache instance.
* @param WC_Payments_Session_Service $session_service Session Service class instance.
* @param WC_Payments_Order_Service $order_service Order Service class instance.
*/
public function __construct(
WC_Payments_API_Client $payments_api_client,
Expand Down Expand Up @@ -177,12 +178,12 @@ public function create_customer_for_user( ?WP_User $user, array $customer_data =
*
* @return string WooPayments customer ID.
* @throws API_Exception Throws when server API request fails.
*/
*/
public function get_or_create_customer_id_from_order( ?int $user_id, WC_Order $order ): string {
// Determine the customer making the payment, create one if we don't have one already.
$customer_id = $this->get_customer_id_by_user_id( $user_id );
$customer_data = self::map_customer_data( $order, new WC_Customer( $user_id ?? 0 ) );
$user = null === $user_id ? null : get_user_by( 'id', $user_id );
$user = null === $user_id ? null : get_user_by( 'id', $user_id );

if ( null !== $customer_id ) {
$this->update_customer_for_user( $customer_id, $user, $customer_data );
Expand Down Expand Up @@ -526,19 +527,19 @@ public function get_prepared_customer_data() {
}

global $wp;
$user_email = '';
$firstname = '';
$lastname = '';
$user_email = '';
$firstname = '';
$lastname = '';
$billing_country = '';

if ( isset( $_GET['pay_for_order'] ) && 'true' === $_GET['pay_for_order'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$order_id = absint( $wp->query_vars['order-pay'] );
$order = wc_get_order( $order_id );

if ( is_a( $order, 'WC_Order' ) ) {
$firstname = $order->get_billing_first_name();
$lastname = $order->get_billing_last_name();
$user_email = $order->get_billing_email();
$firstname = $order->get_billing_first_name();
$lastname = $order->get_billing_last_name();
$user_email = $order->get_billing_email();
$billing_country = $order->get_billing_country();
}
}
Expand All @@ -547,17 +548,17 @@ public function get_prepared_customer_data() {
$user = wp_get_current_user();

if ( $user->ID ) {
$firstname = $user->user_firstname;
$lastname = $user->user_lastname;
$user_email = get_user_meta( $user->ID, 'billing_email', true );
$user_email = $user_email ?: $user->user_email;
$firstname = $user->user_firstname;
$lastname = $user->user_lastname;
$user_email = get_user_meta( $user->ID, 'billing_email', true );
$user_email = ! empty( $user_email ) ? $user_email : $user->user_email;
$billing_country = get_user_meta( $user->ID, 'billing_country', true );
}
}

return [
'name' => $firstname . ' ' . $lastname,
'email' => $user_email,
'name' => $firstname . ' ' . $lastname,
'email' => $user_email,
'billing_country' => $billing_country,
];
}
Expand Down
Loading

0 comments on commit e7a457f

Please sign in to comment.