mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Fix apple pay funding source renderer.
This commit is contained in:
parent
8266e1bce7
commit
52720872de
1 changed files with 14 additions and 0 deletions
|
@ -56,6 +56,8 @@ class FundingSourceRenderer {
|
||||||
* @param string $id The ID of the funding source, such as 'venmo'.
|
* @param string $id The ID of the funding source, such as 'venmo'.
|
||||||
*/
|
*/
|
||||||
public function render_name( string $id ): string {
|
public function render_name( string $id ): string {
|
||||||
|
$id = $this->sanitize_id( $id );
|
||||||
|
|
||||||
if ( array_key_exists( $id, $this->funding_sources ) ) {
|
if ( array_key_exists( $id, $this->funding_sources ) ) {
|
||||||
if ( in_array( $id, $this->own_funding_sources, true ) ) {
|
if ( in_array( $id, $this->own_funding_sources, true ) ) {
|
||||||
return $this->funding_sources[ $id ];
|
return $this->funding_sources[ $id ];
|
||||||
|
@ -78,6 +80,8 @@ class FundingSourceRenderer {
|
||||||
* @param string $id The ID of the funding source, such as 'venmo'.
|
* @param string $id The ID of the funding source, such as 'venmo'.
|
||||||
*/
|
*/
|
||||||
public function render_description( string $id ): string {
|
public function render_description( string $id ): string {
|
||||||
|
$id = $this->sanitize_id( $id );
|
||||||
|
|
||||||
if ( array_key_exists( $id, $this->funding_sources ) ) {
|
if ( array_key_exists( $id, $this->funding_sources ) ) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
/* translators: %s - Sofort, BLIK, iDeal, Mercado Pago, etc. */
|
/* translators: %s - Sofort, BLIK, iDeal, Mercado Pago, etc. */
|
||||||
|
@ -90,4 +94,14 @@ class FundingSourceRenderer {
|
||||||
$this->settings->get( 'description' )
|
$this->settings->get( 'description' )
|
||||||
: __( 'Pay via PayPal.', 'woocommerce-paypal-payments' );
|
: __( '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 ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue