Merge pull request #1986 from woocommerce/PCP-2521-apple-pay-recurring-payments

Apple Pay recurring payments (2521)
This commit is contained in:
Emili Castells 2024-02-07 10:47:08 +01:00 committed by GitHub
commit 037f650288
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 437 additions and 37 deletions

View file

@ -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 ) );
}
}