From dfe4acb122352c08ae47d26b95fddd942cf466c1 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Tue, 20 Apr 2021 13:20:50 +0300 Subject: [PATCH 1/6] make expire field placeholder the same as label --- modules/ppcp-button/src/Assets/class-smartbutton.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ppcp-button/src/Assets/class-smartbutton.php b/modules/ppcp-button/src/Assets/class-smartbutton.php index ac95dc3f7..7cc8e4baf 100644 --- a/modules/ppcp-button/src/Assets/class-smartbutton.php +++ b/modules/ppcp-button/src/Assets/class-smartbutton.php @@ -683,7 +683,7 @@ class SmartButton implements SmartButtonInterface { 'labels' => array( 'credit_card_number' => '', 'cvv' => '', - 'mm_yyyy' => __( 'MM/YYYY', 'woocommerce-paypal-payments' ), + 'mm_yyyy' => __( 'MM/YY', 'woocommerce-paypal-payments' ), 'fields_not_valid' => __( 'Unfortunatly, your credit card details are not valid.', 'woocommerce-paypal-payments' From 9fd1822c0fddd7c052f0f7378cfc32d5161062a6 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Tue, 20 Apr 2021 16:34:51 +0300 Subject: [PATCH 2/6] replace WC CVV field label --- .../src/Gateway/class-creditcardgateway.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php b/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php index d74770eb4..4dcdd4b96 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php @@ -197,6 +197,34 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC { ); } + /** + * Render the credit card fields. + */ + public function form() + { + add_action('gettext', array($this, 'replace_credit_card_cvv_label'), 10, 3); + parent::form(); + remove_action('gettext', 'replace_credit_card_cvv_label'); + } + + /** + * Replace WooCommerce credit card field label. + * + * @param $translation string Translated text. + * @param $text string Original text to translate. + * @param $domain string Text domain. + * + * @return string Translated field. + */ + public function replace_credit_card_cvv_label(string $translation, string $text, string $domain): string + { + if('woocommerce' !== $domain || 'Card code' !== $text) { + return $translation; + } + + return __('CVV', 'woocommerce-paypal-payments'); + } + /** * Returns the title of the gateway. * From d38697dddf4fba0baf2627dde13c8f43750072ee Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Tue, 20 Apr 2021 16:43:08 +0300 Subject: [PATCH 3/6] auto fix phpcs errors --- .../src/Gateway/class-creditcardgateway.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php b/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php index 4dcdd4b96..55dc914b9 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php @@ -200,13 +200,12 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC { /** * Render the credit card fields. */ - public function form() - { - add_action('gettext', array($this, 'replace_credit_card_cvv_label'), 10, 3); + public function form() { + add_action( 'gettext', array( $this, 'replace_credit_card_cvv_label' ), 10, 3 ); parent::form(); - remove_action('gettext', 'replace_credit_card_cvv_label'); + remove_action( 'gettext', 'replace_credit_card_cvv_label' ); } - + /** * Replace WooCommerce credit card field label. * @@ -216,13 +215,12 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC { * * @return string Translated field. */ - public function replace_credit_card_cvv_label(string $translation, string $text, string $domain): string - { - if('woocommerce' !== $domain || 'Card code' !== $text) { + public function replace_credit_card_cvv_label( string $translation, string $text, string $domain ): string { + if ( 'woocommerce' !== $domain || 'Card code' !== $text ) { return $translation; } - - return __('CVV', 'woocommerce-paypal-payments'); + + return __( 'CVV', 'woocommerce-paypal-payments' ); } /** From 0a2a571e3e3f69418bb2219229444ae184a497cf Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Tue, 20 Apr 2021 16:51:48 +0300 Subject: [PATCH 4/6] fix docblock --- .../ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php b/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php index 55dc914b9..80db250a3 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php @@ -209,9 +209,9 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC { /** * Replace WooCommerce credit card field label. * - * @param $translation string Translated text. - * @param $text string Original text to translate. - * @param $domain string Text domain. + * @param string $translation Translated text. + * @param string $text Original text to translate. + * @param string $domain Text domain. * * @return string Translated field. */ From 74d5337bc9bb87dca542567ac65d5a7cef5986ed Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Fri, 14 May 2021 14:27:41 +0300 Subject: [PATCH 5/6] use yy format instead of yyyy for card details --- .../resources/js/modules/Renderer/CreditCardRenderer.js | 2 +- modules/ppcp-button/src/Assets/class-smartbutton.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-button/resources/js/modules/Renderer/CreditCardRenderer.js b/modules/ppcp-button/resources/js/modules/Renderer/CreditCardRenderer.js index ccd6de35f..0a3447457 100644 --- a/modules/ppcp-button/resources/js/modules/Renderer/CreditCardRenderer.js +++ b/modules/ppcp-button/resources/js/modules/Renderer/CreditCardRenderer.js @@ -87,7 +87,7 @@ class CreditCardRenderer { }, expirationDate: { selector: '#ppcp-credit-card-gateway-card-expiry', - placeholder: this.defaultConfig.hosted_fields.labels.mm_yyyy, + placeholder: this.defaultConfig.hosted_fields.labels.mm_yy, } } }).then(hostedFields => { diff --git a/modules/ppcp-button/src/Assets/class-smartbutton.php b/modules/ppcp-button/src/Assets/class-smartbutton.php index 7cc8e4baf..86f5c1ddd 100644 --- a/modules/ppcp-button/src/Assets/class-smartbutton.php +++ b/modules/ppcp-button/src/Assets/class-smartbutton.php @@ -683,7 +683,7 @@ class SmartButton implements SmartButtonInterface { 'labels' => array( 'credit_card_number' => '', 'cvv' => '', - 'mm_yyyy' => __( 'MM/YY', 'woocommerce-paypal-payments' ), + 'mm_yy' => __( 'MM/YY', 'woocommerce-paypal-payments' ), 'fields_not_valid' => __( 'Unfortunatly, your credit card details are not valid.', 'woocommerce-paypal-payments' From 06769c9af94633a93df5803adcfff5c8800e6033 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Mon, 17 May 2021 10:45:02 +0300 Subject: [PATCH 6/6] fix phpcs errors --- modules/ppcp-button/src/Assets/class-smartbutton.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ppcp-button/src/Assets/class-smartbutton.php b/modules/ppcp-button/src/Assets/class-smartbutton.php index 86f5c1ddd..36d4f7b8e 100644 --- a/modules/ppcp-button/src/Assets/class-smartbutton.php +++ b/modules/ppcp-button/src/Assets/class-smartbutton.php @@ -683,7 +683,7 @@ class SmartButton implements SmartButtonInterface { 'labels' => array( 'credit_card_number' => '', 'cvv' => '', - 'mm_yy' => __( 'MM/YY', 'woocommerce-paypal-payments' ), + 'mm_yy' => __( 'MM/YY', 'woocommerce-paypal-payments' ), 'fields_not_valid' => __( 'Unfortunatly, your credit card details are not valid.', 'woocommerce-paypal-payments'