Skip to content

Commit

Permalink
chore: PRB references to ECE (#9780)
Browse files Browse the repository at this point in the history
Co-authored-by: Samir Merchant <[email protected]>
  • Loading branch information
frosso and FangedParakeet authored Dec 3, 2024
1 parent 137745e commit a622dac
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
4 changes: 4 additions & 0 deletions changelog/chore-prb-references-in-ece-docs-and-logs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: update

chore: renamed PRB references in GooglePay/ApplePay implementation docs and logs files to ECE.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function display_express_checkout_buttons() {
$should_show_woopay = $this->platform_checkout_button_handler->should_show_woopay_button();
$should_show_express_checkout_button = $this->express_checkout_helper->should_show_express_checkout_button();

// When Payment Request button is enabled, we need the separator markup on the page, but hidden in case the browser doesn't have any payment request methods to display.
// When Express Checkout button is enabled, we need the separator markup on the page, but hidden in case the browser doesn't have any express payment methods to display.
// More details: https://github.com/Automattic/woocommerce-payments/pull/5399#discussion_r1073633776.
$separator_starts_hidden = ! $should_show_woopay;
if ( $should_show_woopay || $should_show_express_checkout_button ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function is_account_creation_possible() {
$is_signup_from_checkout_allowed = 'yes' === get_option( 'woocommerce_enable_signup_from_checkout_for_subscriptions', 'no' );
}

// If automatically generate username/password are disabled, the Payment Request API
// If automatically generate username/password are disabled, the Express Checkout API
// can't include any of those fields, so account creation is not possible.
return (
$is_signup_from_checkout_allowed &&
Expand Down Expand Up @@ -311,7 +311,7 @@ public function scripts() {
}

/**
* Display the payment request button.
* Display the express checkout button.
*/
public function display_express_checkout_button_html() {
if ( ! $this->express_checkout_helper->should_show_express_checkout_button() ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function get_booking_id_from_cart() {
}

/**
* Builds the line items to pass to Payment Request
* Builds the line items to pass to Express Checkout
*
* @param boolean $itemized_display_items Indicates whether to show subtotals or itemized views.
*/
Expand Down Expand Up @@ -182,7 +182,7 @@ public function get_total_label() {
* @return int
*/
public function get_quantity() {
// Payment Request Button sends the quantity as qty. WooPay sends it as quantity.
// Express Checkout Element sends the quantity as qty. WooPay sends it as quantity.
if ( isset( $_POST['quantity'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
return absint( $_POST['quantity'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
} elseif ( isset( $_POST['qty'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
Expand Down Expand Up @@ -245,7 +245,7 @@ public function is_available_at( $location, $option_name ) {
}

/**
* Gets settings that are shared between the Payment Request button and the WooPay button.
* Gets settings that are shared between the Express Checkout button and the WooPay button.
*
* @return array
*/
Expand Down Expand Up @@ -361,7 +361,7 @@ public function is_product_subscription( WC_Product $product ): bool {
}

/**
* Checks whether Payment Request Button should be available on this page.
* Checks whether Express Checkout Element Button should be available on this page.
*
* @return bool
*/
Expand All @@ -373,7 +373,7 @@ public function should_show_express_checkout_button() {

// If no SSL, bail.
if ( ! WC_Payments::mode()->is_test() && ! is_ssl() ) {
Logger::log( 'Stripe Payment Request live mode requires SSL.' );
Logger::log( 'Stripe Express Checkout live mode requires SSL.' );

return false;
}
Expand All @@ -400,13 +400,13 @@ public function should_show_express_checkout_button() {

// Product page, but has unsupported product type.
if ( $this->is_product() && ! $this->is_product_supported() ) {
Logger::log( 'Product page has unsupported product type ( Payment Request button disabled )' );
Logger::log( 'Product page has unsupported product type ( Express Checkout Element button disabled )' );
return false;
}

// Cart has unsupported product type.
if ( ( $this->is_checkout() || $this->is_cart() ) && ! $this->has_allowed_items_in_cart() ) {
Logger::log( 'Items in the cart have unsupported product type ( Payment Request button disabled )' );
Logger::log( 'Items in the cart have unsupported product type ( Express Checkout Element button disabled )' );
return false;
}

Expand Down Expand Up @@ -439,7 +439,7 @@ public function should_show_express_checkout_button() {
( $this->is_product() && 0.0 === (float) $this->get_product()->get_price() )

) {
Logger::log( 'Order price is 0 ( Payment Request button disabled )' );
Logger::log( 'Order price is 0 ( Express Checkout Element button disabled )' );
return false;
}

Expand Down Expand Up @@ -509,11 +509,11 @@ public function has_allowed_items_in_cart() {
}

/**
* Filter whether product supports Payment Request Button on cart page.
* Filter whether product supports Express Checkout Element Button on cart page.
*
* @since 6.9.0
*
* @param boolean $is_supported Whether product supports Payment Request Button on cart page.
* @param boolean $is_supported Whether product supports Express Checkout Element Button on cart page.
* @param object $_product Product object.
*/
if ( ! apply_filters( 'wcpay_payment_request_is_cart_supported', true, $_product ) ) {
Expand All @@ -530,7 +530,7 @@ public function has_allowed_items_in_cart() {
}
}

// We don't support multiple packages with Payment Request Buttons because we can't offer a good UX.
// We don't support multiple packages with Express Checkout Element Buttons because we can't offer a good UX.
$packages = WC()->cart->get_shipping_packages();
if ( 1 < ( is_countable( $packages ) ? count( $packages ) : 0 ) ) {
return false;
Expand Down Expand Up @@ -618,7 +618,7 @@ public function get_shipping_options( $shipping_address, $itemized_display_items

/**
* Restores the shipping methods previously chosen for each recurring cart after shipping was reset and recalculated
* during the Payment Request get_shipping_options flow.
* during the Express Checkout get_shipping_options flow.
*
* When the cart contains multiple subscriptions with different billing periods, customers are able to select different shipping
* methods for each subscription, however, this is not supported when purchasing with Apple Pay and Google Pay as it's
Expand Down Expand Up @@ -888,7 +888,7 @@ public function get_normalized_state( $state, $country ) {
return $state;
}

// Try to match state from the Payment Request API list of states.
// Try to match state from the Express Checkout API list of states.
$state = $this->get_normalized_state_from_ece_states( $state, $country );

// If it's normalized, return.
Expand All @@ -902,11 +902,11 @@ public function get_normalized_state( $state, $country ) {
}

/**
* The Payment Request API provides its own validation for the address form.
* The Express Checkout Element API provides its own validation for the address form.
* For some countries, it might not provide a state field, so we need to return a more descriptive
* error message, indicating that the Payment Request button is not supported for that country.
* error message, indicating that the Express Checkout Element button is not supported for that country.
*/
public static function validate_state() {
public function validate_state() {
$wc_checkout = WC_Checkout::instance();
$posted_data = $wc_checkout->get_posted_data();
$checkout_fields = $wc_checkout->get_checkout_fields();
Expand All @@ -927,7 +927,7 @@ public static function validate_state() {
wc_add_notice(
sprintf(
/* translators: %s: country. */
__( 'The payment request button is not supported in %s because some required fields couldn\'t be verified. Please proceed to the checkout page and try again.', 'woocommerce-payments' ),
__( 'The express checkout is not supported in %s because some required fields couldn\'t be verified. Please proceed to the checkout page and try again.', 'woocommerce-payments' ),
$countries[ $posted_data['billing_country'] ] ?? $posted_data['billing_country']
),
'error'
Expand Down Expand Up @@ -969,7 +969,7 @@ public function is_normalized_state( $state, $country ) {
}

/**
* Get normalized state from Payment Request API dropdown list of states.
* Get normalized state from Express Checkout API dropdown list of states.
*
* @param string $state Full state name or state code.
* @param string $country Two-letter country code.
Expand All @@ -987,7 +987,7 @@ public function get_normalized_state_from_ece_states( $state, $country ) {

foreach ( $pr_states[ $country ] as $wc_state_abbr => $pr_state ) {
$sanitized_state_string = $this->sanitize_string( $state );
// Checks if input state matches with Payment Request state code (0), name (1) or localName (2).
// Checks if input state matches with Express Checkout state code (0), name (1) or localName (2).
if (
( ! empty( $pr_state[0] ) && $sanitized_state_string === $this->sanitize_string( $pr_state[0] ) ) ||
( ! empty( $pr_state[1] ) && $sanitized_state_string === $this->sanitize_string( $pr_state[1] ) ) ||
Expand Down

0 comments on commit a622dac

Please sign in to comment.