Date: Mon, 18 Sep 2023 17:52:17 +0200
Subject: [PATCH 11/17] Fix cs
---
modules/ppcp-applepay/extensions.php | 26 +++++++++----------
modules/ppcp-applepay/services.php | 18 ++++++-------
.../src/Assets/DataToAppleButtonScripts.php | 8 +++---
3 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/modules/ppcp-applepay/extensions.php b/modules/ppcp-applepay/extensions.php
index e6006dba5..7349e2e5b 100644
--- a/modules/ppcp-applepay/extensions.php
+++ b/modules/ppcp-applepay/extensions.php
@@ -32,27 +32,27 @@ return array(
$fields,
'allow_card_button_gateway',
array(
- 'applepay_button_enabled' => array(
- 'title' => __('Apple Pay Button', 'woocommerce-paypal-payments'),
- 'type' => 'checkbox',
- 'class' => array('ppcp-grayed-out-text'),
- 'input_class' => array('ppcp-disabled-checkbox'),
- 'label' => __('Enable Apple Pay button', 'woocommerce-paypal-payments')
+ 'applepay_button_enabled' => array(
+ 'title' => __( 'Apple Pay Button', 'woocommerce-paypal-payments' ),
+ 'type' => 'checkbox',
+ 'class' => array( 'ppcp-grayed-out-text' ),
+ 'input_class' => array( 'ppcp-disabled-checkbox' ),
+ 'label' => __( 'Enable Apple Pay button', 'woocommerce-paypal-payments' )
. ''
. sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML tag.
- __('Your PayPal account %1$srequires additional permissions%2$s to enable Apple Pay.', 'woocommerce-paypal-payments'),
+ __( 'Your PayPal account %1$srequires additional permissions%2$s to enable Apple Pay.', 'woocommerce-paypal-payments' ),
$connection_link,
''
)
. '
',
- 'default' => 'yes',
- 'screens' => array(State::STATE_ONBOARDED),
- 'gateway' => 'paypal',
+ 'default' => 'yes',
+ 'screens' => array( State::STATE_ONBOARDED ),
+ 'gateway' => 'paypal',
'requirements' => array(),
- ),
- )
- );
+ ),
+ )
+ );
}
return $insert_after(
$fields,
diff --git a/modules/ppcp-applepay/services.php b/modules/ppcp-applepay/services.php
index c5f826aa1..9158dacae 100644
--- a/modules/ppcp-applepay/services.php
+++ b/modules/ppcp-applepay/services.php
@@ -33,10 +33,10 @@ return array(
$container->get( 'api.shop.country' )
);
},
- 'applepay.status-cache' => static function( ContainerInterface $container ): Cache {
+ 'applepay.status-cache' => static function( ContainerInterface $container ): Cache {
return new Cache( 'ppcp-paypal-apple-status-cache' );
},
- 'applepay.apple-product-status' => static function( ContainerInterface $container ): AppleProductStatus {
+ 'applepay.apple-product-status' => static function( ContainerInterface $container ): AppleProductStatus {
return new AppleProductStatus(
$container->get( 'wcgateway.settings' ),
$container->get( 'api.endpoint.partners' ),
@@ -44,7 +44,7 @@ return array(
$container->get( 'onboarding.state' )
);
},
- 'applepay.enabled' => static function ( ContainerInterface $container ): bool {
+ 'applepay.enabled' => static function ( ContainerInterface $container ): bool {
if ( apply_filters( 'woocommerce_paypal_payments_applepay_validate_product_status', false ) ) {
$status = $container->get( 'applepay.apple-product-status' );
assert( $status instanceof AppleProductStatus );
@@ -55,10 +55,10 @@ return array(
}
return true;
},
- 'applepay.server_supported' => static function ( ContainerInterface $container ): bool {
+ 'applepay.server_supported' => static function ( ContainerInterface $container ): bool {
return ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] !== 'off';
},
- 'applepay.url' => static function ( ContainerInterface $container ): string {
+ 'applepay.url' => static function ( ContainerInterface $container ): string {
$path = realpath( __FILE__ );
if ( false === $path ) {
return '';
@@ -68,13 +68,13 @@ return array(
dirname( $path, 3 ) . '/woocommerce-paypal-payments.php'
);
},
- 'applepay.sdk_script_url' => static function ( ContainerInterface $container ): string {
+ 'applepay.sdk_script_url' => static function ( ContainerInterface $container ): string {
return 'https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js';
},
- 'applepay.data_to_scripts' => static function ( ContainerInterface $container ): DataToAppleButtonScripts {
+ 'applepay.data_to_scripts' => static function ( ContainerInterface $container ): DataToAppleButtonScripts {
return new DataToAppleButtonScripts( $container->get( 'applepay.sdk_script_url' ), $container->get( 'wcgateway.settings' ) );
},
- 'applepay.button' => static function ( ContainerInterface $container ): ApplePayButton {
+ 'applepay.button' => static function ( ContainerInterface $container ): ApplePayButton {
return new ApplePayButton(
$container->get( 'wcgateway.settings' ),
@@ -86,7 +86,7 @@ return array(
$container->get( 'wcgateway.settings.status' )
);
},
- 'applepay.blocks-payment-method' => static function ( ContainerInterface $container ): PaymentMethodTypeInterface {
+ 'applepay.blocks-payment-method' => static function ( ContainerInterface $container ): PaymentMethodTypeInterface {
return new BlocksPaymentMethod(
'ppcp-applepay',
$container->get( 'applepay.url' ),
diff --git a/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php b/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php
index e87abbd88..90f25b6c1 100644
--- a/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php
+++ b/modules/ppcp-applepay/src/Assets/DataToAppleButtonScripts.php
@@ -173,10 +173,10 @@ class DataToAppleButtonScripts {
''
. $nonce
. '
';
- $type = $this->settings->has('applepay_button_type') ? $this->settings->get('applepay_button_type') : '';
- $color = $this->settings->has('applepay_button_color') ? $this->settings->get('applepay_button_color') : '';
- $lang = $this->settings->has('applepay_button_language') ? $this->settings->get('applepay_button_language') : '';
- $lang = apply_filters('woocommerce_paypal_payments_applepay_button_language', $lang);
+ $type = $this->settings->has( 'applepay_button_type' ) ? $this->settings->get( 'applepay_button_type' ) : '';
+ $color = $this->settings->has( 'applepay_button_color' ) ? $this->settings->get( 'applepay_button_color' ) : '';
+ $lang = $this->settings->has( 'applepay_button_language' ) ? $this->settings->get( 'applepay_button_language' ) : '';
+ $lang = apply_filters( 'woocommerce_paypal_payments_applepay_button_language', $lang );
return array(
'sdk_url' => $this->sdk_url,
From 18216c8fea626fc85fdb9e13fa88b1574c6b80f6 Mon Sep 17 00:00:00 2001
From: carmenmaymo
Date: Tue, 19 Sep 2023 08:23:23 +0200
Subject: [PATCH 12/17] Add currencies
---
modules/ppcp-applepay/services.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/ppcp-applepay/services.php b/modules/ppcp-applepay/services.php
index 9158dacae..4ae3ec2b0 100644
--- a/modules/ppcp-applepay/services.php
+++ b/modules/ppcp-applepay/services.php
@@ -106,7 +106,7 @@ return array(
'woocommerce_paypal_payments_applepay_supported_country_currency_matrix',
array(
'US' => array(
- 'USD',
+ 'AUD', 'CAD', 'EUR', 'GBP', 'JPY', 'USD'
),
)
);
From cca21234edb8aeb6249318fba332b8a925aab3df Mon Sep 17 00:00:00 2001
From: carmenmaymo
Date: Tue, 19 Sep 2023 11:17:48 +0200
Subject: [PATCH 13/17] Show validation file from within
---
modules/ppcp-applepay/extensions.php | 30 +++-----------
modules/ppcp-applepay/services.php | 7 +++-
modules/ppcp-applepay/src/ApplepayModule.php | 43 ++++++++++++++++----
3 files changed, 45 insertions(+), 35 deletions(-)
diff --git a/modules/ppcp-applepay/extensions.php b/modules/ppcp-applepay/extensions.php
index 7349e2e5b..ccbd7fbcd 100644
--- a/modules/ppcp-applepay/extensions.php
+++ b/modules/ppcp-applepay/extensions.php
@@ -58,7 +58,7 @@ return array(
$fields,
'allow_card_button_gateway',
array(
- 'applepay_button_enabled' => array(
+ 'applepay_button_enabled' => array(
'title' => __( 'Apple Pay Button', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable Apple Pay button', 'woocommerce-paypal-payments' )
@@ -81,34 +81,14 @@ return array(
'handler' => 'SubElementsHandler',
'options' => array(
'values' => array( '1' ),
- 'elements' => array( '#field-applepay_sandbox_validation_file', '#field-applepay_live_validation_file', '#field-applepay_button_color', '#field-applepay_button_type', '#field-applepay_button_language' ),
+ 'elements' => array( '#field-applepay_button_color', '#field-applepay_button_type', '#field-applepay_button_language' ),
),
),
)
),
),
),
- 'applepay_live_validation_file' => array(
- 'title' => __( 'Apple Pay Live Validation File', 'woocommerce-paypal-payments' ),
- 'type' => 'text',
- 'desc_tip' => true,
- 'description' => __( 'Paste here the validation file content', 'woocommerce-paypal-payments' ),
- 'default' => null,
- 'screens' => array( State::STATE_ONBOARDED ),
- 'gateway' => 'paypal',
- 'requirements' => array(),
- ),
- 'applepay_sandbox_validation_file' => array(
- 'title' => __( 'Apple Pay Sandbox Validation File', 'woocommerce-paypal-payments' ),
- 'type' => 'text',
- 'desc_tip' => true,
- 'description' => __( 'Paste here the validation file content', 'woocommerce-paypal-payments' ),
- 'default' => null,
- 'screens' => array( State::STATE_ONBOARDED ),
- 'gateway' => 'paypal',
- 'requirements' => array(),
- ),
- 'applepay_button_type' => array(
+ 'applepay_button_type' => array(
'title' => str_repeat( ' ', 6 ) . __( 'Button Label', 'woocommerce-paypal-payments' ),
'type' => 'select',
'desc_tip' => true,
@@ -124,7 +104,7 @@ return array(
'gateway' => 'paypal',
'requirements' => array(),
),
- 'applepay_button_color' => array(
+ 'applepay_button_color' => array(
'title' => str_repeat( ' ', 6 ) . __( 'Button Color', 'woocommerce-paypal-payments' ),
'type' => 'select',
'desc_tip' => true,
@@ -141,7 +121,7 @@ return array(
'gateway' => 'paypal',
'requirements' => array(),
),
- 'applepay_button_language' => array(
+ 'applepay_button_language' => array(
'title' => str_repeat( ' ', 6 ) . __( 'Button Language', 'woocommerce-paypal-payments' ),
'type' => 'select',
'desc_tip' => true,
diff --git a/modules/ppcp-applepay/services.php b/modules/ppcp-applepay/services.php
index 4ae3ec2b0..1cc6f81d3 100644
--- a/modules/ppcp-applepay/services.php
+++ b/modules/ppcp-applepay/services.php
@@ -106,7 +106,12 @@ return array(
'woocommerce_paypal_payments_applepay_supported_country_currency_matrix',
array(
'US' => array(
- 'AUD', 'CAD', 'EUR', 'GBP', 'JPY', 'USD'
+ 'AUD',
+ 'CAD',
+ 'EUR',
+ 'GBP',
+ 'JPY',
+ 'USD',
),
)
);
diff --git a/modules/ppcp-applepay/src/ApplepayModule.php b/modules/ppcp-applepay/src/ApplepayModule.php
index 9752642a3..23c492236 100644
--- a/modules/ppcp-applepay/src/ApplepayModule.php
+++ b/modules/ppcp-applepay/src/ApplepayModule.php
@@ -106,19 +106,15 @@ class ApplepayModule implements ModuleInterface {
/**
* Loads the validation string.
*
- * @param boolean $is_sandbox The environment for this merchant.
- * @param Settings $settings The settings.
+ * @param boolean $is_sandbox The environment for this merchant.
*/
- protected function load_domain_association_file( bool $is_sandbox, Settings $settings ): void {
+ protected function load_domain_association_file( bool $is_sandbox ): void {
if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
return;
}
$request_uri = (string) filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_URL );
if ( strpos( $request_uri, '.well-known/apple-developer-merchantid-domain-association' ) !== false ) {
- $validation_string = $is_sandbox ? 'applepay_sandbox_validation_file' : 'applepay_live_validation_file';
- $validation_string = $settings->has( $validation_string ) ? $settings->get( $validation_string ) : '';
- $validation_string = preg_replace( '/\s+/', '', $validation_string );
- $validation_string = $validation_string ? preg_replace( '/[^a-zA-Z0-9]/', '', $validation_string ) : '';
+ $validation_string = $this->validation_string( $is_sandbox );
nocache_headers();
header( 'Content-Type: text/plain', true, 200 );
echo $validation_string;// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -226,7 +222,36 @@ class ApplepayModule implements ModuleInterface {
$env = $c->get( 'onboarding.environment' );
assert( $env instanceof Environment );
$is_sandobx = $env->current_environment_is( Environment::SANDBOX );
- $settings = $c->get( 'wcgateway.settings' );
- $this->load_domain_association_file( $is_sandobx, $settings );
+ $this->load_domain_association_file( $is_sandobx );
+ }
+
+ /**
+ * Returns the validation string, depending on the environment.
+ *
+ * @param bool $is_sandbox The environment for this merchant.
+ * @return string
+ */
+ public function validation_string( bool $is_sandbox ) {
+ $sandbox_string = $this->sandbox_validation_string();
+ $live_string = $this->live_validation_string();
+ return $is_sandbox ? $sandbox_string : $live_string;
+ }
+
+ /**
+ * Returns the sandbox validation string.
+ *
+ * @return string
+ */
+ private function sandbox_validation_string(): string {
+ return '7B227073704964223A2241443631324543383841333039314132314539434132433035304439454130353741414535444341304542413237424243333838463239344231353534434233222C2276657273696F6E223A312C22637265617465644F6E223A313632343438393037393630362C227369676E6174757265223A2233303830303630393261383634383836663730643031303730326130383033303830303230313031333130663330306430363039363038363438303136353033303430323031303530303330383030363039326138363438383666373064303130373031303030306130383033303832303365343330383230333862613030333032303130323032303835396438613162636161663465336364333030613036303832613836343863653364303430333032333037613331326533303263303630333535303430333063323534313730373036633635323034313730373036633639363336313734363936663665323034393665373436353637373236313734363936663665323034333431323032643230343733333331323633303234303630333535303430623063316434313730373036633635323034333635373237343639363636393633363137343639366636653230343137353734363836663732363937343739333131333330313130363033353530343061306330613431373037303663363532303439366536333265333130623330303930363033353530343036313330323535353333303165313730643332333133303334333233303331333933333337333033303561313730643332333633303334333133393331333933333336333533393561333036323331323833303236303630333535303430333063316636353633363332643733366437303264363237323666366236353732326437333639363736653566353534333334326435333431346534343432346635383331313433303132303630333535303430623063306236393466353332303533373937333734363536643733333131333330313130363033353530343061306330613431373037303663363532303439366536333265333130623330303930363033353530343036313330323535353333303539333031333036303732613836343863653364303230313036303832613836343863653364303330313037303334323030303438323330666461626333396366373565323032633530643939623435313265363337653261393031646436636233653062316364346235323637393866386366346562646538316132356138633231653463333364646365386532613936633266366166613139333033343563346538376134343236636539353162313239356133383230323131333038323032306433303063303630333535316431333031303166663034303233303030333031663036303335353164323330343138333031363830313432336632343963343466393365346566323765366334663632383663336661326262666432653462333034353036303832623036303130353035303730313031303433393330333733303335303630383262303630313035303530373330303138363239363837343734373033613266326636663633373337303265363137303730366336353265363336663664326636663633373337303330333432643631373037303663363536313639363336313333333033323330383230313164303630333535316432303034383230313134333038323031313033303832303130633036303932613836343838366637363336343035303133303831666533303831633330363038326230363031303530353037303230323330383162363063383162333532363536633639363136653633363532303666366532303734363836393733323036333635373237343639363636393633363137343635323036323739323036313665373932303730363137323734373932303631373337333735366436353733323036313633363336353730373436313665363336353230366636363230373436383635323037343638363536653230363137303730366336393633363136323663363532303733373436313665363436313732363432303734363537323664373332303631366536343230363336663665363436393734363936663665373332303666363632303735373336353263323036333635373237343639363636393633363137343635323037303666366336393633373932303631366536343230363336353732373436393636363936333631373436393666366532303730373236313633373436393633363532303733373436313734363536643635366537343733326533303336303630383262303630313035303530373032303131363261363837343734373033613266326637373737373732653631373037303663363532653633366636643266363336353732373436393636363936333631373436353631373537343638366637323639373437393266333033343036303335353164316630343264333032623330323961303237613032353836323336383734373437303361326632663633373236633265363137303730366336353265363336663664326636313730373036633635363136393633363133333265363337323663333031643036303335353164306530343136303431343032323433303062396165656564343633313937613461363561323939653432373138323163343533303065303630333535316430663031303166663034303430333032303738303330306630363039326138363438383666373633363430363164303430323035303033303061303630383261383634386365336430343033303230333437303033303434303232303734613162333234646234323439343330646433323734633530373463343830386439613166343830653361383563356331333632353636333235666263613330323230363933363930353361626635306235613532663966363030346463353861616436633530613764363038363833373930653061373361643031653461643938313330383230326565333038323032373561303033303230313032303230383439366432666266336139386461393733303061303630383261383634386365336430343033303233303637333131623330313930363033353530343033306331323431373037303663363532303532366636663734323034333431323032643230343733333331323633303234303630333535303430623063316434313730373036633635323034333635373237343639363636393633363137343639366636653230343137353734363836663732363937343739333131333330313130363033353530343061306330613431373037303663363532303439366536333265333130623330303930363033353530343036313330323535353333303165313730643331333433303335333033363332333333343336333333303561313730643332333933303335333033363332333333343336333333303561333037613331326533303263303630333535303430333063323534313730373036633635323034313730373036633639363336313734363936663665323034393665373436353637373236313734363936663665323034333431323032643230343733333331323633303234303630333535303430623063316434313730373036633635323034333635373237343639363636393633363137343639366636653230343137353734363836663732363937343739333131333330313130363033353530343061306330613431373037303663363532303439366536333265333130623330303930363033353530343036313330323535353333303539333031333036303732613836343863653364303230313036303832613836343863653364303330313037303334323030303466303137313138343139643736343835643531613565323538313037373665383830613265666465376261653464653038646663346239336531333335366435363635623335616532326430393737363064323234653762626130386664373631376365383863623736626236363730626563386538323938346666353434356133383166373330383166343330343630363038326230363031303530353037303130313034336133303338333033363036303832623036303130353035303733303031383632613638373437343730336132663266366636333733373032653631373037303663363532653633366636643266366636333733373033303334326436313730373036633635373236663666373436333631363733333330316430363033353531643065303431363034313432336632343963343466393365346566323765366334663632383663336661326262666432653462333030663036303335353164313330313031666630343035333030333031303166663330316630363033353531643233303431383330313638303134626262306465613135383333383839616134386139396465626562646562616664616362323461623330333730363033353531643166303433303330326533303263613032616130323838363236363837343734373033613266326636333732366332653631373037303663363532653633366636643266363137303730366336353732366636663734363336313637333332653633373236633330306530363033353531643066303130316666303430343033303230313036333031303036306132613836343838366637363336343036303230653034303230353030333030613036303832613836343863653364303430333032303336373030333036343032333033616366373238333531313639396231383666623335633335366361363262666634313765646439306637353464613238656265663139633831356534326237383966383938663739623539396639386435343130643866396465396332666530323330333232646435343432316230613330353737366335646633333833623930363766643137376332633231366439363466633637323639383231323666353466383761376431623939636239623039383932313631303639393066303939323164303030303331383230313863333038323031383830323031303133303831383633303761333132653330326330363033353530343033306332353431373037303663363532303431373037303663363936333631373436393666366532303439366537343635363737323631373436393666366532303433343132303264323034373333333132363330323430363033353530343062306331643431373037303663363532303433363537323734363936363639363336313734363936663665323034313735373436383666373236393734373933313133333031313036303335353034306130633061343137303730366336353230343936653633326533313062333030393036303335353034303631333032353535333032303835396438613162636161663465336364333030643036303936303836343830313635303330343032303130353030613038313935333031383036303932613836343838366637306430313039303333313062303630393261383634383836663730643031303730313330316330363039326138363438383666373064303130393035333130663137306433323331333033363332333333323332333533373335333935613330326130363039326138363438383666373064303130393334333131643330316233303064303630393630383634383031363530333034303230313035303061313061303630383261383634386365336430343033303233303266303630393261383634383836663730643031303930343331323230343230343239323932333766306638303764346538373932333134643438393635623165626262633038636265386333333432643365643261333939623963336538353330306130363038326138363438636533643034303330323034343733303435303232313030643430333138326637626530396663386265393738316463646461613434623332663362353634386566353666323664323933363738343237393933616530383032323037646663306563316361306461343531653464663031386236376538326231366330313065313930373431363762666632363839356230336563336430396134303030303030303030303030227D';
+ }
+
+ /**
+ * Returns the live validation string.
+ *
+ * @return string
+ */
+ private function live_validation_string(): string {
+ return 'MIIQYQYJKoZIhvcNAQcCoI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a-CuVwlkFFrPthelMfZU0YsMBv2zAOD5ZWnUrMc1Tc4myrZEK4DoNVtSG5kS5TvU_F_Cd3gPuCML4DIzrfaRMW9u9h_VehOcQIlultruQn2Wl1ihmi2_D8Q5fXF4E1dXe-a5ohdKCLWCXa7IhW818nfFbophoVDN4ymAY_1bMXp4iLa06iXXfZqQJqHnG2rFsUSLsGX49qSnNtR-1N23EtHgJQMqQpTz8C6VKI93ySOC3ijSqvRnm4Dgdl0HZ';
}
}
From f1ec501311dce8f16970f7f53fbc1d6fc9190110 Mon Sep 17 00:00:00 2001
From: carmenmaymo
Date: Tue, 19 Sep 2023 12:22:08 +0200
Subject: [PATCH 14/17] Merge PCP-1970
---
modules/ppcp-applepay/extensions.php | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/modules/ppcp-applepay/extensions.php b/modules/ppcp-applepay/extensions.php
index d531564e6..f1e17b10e 100644
--- a/modules/ppcp-applepay/extensions.php
+++ b/modules/ppcp-applepay/extensions.php
@@ -24,6 +24,8 @@ return array(
return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
};
+ $display_manager = $container->get( 'wcgateway.display-manager' );
+ assert( $display_manager instanceof DisplayManager );
if ( ! $container->has( 'applepay.eligible' ) || ! $container->get( 'applepay.eligible' ) ) {
$connection_url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=ppcp-connection#field-credentials_feature_onboarding_heading' );
@@ -50,17 +52,21 @@ return array(
'screens' => array( State::STATE_ONBOARDED ),
'gateway' => 'paypal',
'requirements' => array(),
+ 'custom_attributes' => array(
+ 'data-ppcp-display' => wp_json_encode(
+ array(
+ $display_manager
+ ->rule()
+ ->condition_element( 'applepay_button_enabled', '1' )
+ ->action_enable( 'applepay_button_enabled' )
+ ->to_array(),
+ )
+ ),
+ ),
),
)
);
}
- return $insert_after(
- $fields,
- 'allow_card_button_gateway',
- array(
- 'applepay_button_enabled' => array(
- $display_manager = $container->get( 'wcgateway.display-manager' );
- assert( $display_manager instanceof DisplayManager );
return $insert_after(
$fields,
@@ -88,8 +94,6 @@ return array(
$display_manager
->rule()
->condition_element( 'applepay_button_enabled', '1' )
- ->action_visible( 'applepay_sandbox_validation_file' )
- ->action_visible( 'applepay_live_validation_file' )
->action_visible( 'applepay_button_color' )
->action_visible( 'applepay_button_type' )
->action_visible( 'applepay_button_language' )
From a45f3c4436b0081472e70f5a107b82c4090763d4 Mon Sep 17 00:00:00 2001
From: carmenmaymo
Date: Tue, 19 Sep 2023 12:44:26 +0200
Subject: [PATCH 15/17] Fix cs
---
modules/ppcp-applepay/extensions.php | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/modules/ppcp-applepay/extensions.php b/modules/ppcp-applepay/extensions.php
index f1e17b10e..64c41b52c 100644
--- a/modules/ppcp-applepay/extensions.php
+++ b/modules/ppcp-applepay/extensions.php
@@ -35,11 +35,11 @@ return array(
'allow_card_button_gateway',
array(
'applepay_button_enabled' => array(
- 'title' => __( 'Apple Pay Button', 'woocommerce-paypal-payments' ),
- 'type' => 'checkbox',
- 'class' => array( 'ppcp-grayed-out-text' ),
- 'input_class' => array( 'ppcp-disabled-checkbox' ),
- 'label' => __( 'Enable Apple Pay button', 'woocommerce-paypal-payments' )
+ 'title' => __( 'Apple Pay Button', 'woocommerce-paypal-payments' ),
+ 'type' => 'checkbox',
+ 'class' => array( 'ppcp-grayed-out-text' ),
+ 'input_class' => array( 'ppcp-disabled-checkbox' ),
+ 'label' => __( 'Enable Apple Pay button', 'woocommerce-paypal-payments' )
. ''
. sprintf(
// translators: %1$s and %2$s are the opening and closing of HTML tag.
@@ -48,10 +48,10 @@ return array(
''
)
. '
',
- 'default' => 'yes',
- 'screens' => array( State::STATE_ONBOARDED ),
- 'gateway' => 'paypal',
- 'requirements' => array(),
+ 'default' => 'yes',
+ 'screens' => array( State::STATE_ONBOARDED ),
+ 'gateway' => 'paypal',
+ 'requirements' => array(),
'custom_attributes' => array(
'data-ppcp-display' => wp_json_encode(
array(
@@ -72,7 +72,7 @@ return array(
$fields,
'allow_card_button_gateway',
array(
- 'applepay_button_enabled' => array(
+ 'applepay_button_enabled' => array(
'title' => __( 'Apple Pay Button', 'woocommerce-paypal-payments' ),
'type' => 'checkbox',
'label' => __( 'Enable Apple Pay button', 'woocommerce-paypal-payments' )
From ccf11e4d8c04dbc445b99aa88f52365d8ebb8bb1 Mon Sep 17 00:00:00 2001
From: carmenmaymo
Date: Thu, 21 Sep 2023 09:53:17 +0200
Subject: [PATCH 16/17] Use checkout form data on payment sheet
---
.../resources/js/ApplepayButton.js | 121 +++++++++++++++---
1 file changed, 101 insertions(+), 20 deletions(-)
diff --git a/modules/ppcp-applepay/resources/js/ApplepayButton.js b/modules/ppcp-applepay/resources/js/ApplepayButton.js
index ab1560e4a..af9720636 100644
--- a/modules/ppcp-applepay/resources/js/ApplepayButton.js
+++ b/modules/ppcp-applepay/resources/js/ApplepayButton.js
@@ -2,6 +2,8 @@ import ContextHandlerFactory from "./Context/ContextHandlerFactory";
import {createAppleErrors} from "./Helper/applePayError";
import {setVisible} from '../../../ppcp-button/resources/js/modules/Helper/Hiding';
import {setEnabled} from '../../../ppcp-button/resources/js/modules/Helper/ButtonDisabler';
+import FormValidator from "../../../ppcp-button/resources/js/modules/Helper/FormValidator";
+import ErrorHandler from '../../../ppcp-button/resources/js/modules/ErrorHandler';
class ApplepayButton {
@@ -13,6 +15,7 @@ class ApplepayButton {
this.buttonConfig = buttonConfig;
this.ppcpConfig = ppcpConfig;
this.paymentsClient = null;
+ this.form_saved = false;
this.contextHandler = ContextHandlerFactory.create(
this.context,
@@ -42,14 +45,14 @@ class ApplepayButton {
if (isEligible) {
this.fetchTransactionInfo().then(() => {
const isSubscriptionProduct = this.ppcpConfig.data_client_id.has_subscriptions === true;
- if(isSubscriptionProduct) {
+ if (isSubscriptionProduct) {
return;
}
this.addButton();
const id_minicart = "#apple-" + this.buttonConfig.button.mini_cart_wrapper;
const id = "#apple-" + this.buttonConfig.button.wrapper;
- if(this.context === 'mini-cart') {
+ if (this.context === 'mini-cart') {
document.querySelector(id_minicart).addEventListener('click', (evt) => {
evt.preventDefault();
this.onButtonClick();
@@ -60,10 +63,13 @@ class ApplepayButton {
this.onButtonClick();
});
}
+
+ // Listen for changes on any input within the WooCommerce checkout form
+ jQuery('form.checkout').on('change', 'input, select, textarea', () => {
+ this.fetchTransactionInfo();
+ });
});
}
- console.log('[ApplePayButton] init done', this.buttonConfig.ajax_url);
-
}
async fetchTransactionInfo() {
this.transactionInfo = await this.contextHandler.transactionInfo();
@@ -103,7 +109,6 @@ class ApplepayButton {
}
jQuery(document).on('ppcp-shown ppcp-hidden ppcp-enabled ppcp-disabled', (ev, data) => {
- console.log('[ApplePayButton] initEventHandlers', ev, data)
if (jQuery(data.selector).is(ppcpButtonWrapper)) {
syncButtonVisibility();
}
@@ -122,6 +127,7 @@ class ApplepayButton {
}
session.onvalidatemerchant = this.onvalidatemerchant(session);
session.onpaymentauthorized = this.onpaymentauthorized(session);
+ return session;
}
@@ -131,19 +137,15 @@ class ApplepayButton {
* Add a Apple Pay purchase button
*/
addButton() {
- console.log('[ApplePayButton] context', this.context);
const wrapper =
(this.context === 'mini-cart')
? this.buttonConfig.button.mini_cart_wrapper
: this.buttonConfig.button.wrapper;
-console.log('[ApplePayButton] wrapper', wrapper)
const shape =
(this.context === 'mini-cart')
? this.ppcpConfig.button.mini_cart_style.shape
: this.ppcpConfig.button.style.shape;
const appleContainer = this.context === 'mini-cart' ? document.getElementById("applepay-container-minicart") : document.getElementById("applepay-container");
- console.log('[ApplePayButton] shape', shape)
- console.log('[ApplePayButton] container', appleContainer)
const type = this.buttonConfig.button.type;
const language = this.buttonConfig.button.lang;
const color = this.buttonConfig.button.color;
@@ -152,7 +154,6 @@ console.log('[ApplePayButton] wrapper', wrapper)
jQuery('#' + wrapper).addClass('ppcp-button-' + shape);
jQuery(wrapper).append(appleContainer);
- console.log('[ApplePayButton] addButton', wrapper, appleContainer);
}
//------------------------
@@ -162,13 +163,58 @@ console.log('[ApplePayButton] wrapper', wrapper)
/**
* Show Apple Pay payment sheet when Apple Pay payment button is clicked
*/
- onButtonClick() {
+ async onButtonClick() {
const paymentDataRequest = this.paymentDataRequest();
- console.log('[ApplePayButton] onButtonClick: paymentDataRequest', paymentDataRequest, this.context);
-
+ // trigger woocommerce validation if we are in the checkout page
+ if (this.context === 'checkout') {
+ const checkoutFormSelector = 'form.woocommerce-checkout';
+ const errorHandler = new ErrorHandler(
+ PayPalCommerceGateway.labels.error.generic,
+ document.querySelector('.woocommerce-notices-wrapper')
+ );
+ try {
+ const formData = new FormData(document.querySelector(checkoutFormSelector));
+ this.form_saved = Object.fromEntries(formData.entries());
+ this.update_request_data_with_form(paymentDataRequest);
+ } catch (error) {
+ console.error(error);
+ }
+ const session = this.applePaySession(paymentDataRequest)
+ console.log("session", session)
+ const formValidator = PayPalCommerceGateway.early_checkout_validation_enabled ?
+ new FormValidator(
+ PayPalCommerceGateway.ajax.validate_checkout.endpoint,
+ PayPalCommerceGateway.ajax.validate_checkout.nonce,
+ ) : null;
+ if (formValidator) {
+ try {
+ const errors = await formValidator.validate(document.querySelector(checkoutFormSelector));
+ if (errors.length > 0) {
+ errorHandler.messages(errors);
+ // fire WC event for other plugins
+ jQuery( document.body ).trigger( 'checkout_error' , [ errorHandler.currentHtml() ] );
+ // stop Apple Pay payment sheet from showing
+ session.abort();
+ return;
+ }
+ } catch (error) {
+ console.error(error);
+ }
+ }
+ return;
+ }
this.applePaySession(paymentDataRequest)
}
+ update_request_data_with_form(paymentDataRequest) {
+ paymentDataRequest.billingContact = this.fill_billing_contact(this.form_saved);
+ paymentDataRequest.applicationData = this.fill_application_data(this.form_saved);
+ if (!this.buttonConfig.product.needShipping) {
+ return;
+ }
+ paymentDataRequest.shippingContact = this.fill_shipping_contact(this.form_saved);
+ }
+
paymentDataRequest() {
const applepayConfig = this.applePayConfig
const buttonConfig = this.buttonConfig
@@ -176,12 +222,9 @@ console.log('[ApplePayButton] wrapper', wrapper)
countryCode: applepayConfig.countryCode,
merchantCapabilities: applepayConfig.merchantCapabilities,
supportedNetworks: applepayConfig.supportedNetworks,
- requiredShippingContactFields: ["name", "phone",
- "email", "postalAddress"],
- requiredBillingContactFields: ["name", "phone", "email",
- "postalAddress"]
+ requiredShippingContactFields: ["postalAddress"],
+ requiredBillingContactFields: ["postalAddress"]
}
- console.log('[ApplePayButton] paymentDataRequest', applepayConfig, buttonConfig);
const paymentDataRequest = Object.assign({}, baseRequest);
paymentDataRequest.currencyCode = buttonConfig.shop.currencyCode;
paymentDataRequest.total = {
@@ -199,6 +242,7 @@ console.log('[ApplePayButton] wrapper', wrapper)
//------------------------
onvalidatemerchant(session) {
+ console.log("onvalidatemerchant")
return (applePayValidateMerchantEvent) => {
paypal.Applepay().validateMerchant({
validationUrl: applePayValidateMerchantEvent.validationURL
@@ -236,7 +280,6 @@ console.log('[ApplePayButton] wrapper', wrapper)
onshippingmethodselected(session) {
const ajax_url = this.buttonConfig.ajax_url
console.log('[ApplePayButton] onshippingmethodselected');
-
return (event) => {
const data = this.getShippingMethodData(event);
jQuery.ajax({
@@ -273,7 +316,7 @@ console.log('[ApplePayButton] wrapper', wrapper)
}
onshippingcontactselected(session) {
const ajax_url = this.buttonConfig.ajax_url
-
+ console.log('[ApplePayButton] onshippingcontactselected', ajax_url, session)
return (event) => {
const data = this.getShippingContactData(event);
console.log('shipping contact selected', data, event)
@@ -516,6 +559,44 @@ console.log('[ApplePayButton] wrapper', wrapper)
return response;
}*/
+ fill_billing_contact(form_saved) {
+ return {
+ givenName: form_saved.billing_first_name ?? '',
+ familyName: form_saved.billing_last_name ?? '',
+ emailAddress: form_saved.billing_email ?? '',
+ phoneNumber: form_saved.billing_phone ?? '',
+ addressLines: [form_saved.billing_address_1, form_saved.billing_address_2],
+ locality: form_saved.billing_city ?? '',
+ postalCode: form_saved.billing_postcode ?? '',
+ countryCode: form_saved.billing_country ?? '',
+ administrativeArea: form_saved.billing_state ?? '',
+ }
+ }
+ fill_shipping_contact(form_saved) {
+ if (form_saved.shipping_first_name === "") {
+ return this.fill_billing_contact(form_saved)
+ }
+ return {
+ givenName: (form_saved?.shipping_first_name && form_saved.shipping_first_name !== "") ? form_saved.shipping_first_name : form_saved?.billing_first_name,
+ familyName: (form_saved?.shipping_last_name && form_saved.shipping_last_name !== "") ? form_saved.shipping_last_name : form_saved?.billing_last_name,
+ emailAddress: (form_saved?.shipping_email && form_saved.shipping_email !== "") ? form_saved.shipping_email : form_saved?.billing_email,
+ phoneNumber: (form_saved?.shipping_phone && form_saved.shipping_phone !== "") ? form_saved.shipping_phone : form_saved?.billing_phone,
+ addressLines: [form_saved.shipping_address_1 ?? '', form_saved.shipping_address_2 ?? ''],
+ locality: (form_saved?.shipping_city && form_saved.shipping_city !== "") ? form_saved.shipping_city : form_saved?.billing_city,
+ postalCode: (form_saved?.shipping_postcode && form_saved.shipping_postcode !== "") ? form_saved.shipping_postcode : form_saved?.billing_postcode,
+ countryCode: (form_saved?.shipping_country && form_saved.shipping_country !== "") ? form_saved.shipping_country : form_saved?.billing_country,
+ administrativeArea: (form_saved?.shipping_state && form_saved.shipping_state !== "") ? form_saved.shipping_state : form_saved?.billing_state,
+ }
+ }
+
+ fill_application_data(form_saved) {
+ const jsonString = JSON.stringify(form_saved);
+ let utf8Str = encodeURIComponent(jsonString).replace(/%([0-9A-F]{2})/g, (match, p1) => {
+ return String.fromCharCode('0x' + p1);
+ });
+
+ return btoa(utf8Str);
+ }
}
export default ApplepayButton;
From f862ee6be4511b6d167ab5da8ae3050bc5aae2ef Mon Sep 17 00:00:00 2001
From: Emili Castells Guasch
Date: Thu, 21 Sep 2023 14:52:00 +0200
Subject: [PATCH 17/17] Update phpdoc
---
modules/ppcp-applepay/src/Helper/ApmApplies.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/ppcp-applepay/src/Helper/ApmApplies.php b/modules/ppcp-applepay/src/Helper/ApmApplies.php
index 30c878057..dec9b1a08 100644
--- a/modules/ppcp-applepay/src/Helper/ApmApplies.php
+++ b/modules/ppcp-applepay/src/Helper/ApmApplies.php
@@ -1,6 +1,6 @@