Skip to content

Commit

Permalink
Merge branch 'develop' into fix/6782-support-phone-dev-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
htdat authored Dec 15, 2023
2 parents 5b12897 + b37d805 commit 37ee776
Show file tree
Hide file tree
Showing 15 changed files with 274 additions and 84 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-7301-descriptive-error-message-on-invalid-pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Improved error message for invalid payment method
4 changes: 4 additions & 0 deletions changelog/fix-7748-capture-notification-styles-are-broken
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fixed broken styles in authorization capture notifications
4 changes: 4 additions & 0 deletions changelog/remove-flag-usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Avoid using the removed deferred UPE flag
4 changes: 4 additions & 0 deletions changelog/update-4163-compatibility-service
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Adding Compatibility Service to assist with flagging possible compatibility issues in the future.
133 changes: 62 additions & 71 deletions client/payment-details/summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
*/
import { __ } from '@wordpress/i18n';
import { dateI18n } from '@wordpress/date';
import {
Card,
CardBody,
CardFooter,
CardDivider,
Flex,
} from '@wordpress/components';
import { Card, CardBody, CardDivider, Flex } from '@wordpress/components';
import moment from 'moment';
import React, { useContext } from 'react';
import { createInterpolateElement } from '@wordpress/element';
Expand Down Expand Up @@ -55,6 +49,7 @@ import MissingOrderNotice from 'wcpay/payment-details/summary/missing-order-noti
import DisputeAwaitingResponseDetails from '../dispute-details/dispute-awaiting-response-details';
import DisputeResolutionFooter from '../dispute-details/dispute-resolution-footer';
import ErrorBoundary from 'components/error-boundary';
import CardNotice from 'wcpay/components/card-notice';

declare const window: any;

