Skip to content

Commit

Permalink
Fix apple pay funding source renderer.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrosilva-pt committed Feb 6, 2024
1 parent 8266e1b commit 5272087
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function __construct(
* @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 ];
Expand All @@ -78,6 +80,8 @@ public function render_name( string $id ): string {
* @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. */
Expand All @@ -90,4 +94,14 @@ public function render_description( string $id ): string {
$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 ) );
}
}

0 comments on commit 5272087

Please sign in to comment.