From 52720872de7f92254c42467257faa5c4e868bc7d Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Tue, 6 Feb 2024 17:40:39 +0000 Subject: [PATCH] Fix apple pay funding source renderer. --- .../src/FundingSource/FundingSourceRenderer.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/ppcp-wc-gateway/src/FundingSource/FundingSourceRenderer.php b/modules/ppcp-wc-gateway/src/FundingSource/FundingSourceRenderer.php index a465db721..071410615 100644 --- a/modules/ppcp-wc-gateway/src/FundingSource/FundingSourceRenderer.php +++ b/modules/ppcp-wc-gateway/src/FundingSource/FundingSourceRenderer.php @@ -56,6 +56,8 @@ class FundingSourceRenderer { * @param string $id The ID of the funding source, such as 'venmo'. */ public function render_name( string $id ): string { + $id = $this->sanitize_id( $id ); + if ( array_key_exists( $id, $this->funding_sources ) ) { if ( in_array( $id, $this->own_funding_sources, true ) ) { return $this->funding_sources[ $id ]; @@ -78,6 +80,8 @@ class FundingSourceRenderer { * @param string $id The ID of the funding source, such as 'venmo'. */ public function render_description( string $id ): string { + $id = $this->sanitize_id( $id ); + if ( array_key_exists( $id, $this->funding_sources ) ) { return sprintf( /* translators: %s - Sofort, BLIK, iDeal, Mercado Pago, etc. */ @@ -90,4 +94,14 @@ class FundingSourceRenderer { $this->settings->get( 'description' ) : __( 'Pay via PayPal.', 'woocommerce-paypal-payments' ); } + + /** + * Sanitizes the id to a standard format. + * + * @param string $id The funding source id. + * @return string + */ + private function sanitize_id( string $id ): string { + return str_replace( '_', '', strtolower( $id ) ); + } }