Expand Down Expand Up @@ -508,73 +503,69 @@ const PaymentDetailsSummary: React.FC< PaymentDetailsSummaryProps > = ( {
authorization &&
! authorization.captured && (
<Loadable isLoading={ isLoading } placeholder="">
<CardFooter className="payment-details-capture-notice">
<div className="payment-details-capture-notice__section">
<div className="payment-details-capture-notice__text">
{ createInterpolateElement(
__(
'You must <a>capture</a> this charge within the next',
'woocommerce-payments'
),
{
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content, react/jsx-no-target-blank
<a
href="https://woo.com/document/woopayments/settings-guide/authorize-and-capture/#capturing-authorized-orders"
target="_blank"
rel="noreferer"
/>
),
<CardNotice
actions={
! isFraudOutcomeReview ? (
<CaptureAuthorizationButton
orderId={ charge.order?.number || 0 }
paymentIntentId={
charge.payment_intent || ''
}
) }{ ' ' }
<abbr
title={ dateI18n(
'M j, Y / g:iA',
moment
.utc( authorization.created )
.add( 7, 'days' ),
'UTC'
) }
>
<b>
{ moment
.utc( authorization.created )
.add( 7, 'days' )
.fromNow( true ) }
</b>
</abbr>
{ isFraudOutcomeReview &&
`. ${ __(
'Approving this transaction will capture the charge.',
'woocommerce-payments'
) }` }
</div>

{ ! isFraudOutcomeReview && (
<div className="payment-details-capture-notice__button">
<CaptureAuthorizationButton
orderId={
charge.order?.number || 0
}
paymentIntentId={
charge.payment_intent || ''
}
buttonIsPrimary={ true }
buttonIsSmall={ false }
onClick={ () => {
wcpayTracks.recordEvent(
'payments_transactions_details_capture_charge_button_click',
{
payment_intent_id:
charge.payment_intent,
}
);
} }
buttonIsPrimary={ true }
buttonIsSmall={ false }
onClick={ () => {
wcpayTracks.recordEvent(
'payments_transactions_details_capture_charge_button_click',
{
payment_intent_id:
charge.payment_intent,
}
);
} }
/>
) : (
<></>
)
}
>
{ createInterpolateElement(
__(
'You must <a>capture</a> this charge within the next',
'woocommerce-payments'
),
{
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content, react/jsx-no-target-blank
<a
href="https://woo.com/document/woopayments/settings-guide/authorize-and-capture/#capturing-authorized-orders"
target="_blank"
rel="noreferer"
/>
</div>
),
}
) }{ ' ' }
<abbr
title={ dateI18n(
'M j, Y / g:iA',
moment
.utc( authorization.created )
.add( 7, 'days' ),
'UTC'
) }
</div>
</CardFooter>
>
<b>
{ moment
.utc( authorization.created )
.add( 7, 'days' )
.fromNow( true ) }
</b>
</abbr>
{ isFraudOutcomeReview &&
`. ${ __(
'Approving this transaction will capture the charge.',
'woocommerce-payments'
) }` }
</CardNotice>
</Loadable>
) }
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ exports[`PaymentDetailsSummary capture notification and fraud buttons renders ca
</ul>
</div>
<div
class="components-flex components-card__footer components-card-footer payment-details-capture-notice css-p1v47q-View-Flex-sx-Base-sx-Items-ItemsRow-Footer-borderRadius-borderColor-medium em57xhy0"
class="components-flex components-card__footer components-card-footer card-notice css-p1v47q-View-Flex-sx-Base-sx-Items-ItemsRow-Footer-borderRadius-borderColor-medium em57xhy0"
data-wp-c16t="true"
data-wp-component="CardFooter"
>
<div
class="payment-details-capture-notice__section"
class="card-notice__section"
>
<div
class="payment-details-capture-notice__text"
class="card-notice__text"
>
You must
<a
Expand All @@ -273,7 +273,7 @@ exports[`PaymentDetailsSummary capture notification and fraud buttons renders ca
</abbr>
</div>
<div
class="payment-details-capture-notice__button"
class="card-notice__button"
>
<button
class="components-button is-primary"
Expand Down Expand Up @@ -561,15 +561,15 @@ exports[`PaymentDetailsSummary capture notification and fraud buttons renders th
</ul>
</div>
<div
class="components-flex components-card__footer components-card-footer payment-details-capture-notice css-p1v47q-View-Flex-sx-Base-sx-Items-ItemsRow-Footer-borderRadius-borderColor-medium em57xhy0"
class="components-flex components-card__footer components-card-footer card-notice css-p1v47q-View-Flex-sx-Base-sx-Items-ItemsRow-Footer-borderRadius-borderColor-medium em57xhy0"
data-wp-c16t="true"
data-wp-component="CardFooter"
>
<div
class="payment-details-capture-notice__section"
class="card-notice__section"
>
<div
class="payment-details-capture-notice__text"
class="card-notice__text"
>
You must
<a
Expand All @@ -590,6 +590,9 @@ exports[`PaymentDetailsSummary capture notification and fraud buttons renders th
</abbr>
. Approving this transaction will capture the charge.
</div>
<div
class="card-notice__button"
/>
</div>
</div>
</div>
Expand Down
61 changes: 61 additions & 0 deletions includes/class-compatibility-service.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* Compatibility_Service class
*
* @package WooCommerce\Payments
*/

namespace WCPay;

use WC_Payments_API_Client;
use WCPay\Exceptions\API_Exception;

defined( 'ABSPATH' ) || exit; // block direct access.

/**
* Class to send compatibility data to the server.
*/
class Compatibility_Service {
/**
* Client for making requests to the WooCommerce Payments API
*
* @var WC_Payments_API_Client
*/
private $payments_api_client;

/**
* Constructor for Compatibility_Service.
*
* @param WC_Payments_API_Client $payments_api_client WooCommerce Payments API client.
*/
public function __construct( WC_Payments_API_Client $payments_api_client ) {
$this->payments_api_client = $payments_api_client;
}

/**
* Initializes this class's WP hooks.
*
* @return void
*/
public function init_hooks() {
add_action( 'woocommerce_payments_account_refreshed', [ $this, 'update_compatibility_data' ] );
}

/**
* Gets the data we need to confirm compatibility and sends it to the server.
*
* @return void
*/
public function update_compatibility_data() {
try {
$this->payments_api_client->update_compatibility_data(
[
'woopayments_version' => WCPAY_VERSION_NUMBER,
'woocommerce_version' => WC_VERSION,
]
);
} catch ( API_Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
// The exception is already logged if logging is on, nothing else needed.
}
}
}
2 changes: 1 addition & 1 deletion includes/class-payment-information.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function __construct(
if ( empty( $payment_method ) && empty( $token ) && ! \WC_Payments::is_network_saved_cards_enabled() ) {
// If network-wide cards are enabled, a payment method or token may not be specified and the platform default one will be used.
throw new Invalid_Payment_Method_Exception(
__( 'Invalid payment method. Please input a new card number.', 'woocommerce-payments' ),
__( 'Invalid or missing payment details. Please ensure the provided payment method is correctly entered.', 'woocommerce-payments' ),
'payment_method_not_provided'
);
}
Expand Down
3 changes: 0 additions & 3 deletions includes/class-wc-payments-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -1476,9 +1476,6 @@ private function finalize_connection( $state, $mode ) {
// user might not have agreed to TOS yet.
update_option( '_wcpay_onboarding_stripe_connected', [ 'is_existing_stripe_account' => false ] );

// Automatically enable deferred intent UPE for new stores.
update_option( WC_Payments_Features::UPE_DEFERRED_INTENT_FLAG_NAME, '1' );

// Track account connection finish.
$incentive = ! empty( $_GET['promo'] ) ? sanitize_text_field( wp_unslash( $_GET['promo'] ) ) : '';
$progressive = ! empty( $_GET['progressive'] ) && 'true' === $_GET['progressive'];
Expand Down
11 changes: 11 additions & 0 deletions includes/class-wc-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use WCPay\Internal\Service\OrderService;
use WCPay\WooPay\WooPay_Scheduler;
use WCPay\WooPay\WooPay_Session;
use WCPay\Compatibility_Service;

/**
* Main class for the WooPayments extension. Its responsibility is to initialize the extension.
Expand Down Expand Up @@ -295,6 +296,13 @@ class WC_Payments {
*/
private static $incentives_service;

/**
* Instance of Compatibility_Service, created in init function
*
* @var Compatibility_Service
*/
private static $compatibility_service;

/**
* Entry point to the initialization logic.
*/
Expand Down Expand Up @@ -463,6 +471,7 @@ public static function init() {
include_once __DIR__ . '/core/service/class-wc-payments-customer-service-api.php';
include_once __DIR__ . '/class-duplicate-payment-prevention-service.php';
include_once __DIR__ . '/class-wc-payments-incentives-service.php';
include_once __DIR__ . '/class-compatibility-service.php';
include_once __DIR__ . '/multi-currency/wc-payments-multi-currency.php';

self::$woopay_checkout_service = new Checkout_Service();
Expand Down Expand Up @@ -497,6 +506,7 @@ public static function init() {
self::$woopay_tracker = new WooPay_Tracker( self::get_wc_payments_http() );
self::$incentives_service = new WC_Payments_Incentives_Service( self::$database_cache );
self::$duplicate_payment_prevention_service = new Duplicate_Payment_Prevention_Service();
self::$compatibility_service = new Compatibility_Service( self::$api_client );

( new WooPay_Scheduler( self::$api_client ) )->init();

Expand All @@ -505,6 +515,7 @@ public static function init() {
self::$fraud_service->init_hooks();
self::$onboarding_service->init_hooks();
self::$incentives_service->init_hooks();
self::$compatibility_service->init_hooks();

self::$legacy_card_gateway = new CC_Payment_Gateway( self::$api_client, self::$account, self::$customer_service, self::$token_service, self::$action_scheduler_service, self::$failed_transaction_rate_limiter, self::$order_service, self::$duplicate_payment_prevention_service, self::$localization_service, self::$fraud_service );

Expand Down
1 change: 1 addition & 0 deletions includes/core/server/class-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ abstract class Request {
WC_Payments_API_Client::AUTHORIZATIONS_API => 'authorizations',
WC_Payments_API_Client::FRAUD_OUTCOMES_API => 'fraud_outcomes',
WC_Payments_API_Client::FRAUD_RULESET_API => 'fraud_ruleset',
WC_Payments_API_Client::COMPATIBILITY_API => 'compatibility',
];

/**
Expand Down
Loading

0 comments on commit 37ee776

Please sign in to comment.