Mollie Payments for WooCommerce - Version 5.8.1

Version Description

  • 08-07-2020 =

  • Feature - Add Apple Pay direct button feature in product and cart pages

Download this release

Release Info

Developer carmen222
Plugin Icon wp plugin Mollie Payments for WooCommerce
Version 5.8.1
Comparing to
See all releases

Code changes from version 5.7.2 to 5.8.1

inc/settings/mollie_apple_pay_button_enabler.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ return [
4
+ 'mollie_apple_pay_button_enabled' => [
5
+ 'type' => 'checkbox',
6
+ 'title' => __('Enable Apple Pay Button', 'mollie-payments-for-woocommerce'),
7
+ 'description' => __(
8
+ 'Enable the Apple Pay direct buy button',
9
+ 'mollie-payments-for-woocommerce'
10
+ ),
11
+ 'default' => 'no',
12
+ ],
13
+ ];
inc/utils.php CHANGED
@@ -149,4 +149,20 @@ function mollieWooCommerceGetDataHelper()
149
  return Mollie_WC_Plugin::getDataHelper();
150
  }
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
149
  return Mollie_WC_Plugin::getDataHelper();
150
  }
151
 
152
+ /**
153
+ * @return bool
154
+ */
155
+ function mollieWooCommerceisApplePayDirectEnabled()
156
+ {
157
+ $applePaySettings = get_option('mollie_wc_gateway_applepay_settings');
158
+ return wc_string_to_bool(
159
+ checkIndexExistOrDefault($applePaySettings, 'mollie_apple_pay_button_enabled', 'no')
160
+ );
161
+ }
162
+
163
+ function checkIndexExistOrDefault($array, $key, $default)
164
+ {
165
+ return isset($array[$key]) ? $array[$key] : $default;
166
+ }
167
+
168
 
mollie-payments-for-woocommerce.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Mollie Payments for WooCommerce
4
  * Plugin URI: https://www.mollie.com
5
  * Description: Accept payments in WooCommerce with the official Mollie plugin
6
- * Version: 5.7.2
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
  * Requires at least: 3.8
3
  * Plugin Name: Mollie Payments for WooCommerce
4
  * Plugin URI: https://www.mollie.com
5
  * Description: Accept payments in WooCommerce with the official Mollie plugin
6
+ * Version: 5.8.1
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
  * Requires at least: 3.8
public/css/mollie-applepaydirect.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .buttonDisabled{opacity:.2}.apple-pay-button{display:inline-block;-webkit-appearance:-apple-pay-button;-apple-pay-button-type:checkout}.apple-pay-button-black{-apple-pay-button-style:#000}.apple-pay-button-white{-apple-pay-button-style:#fff}.apple-pay-button-white-with-line{-apple-pay-button-style:white-outline}
public/js/applepayDirect.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){var t={};function n(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(o,a,function(t){return e[t]}.bind(null,a));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/public/js/",n(n.s="fmef")}({OiFV:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var o=function(){var e=window.ApplePaySession,t=document.querySelector("#mollie-applepayDirect-button");if(t&&e&&e.canMakePayments()){var n=document.createElement("button");n.setAttribute("id","mollie_applepay_button"),n.classList.add("apple-pay-button"),n.classList.add("apple-pay-button-black"),t.appendChild(n)}}},fmef:function(e,t,n){"use strict";n.r(t);var o=n("nxB1"),a=n("OiFV"),i=n("uXQx");!function(e){var t=e._,n=e.mollieApplePayDirectData,r=e.jQuery;if(!t.isEmpty(n)){var c=n.product,l=c.id,p=c.needShipping,u=void 0===p||p,s=c.isVariation,d=void 0!==s&&s,f=c.price,m=n.shop,y=m.countryCode,v=m.currencyCode,h=void 0===v?"EUR":v,b=m.totalLabel,g=void 0===b?"":b,_=n.ajaxUrl;if(l&&f&&y&&_){Object(a.a)();var S=document.getElementById("_wpnonce").value,w=l,P=1,j=[],O=[],C="";if(document.querySelector("input.qty").addEventListener("change",(function(e){P=e.currentTarget.value})),d){var x=document.querySelector("#mollie_applepay_button");r(".single_variation_wrap").on("show_variation",(function(e,t){t.variation_id&&(w=t.variation_id),x.disabled=!1,x.classList.remove("buttonDisabled")})),x.disabled=!0,x.classList.add("buttonDisabled")}var M=P*f;document.querySelector("#mollie_applepay_button").addEventListener("click",(function(e){var t=new ApplePaySession(3,Object(i.a)(y,h,g,M));t.begin(),u&&(t.onshippingmethodselected=function(e){var n=this;r.ajax({url:_,method:"POST",data:{action:"mollie_apple_pay_update_shipping_method",shippingMethod:e.shippingMethod,productId:l,callerPage:"productDetail",productQuantity:P,simplifiedContact:j,nonce:S},complete:function(e,t){},success:function(t,a,i){var r=t.data;O=e.shippingMethod,!1===t.success&&(r.errors=Object(o.a)(r.errors)),n.completeShippingMethodSelection(r)},error:function(e,n,o){console.warn(n,o),t.abort()}})},t.onshippingcontactselected=function(e){var n=this;r.ajax({url:_,method:"POST",data:{action:"mollie_apple_pay_update_shipping_contact",productId:l,callerPage:"productDetail",productQuantity:P,simplifiedContact:e.shippingContact,needShipping:u,nonce:S},complete:function(e,t){},success:function(t,a,i){var r=t.data;j=e.shippingContact,!1===t.success&&(r.errors=Object(o.a)(r.errors)),r.newShippingMethods&&(O=r.newShippingMethods[0]),n.completeShippingContactSelection(r)},error:function(e,n,o){console.warn(n,o),t.abort()}})}),t.onvalidatemerchant=function(e){r.ajax({url:_,method:"POST",data:{action:"mollie_apple_pay_validation",validationUrl:e.validationURL,nonce:S},complete:function(e,t){},success:function(e,n,o){!0===e.success?t.completeMerchantValidation(JSON.parse(e.data)):(console.warn(e.data),t.abort())},error:function(e,n,o){console.warn(n,o),t.abort()}})},t.onpaymentauthorized=function(e){r.ajax({url:_,method:"POST",data:{action:"mollie_apple_pay_create_order",productId:w,productQuantity:P,shippingContact:e.payment.shippingContact,billingContact:e.payment.billingContact,token:e.payment.token,shippingMethod:O,"mollie-payments-for-woocommerce_issuer_applepay":"applepay",nonce:S},complete:function(e,t){},success:function(e,n,a){var i=e.data;!0===e.success?(C=i.returnUrl,t.completePayment(i.responseToApple),window.location.href=C):(i.errors=Object(o.a)(i.errors),t.completePayment(i))},error:function(e,n,o){console.warn(n,o),t.abort()}})}}))}}}(window)},nxB1:function(e,t,n){"use strict";function o(e){var t=[],n=!0,o=!1,a=void 0;try{for(var i,r=e[Symbol.iterator]();!(n=(i=r.next()).done);n=!0){var c=i.value,l=c.contactField,p=void 0===l?null:l,u=c.code,s=void 0===u?null:u,d=c.message,f=p?new ApplePayError(s,p,void 0===d?null:d):new ApplePayError(s);t.push(f)}}catch(e){o=!0,a=e}finally{try{n||null==r.return||r.return()}finally{if(o)throw a}}return t}n.d(t,"a",(function(){return o}))},uXQx:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var o=function(e,t,n,o){return{countryCode:e,currencyCode:t,supportedNetworks:["amex","maestro","masterCard","visa","vPay"],merchantCapabilities:["supports3DS"],shippingType:"shipping",requiredBillingContactFields:["postalAddress","email"],requiredShippingContactFields:["postalAddress","email"],total:{label:n,amount:o,type:"final"}}}}});
public/js/applepayDirectCart.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){var t={};function n(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(o,a,function(t){return e[t]}.bind(null,a));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/public/js/",n(n.s="RX5I")}({OiFV:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var o=function(){var e=window.ApplePaySession,t=document.querySelector("#mollie-applepayDirect-button");if(t&&e&&e.canMakePayments()){var n=document.createElement("button");n.setAttribute("id","mollie_applepay_button"),n.classList.add("apple-pay-button"),n.classList.add("apple-pay-button-black"),t.appendChild(n)}}},RX5I:function(e,t,n){"use strict";n.r(t);var o=n("nxB1"),a=n("uXQx"),r=n("OiFV");!function(e){var t=e._,n=e.mollieApplePayDirectDataCart,i=e.jQuery;if(!t.isEmpty(n)){var c=n.product,l=c.needShipping,p=void 0===l||l,u=c.subtotal,s=n.shop,d=s.countryCode,f=s.currencyCode,m=void 0===f?"EUR":f,y=s.totalLabel,h=void 0===y?"":y,b=n.ajaxUrl;if(u&&d&&b){var v=document.getElementById("_wpnonce").value,_=[],g=[],S="",w=function(){var e=new ApplePaySession(3,Object(a.a)(d,m,h,u));e.begin(),e.onshippingmethodselected=function(t){var n=this;i.ajax({url:b,method:"POST",data:{action:"mollie_apple_pay_update_shipping_method",shippingMethod:t.shippingMethod,callerPage:"cart",simplifiedContact:_,nonce:v},complete:function(e,t){},success:function(e,a,r){var i=e.data;g=t.shippingMethod,!1===e.success&&(i.errors=Object(o.a)(i.errors)),n.completeShippingMethodSelection(i)},error:function(t,n,o){console.warn(n,o),e.abort()}})},e.onshippingcontactselected=function(t){var n=this;i.ajax({url:b,method:"POST",data:{action:"mollie_apple_pay_update_shipping_contact",simplifiedContact:t.shippingContact,callerPage:"cart",needShipping:p,nonce:v},complete:function(e,t){},success:function(e,a,r){var i=e.data;_=t.shippingContact,!1===e.success&&(i.errors=Object(o.a)(i.errors)),i.newShippingMethods&&(g=i.newShippingMethods[0]),n.completeShippingContactSelection(i)},error:function(t,n,o){console.warn(n,o),e.abort()}})},e.onvalidatemerchant=function(t){i.ajax({url:b,method:"POST",data:{action:"mollie_apple_pay_validation",validationUrl:t.validationURL,nonce:v},complete:function(e,t){},success:function(t,n,o){!0===t.success?e.completeMerchantValidation(JSON.parse(t.data)):(console.warn(t.data),e.abort())},error:function(t,n,o){console.warn(n,o),e.abort()}})},e.onpaymentauthorized=function(t){i.ajax({url:b,method:"POST",data:{action:"mollie_apple_pay_create_order_cart",shippingContact:t.payment.shippingContact,billingContact:t.payment.billingContact,token:t.payment.token,shippingMethod:g,"mollie-payments-for-woocommerce_issuer_applepay":"applepay",nonce:v},complete:function(e,t){},success:function(t,n,a){var r=t.data;!0===t.success?(S=r.returnUrl,e.completePayment(r.responseToApple),window.location.href=S):(r.errors=Object(o.a)(r.errors),e.completePayment(r))},error:function(t,n,o){console.warn(n,o),e.abort()}})}};Object(r.a)(),i(document.body).on("updated_cart_totals",(function(e){Object(r.a)(),document.querySelector("#mollie_applepay_button").addEventListener("click",(function(e){w()}))})),document.querySelector("#mollie_applepay_button").addEventListener("click",(function(e){w()}))}}}(window)},nxB1:function(e,t,n){"use strict";function o(e){var t=[],n=!0,o=!1,a=void 0;try{for(var r,i=e[Symbol.iterator]();!(n=(r=i.next()).done);n=!0){var c=r.value,l=c.contactField,p=void 0===l?null:l,u=c.code,s=void 0===u?null:u,d=c.message,f=p?new ApplePayError(s,p,void 0===d?null:d):new ApplePayError(s);t.push(f)}}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return t}n.d(t,"a",(function(){return o}))},uXQx:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var o=function(e,t,n,o){return{countryCode:e,currencyCode:t,supportedNetworks:["amex","maestro","masterCard","visa","vPay"],merchantCapabilities:["supports3DS"],shippingType:"shipping",requiredBillingContactFields:["postalAddress","email"],requiredShippingContactFields:["postalAddress","email"],total:{label:n,amount:o,type:"final"}}}}});
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: daanvm, danielhuesken, davdebcom, dinamiko, inpsyde, l.vangunst, n
3
  Tags: mollie, payments, payment gateway, woocommerce, credit card, ideal, bancontact, klarna, sofort, giropay, woocommerce subscriptions
4
  Requires at least: 3.8
5
  Tested up to: 5.3
6
- Stable tag: 5.7.2
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -181,6 +181,10 @@ Automatic updates should work like a charm; as always though, ensure you backup
181
 
182
  == Changelog ==
183
 
 
 
 
 
184
  = 5.7.2 - 01-07-2020 =
185
 
186
  * Fix - Missing MasterCard icon selector
3
  Tags: mollie, payments, payment gateway, woocommerce, credit card, ideal, bancontact, klarna, sofort, giropay, woocommerce subscriptions
4
  Requires at least: 3.8
5
  Tested up to: 5.3
6
+ Stable tag: 5.8.1
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
181
 
182
  == Changelog ==
183
 
184
+ = 5.8.1 - 08-07-2020 =
185
+
186
+ * Feature - Add Apple Pay direct button feature in product and cart pages
187
+
188
  = 5.7.2 - 01-07-2020 =
189
 
190
  * Fix - Missing MasterCard icon selector
src/Mollie/WC/ApplePayButton/AjaxRequests.php ADDED
@@ -0,0 +1,795 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_ApplePayButton_AjaxRequests
4
+ {
5
+ /**
6
+ * @var Mollie_WC_ApplePayButton_ResponsesToApple
7
+ */
8
+ private $responseTemplates;
9
+
10
+ /**
11
+ * Mollie_WC_ApplePayButton_AjaxRequests constructor.
12
+ *
13
+ * @param Mollie_WC_ApplePayButton_ResponsesToApple $responseTemplates
14
+ */
15
+ public function __construct(Mollie_WC_ApplePayButton_ResponsesToApple $responseTemplates)
16
+ {
17
+ $this->responseTemplates = $responseTemplates;
18
+ }
19
+
20
+ /**
21
+ * Adds all the Ajax actions to perform the whole workflow
22
+ */
23
+ public function bootstrapAjaxRequest()
24
+ {
25
+ add_action(
26
+ 'wp_ajax_' . Mollie_WC_ApplePayButton_PropertiesDictionary::VALIDATION,
27
+ array($this, 'validateMerchant')
28
+ );
29
+ add_action(
30
+ 'wp_ajax_nopriv_' . Mollie_WC_ApplePayButton_PropertiesDictionary::VALIDATION,
31
+ array($this, 'validateMerchant')
32
+ );
33
+ add_action(
34
+ 'wp_ajax_' . Mollie_WC_ApplePayButton_PropertiesDictionary::CREATE_ORDER,
35
+ array($this, 'createWcOrder')
36
+ );
37
+ add_action(
38
+ 'wp_ajax_nopriv_' . Mollie_WC_ApplePayButton_PropertiesDictionary::CREATE_ORDER,
39
+ array($this, 'createWcOrder')
40
+ );
41
+ add_action(
42
+ 'wp_ajax_' . Mollie_WC_ApplePayButton_PropertiesDictionary::CREATE_ORDER_CART,
43
+ array($this, 'createWcOrderFromCart')
44
+ );
45
+ add_action(
46
+ 'wp_ajax_nopriv_' . Mollie_WC_ApplePayButton_PropertiesDictionary::CREATE_ORDER_CART,
47
+ array($this, 'createWcOrderFromCart')
48
+ );
49
+ add_action(
50
+ 'wp_ajax_' . Mollie_WC_ApplePayButton_PropertiesDictionary::UPDATE_SHIPPING_CONTACT,
51
+ array($this, 'updateShippingContact')
52
+ );
53
+ add_action(
54
+ 'wp_ajax_nopriv_' . Mollie_WC_ApplePayButton_PropertiesDictionary::UPDATE_SHIPPING_CONTACT,
55
+ array($this, 'updateShippingContact')
56
+ );
57
+ add_action(
58
+ 'wp_ajax_' . Mollie_WC_ApplePayButton_PropertiesDictionary::UPDATE_SHIPPING_METHOD,
59
+ array($this, 'updateShippingMethod')
60
+ );
61
+ add_action(
62
+ 'wp_ajax_nopriv_' . Mollie_WC_ApplePayButton_PropertiesDictionary::UPDATE_SHIPPING_METHOD,
63
+ array($this, 'updateShippingMethod')
64
+ );
65
+ }
66
+ /**
67
+ * Method to validate the merchant against Apple system through Mollie
68
+ * On fail triggers and option that shows an admin notice showing the error
69
+ * On success returns the validation data to the script
70
+ */
71
+ public function validateMerchant()
72
+ {
73
+ $applePayRequestDataObject = $this->applePayDataObjectHttp();
74
+ $applePayRequestDataObject->validationData($_POST);
75
+ if (!$this->isNonceValid($applePayRequestDataObject)) {
76
+ return;
77
+ }
78
+ $validationUrl = $applePayRequestDataObject->validationUrl;
79
+ $completeDomain = get_site_url();
80
+ $removeHttp = ["https://", "http://", "/"];
81
+ $domain = str_replace($removeHttp, "", $completeDomain);
82
+
83
+ try {
84
+ $json = $this->validationApiWalletsEndpointCall(
85
+ $domain,
86
+ $validationUrl
87
+ );
88
+ } catch (\Mollie\Api\Exceptions\ApiException $exc) {
89
+ update_option('mollie_wc_applepay_validated', 'no');
90
+
91
+ wp_send_json_error(
92
+ sprintf(
93
+ __(
94
+ $exc->getMessage(),
95
+ 'mollie-payments-for-woocommerce'
96
+ )
97
+ )
98
+ );
99
+ }
100
+ update_option('mollie_wc_applepay_validated', 'yes');
101
+
102
+ wp_send_json_success($json);
103
+ }
104
+
105
+ /**
106
+ * Method to validate and update the shipping contact of the user
107
+ * It updates the amount paying information if needed
108
+ * On error returns an array of errors to be handled by the script
109
+ * On success returns the new contact data
110
+ */
111
+ public function updateShippingContact()
112
+ {
113
+ $applePayRequestDataObject = $this->applePayDataObjectHttp();
114
+ $applePayRequestDataObject->updateContactData($_POST);
115
+
116
+ if (!$this->isNonceValid($applePayRequestDataObject)) {
117
+ return;
118
+ }
119
+ if ($applePayRequestDataObject->hasErrors()) {
120
+ $this->responseTemplates->responseWithDataErrors($applePayRequestDataObject->errors);
121
+ return;
122
+ }
123
+
124
+ if (!class_exists('WC_Countries')) {
125
+ return;
126
+ }
127
+
128
+ $countries = $this->createWCCountries();
129
+ $allowedSellingCountries = $countries->get_allowed_countries();
130
+ $allowedShippingCountries = $countries->get_shipping_countries();
131
+ $userCountry = $applePayRequestDataObject->simplifiedContact['country'];
132
+ $isAllowedSellingCountry = array_key_exists(
133
+ $userCountry,
134
+ $allowedSellingCountries
135
+ );
136
+
137
+ $isAllowedShippingCountry = array_key_exists(
138
+ $userCountry,
139
+ $allowedShippingCountries
140
+ );
141
+ $productNeedShipping
142
+ = $applePayRequestDataObject->needShipping;
143
+ if (!$isAllowedSellingCountry) {
144
+ $this->responseTemplates->responseWithDataErrors(
145
+ [['errorCode' => 'addressUnserviceable']]
146
+ );
147
+ return;
148
+ }
149
+ if ($productNeedShipping && !$isAllowedShippingCountry) {
150
+ $this->responseTemplates->responseWithDataErrors(
151
+ [['errorCode' => 'addressUnserviceable']]
152
+ );
153
+ return;
154
+ }
155
+
156
+ $paymentDetails = $this->whichCalculateTotals($applePayRequestDataObject);
157
+ $response = $this->responseTemplates->appleFormattedResponse($paymentDetails);
158
+ $this->responseTemplates->responseSuccess($response);
159
+ }
160
+
161
+ /**
162
+ ** Method to validate and update the shipping method selected by the user
163
+ * It updates the amount paying information if needed
164
+ * On error returns an array of errors to be handled by the script
165
+ * On success returns the new contact data
166
+ */
167
+ public function updateShippingMethod()
168
+ {
169
+ $applePayRequestDataObject = $this->applePayDataObjectHttp();
170
+ $applePayRequestDataObject->updateMethodData($_POST);
171
+
172
+ if (!$this->isNonceValid($applePayRequestDataObject)) {
173
+ return;
174
+ }
175
+ if ($applePayRequestDataObject->hasErrors()) {
176
+ $this->responseTemplates->responseWithDataErrors($applePayRequestDataObject->errors);
177
+ }
178
+ $paymentDetails = $this->whichCalculateTotals($applePayRequestDataObject);
179
+ $response = $this->responseTemplates->appleFormattedResponse($paymentDetails);
180
+ $this->responseTemplates->responseSuccess($response);
181
+ }
182
+
183
+ /**
184
+ * Creates the order from the product detail page and process the payment
185
+ * On error returns an array of errors to be handled by the script
186
+ * On success returns the status success for Apple to close the transaction
187
+ * and the url to redirect the user
188
+ *
189
+ * @throws WC_Data_Exception
190
+ * @throws \Mollie\Api\Exceptions\ApiException
191
+ */
192
+ public function createWcOrder()
193
+ {
194
+ $applePayRequestDataObject = $this->applePayDataObjectHttp();
195
+ $applePayRequestDataObject->orderData($_POST, 'productDetail');
196
+ if (!$this->isNonceValid($applePayRequestDataObject)) {
197
+ return;
198
+ }
199
+ if ($applePayRequestDataObject->hasErrors()) {
200
+ $this->responseTemplates->responseWithDataErrors($applePayRequestDataObject->errors);
201
+ }
202
+ $order = wc_create_order();
203
+ $order->add_product(
204
+ wc_get_product($applePayRequestDataObject->productId),
205
+ $applePayRequestDataObject->productQuantity
206
+ );
207
+ $order = $this->addAddressesToOrder($applePayRequestDataObject, $order);
208
+
209
+ if(isset($applePayRequestDataObject->shippingMethod)){
210
+ $order = $this->addShippingMethodsToOrder(
211
+ $applePayRequestDataObject->shippingMethod,
212
+ $applePayRequestDataObject->shippingAddress,
213
+ $order
214
+ );
215
+ }
216
+
217
+ $orderId = $order->get_id();
218
+
219
+ $order->calculate_totals();
220
+
221
+ $this->updateOrderPostMeta($orderId, $order);
222
+ $result = $this->processOrderPayment($orderId);
223
+
224
+ if (isset($result['result'])
225
+ && 'success' === $result['result']
226
+ ) {
227
+ $order->payment_complete();
228
+
229
+ $this->responseTemplates->responseSuccess(
230
+ $this->responseTemplates->authorizationResultResponse(
231
+ 'STATUS_SUCCESS',
232
+ $orderId
233
+ )
234
+ );
235
+ } else {
236
+ /* translators: Placeholder 1: Payment method title */
237
+ $message = sprintf(
238
+ __(
239
+ 'Could not create %s payment.',
240
+ 'mollie-payments-for-woocommerce'
241
+ ),
242
+ 'ApplePay'
243
+ );
244
+
245
+ mollieWooCommerceDebug($message, 'error');
246
+ wp_send_json_error(
247
+ $this->responseTemplates->authorizationResultResponse('STATUS_FAILURE')
248
+ );
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Creates the order from the cart page and process the payment
254
+ * On error returns an array of errors to be handled by the script
255
+ * On success returns the status success for Apple to close the transaction
256
+ * and the url to redirect the user
257
+ *
258
+ * @throws WC_Data_Exception
259
+ * @throws \Mollie\Api\Exceptions\ApiException
260
+ */
261
+ public function createWcOrderFromCart()
262
+ {
263
+ $applePayRequestDataObject = $this->applePayDataObjectHttp();
264
+ $applePayRequestDataObject->orderData($_POST, 'cart');
265
+ if (!$this->isNonceValid($applePayRequestDataObject)) {
266
+ return;
267
+ }
268
+
269
+ list($cart, $order) = $this->createOrderFromCart();
270
+ $order = $this->addAddressesToOrder($applePayRequestDataObject, $order);
271
+ $order = $this->addShippingMethodsToOrder(
272
+ $applePayRequestDataObject->shippingMethod,
273
+ $applePayRequestDataObject->shippingAddress,
274
+ $order
275
+ );
276
+ $orderId = $order->get_id();
277
+ $order->calculate_totals();
278
+ $this->updateOrderPostMeta($orderId, $order);
279
+ $result = $this->processOrderPayment($orderId);
280
+ if (isset($result['result'])
281
+ && 'success' === $result['result']
282
+ ) {
283
+ $order->payment_complete();
284
+ $cart->empty_cart();
285
+ $this->responseTemplates->responseSuccess(
286
+ $this->responseTemplates->authorizationResultResponse(
287
+ 'STATUS_SUCCESS',
288
+ $orderId
289
+ )
290
+ );
291
+ } else {
292
+ /* translators: Placeholder 1: Payment method title */
293
+ $message = sprintf(
294
+ __(
295
+ 'Could not create %s payment.',
296
+ 'mollie-payments-for-woocommerce'
297
+ ),
298
+ 'ApplePay'
299
+ );
300
+
301
+ Mollie_WC_Plugin::addNotice($message, 'error');
302
+
303
+ wp_send_json_error(
304
+ $this->responseTemplates->authorizationResultResponse(
305
+ 'STATUS_FAILURE',
306
+ 0,
307
+ [['errorCode' => 'unknown']]
308
+ )
309
+ );
310
+ }
311
+ }
312
+
313
+
314
+
315
+
316
+ /**
317
+ * Data Object to collect and validate all needed data collected
318
+ * through HTTP
319
+ *
320
+ * @return Mollie_WC_ApplePayButton_ApplePayDataObjectHttp
321
+ */
322
+ protected function applePayDataObjectHttp()
323
+ {
324
+ return new Mollie_WC_ApplePayButton_ApplePayDataObjectHttp();
325
+ }
326
+
327
+
328
+ /**
329
+ * Returns a WC_Countries instance to check shipping
330
+ *
331
+ * @return WC_Countries
332
+ */
333
+ protected function createWCCountries()
334
+ {
335
+ $countries = new WC_Countries();
336
+ return $countries;
337
+ }
338
+
339
+ /**
340
+ * Selector between product detail and cart page calculations
341
+ *
342
+ * @param $applePayRequestDataObject
343
+ *
344
+ * @return array|bool
345
+ */
346
+ protected function whichCalculateTotals(
347
+ $applePayRequestDataObject
348
+ ) {
349
+ if ($applePayRequestDataObject->callerPage === 'productDetail') {
350
+ return $this->calculateTotalsSingleProduct(
351
+ $applePayRequestDataObject->productId,
352
+ $applePayRequestDataObject->productQuantity,
353
+ $applePayRequestDataObject->simplifiedContact,
354
+ $applePayRequestDataObject->shippingMethod
355
+ );
356
+ }
357
+ if ($applePayRequestDataObject->callerPage === 'cart') {
358
+ return $this->calculateTotalsCartPage(
359
+ $applePayRequestDataObject->simplifiedContact,
360
+ $applePayRequestDataObject->shippingMethod
361
+ );
362
+ }
363
+ return false;
364
+ }
365
+
366
+ /**
367
+ * Calculates totals for the product with the given information
368
+ * Saves the previous cart to reload it after calculations
369
+ * If no shippingMethodId provided will return the first available shipping
370
+ * method
371
+ *
372
+ * @param $productId
373
+ * @param $productQuantity
374
+ * @param $customerAddress
375
+ * @param null $shippingMethod
376
+ *
377
+ * @return array
378
+ */
379
+ protected function calculateTotalsSingleProduct(
380
+ $productId,
381
+ $productQuantity,
382
+ $customerAddress,
383
+ $shippingMethod = null
384
+ ) {
385
+ $results = [];
386
+ $reloadCart = false;
387
+ if (!WC()->cart->is_empty()) {
388
+ $oldCartContents = WC()->cart->get_cart_contents();
389
+ foreach ($oldCartContents as $cartItemKey => $value) {
390
+ WC()->cart->remove_cart_item($cartItemKey);
391
+ }
392
+ $reloadCart = true;
393
+ }
394
+ try {
395
+ //I just care about apple address details
396
+ $shippingMethodId = '';
397
+ $shippingMethodsArray = [];
398
+ $selectedShippingMethod = [];
399
+ $this->customerAddress($customerAddress);
400
+ $cart = WC()->cart;
401
+ if ($shippingMethod) {
402
+ $shippingMethodId = $shippingMethod['identifier'];
403
+ WC()->session->set(
404
+ 'chosen_shipping_methods',
405
+ array($shippingMethodId)
406
+ );
407
+ }
408
+ $cartItemKey = $cart->add_to_cart($productId, $productQuantity);
409
+ if ($cart->needs_shipping()) {
410
+ list(
411
+ $shippingMethodsArray, $selectedShippingMethod
412
+ )
413
+ = $this->cartShippingMethods(
414
+ $cart,
415
+ $customerAddress,
416
+ $shippingMethod,
417
+ $shippingMethodId
418
+ );
419
+ }
420
+
421
+ $cart->calculate_shipping();
422
+ $cart->calculate_fees();
423
+ $cart->calculate_totals();
424
+
425
+ $results = $this->cartCalculationResults(
426
+ $cart,
427
+ $selectedShippingMethod,
428
+ $shippingMethodsArray
429
+ );
430
+
431
+ $cart->remove_cart_item($cartItemKey);
432
+ $this->customerAddress();
433
+ if ($reloadCart) {
434
+ foreach ($oldCartContents as $cartItemKey => $value) {
435
+ $cart->restore_cart_item($cartItemKey);
436
+ }
437
+ }
438
+ } catch (Exception $e) {
439
+ }
440
+
441
+
442
+ return $results;
443
+ }
444
+
445
+ /**
446
+ * Sets the customer address with ApplePay details to perform correct
447
+ * calculations
448
+ * If no parameter passed then it resets the customer to shop details
449
+ *
450
+ * @param array $address
451
+ */
452
+ protected function customerAddress($address = [])
453
+ {
454
+ $base_location = wc_get_base_location();
455
+ $shopCountryCode = $base_location['country'];
456
+ WC()->customer->set_shipping_country(
457
+ $address['country'] ?: $shopCountryCode
458
+ );
459
+ WC()->customer->set_billing_country(
460
+ $address['country'] ?: $shopCountryCode
461
+ );
462
+ WC()->customer->set_shipping_postcode(
463
+ $address['postcode'] ?: ''
464
+ );
465
+ WC()->customer->set_shipping_city(
466
+ $address['city'] ?: ''
467
+ );
468
+ }
469
+
470
+ /**
471
+ * Add shipping methods to cart to perform correct calculations
472
+ *
473
+ * @param WC_Cart $cart
474
+ * @param $customerAddress
475
+ * @param $shippingMethod
476
+ * @param $shippingMethodId
477
+ *
478
+ * @return array
479
+ */
480
+ protected function cartShippingMethods(
481
+ WC_Cart $cart,
482
+ $customerAddress,
483
+ $shippingMethod,
484
+ $shippingMethodId
485
+ ) {
486
+ $shippingMethodsArray = [];
487
+ $shippingMethods = WC()->shipping->calculate_shipping(
488
+ $this->getShippingPackages(
489
+ $customerAddress,
490
+ $cart->get_total('edit')
491
+ )
492
+ );
493
+ $done = false;
494
+ foreach ($shippingMethods[0]['rates'] as $rate) {
495
+ array_push(
496
+ $shippingMethodsArray,
497
+ [
498
+ "label" => $rate->get_label(),
499
+ "detail" => "",
500
+ "amount" => $rate->get_cost(),
501
+ "identifier" => $rate->get_id()
502
+ ]
503
+ );
504
+ if (!$done) {
505
+ $done = true;
506
+ $shippingMethodId = $shippingMethod ? $shippingMethodId
507
+ : $rate->get_id();
508
+ WC()->session->set(
509
+ 'chosen_shipping_methods',
510
+ array($shippingMethodId)
511
+ );
512
+ }
513
+ }
514
+
515
+ $selectedShippingMethod = $shippingMethodsArray[0];
516
+ if ($shippingMethod) {
517
+ $selectedShippingMethod = $shippingMethod;
518
+ }
519
+
520
+ return array($shippingMethodsArray, $selectedShippingMethod);
521
+ }
522
+
523
+ /**
524
+ * Sets shipping packages for correct calculations
525
+ * @param $customerAddress
526
+ * @param $total
527
+ *
528
+ * @return mixed|void|null
529
+ */
530
+ protected function getShippingPackages($customerAddress, $total)
531
+ {
532
+ // Packages array for storing 'carts'
533
+ $packages = array();
534
+ $packages[0]['contents'] = WC()->cart->cart_contents;
535
+ $packages[0]['contents_cost'] = $total;
536
+ $packages[0]['applied_coupons'] = WC()->session->applied_coupon;
537
+ $packages[0]['destination']['country'] = $customerAddress['country'];
538
+ $packages[0]['destination']['state'] = '';
539
+ $packages[0]['destination']['postcode'] = $customerAddress['postcode'];
540
+ $packages[0]['destination']['city'] = $customerAddress['city'];
541
+ $packages[0]['destination']['address'] = '';
542
+ $packages[0]['destination']['address_2'] = '';
543
+
544
+
545
+ return apply_filters('woocommerce_cart_shipping_packages', $packages);
546
+ }
547
+
548
+ /**
549
+ * Returns the formatted results of the cart calculations
550
+ *
551
+ * @param WC_Cart $cart
552
+ * @param $selectedShippingMethod
553
+ * @param $shippingMethodsArray
554
+ *
555
+ * @return array
556
+ */
557
+ protected function cartCalculationResults(
558
+ WC_Cart $cart,
559
+ $selectedShippingMethod,
560
+ $shippingMethodsArray
561
+ ) {
562
+ return [
563
+ 'subtotal' => $cart->get_subtotal(),
564
+ 'shipping' => [
565
+ 'amount' => $cart->needs_shipping()
566
+ ? $cart->get_shipping_total() : null,
567
+ 'label' => $cart->needs_shipping()
568
+ ? $selectedShippingMethod['label'] : null
569
+ ],
570
+ 'shippingMethods' => $cart->needs_shipping()
571
+ ? $shippingMethodsArray : null,
572
+ 'taxes' => $cart->get_total_tax(),
573
+ 'total' => $cart->get_total('edit')
574
+ ];
575
+ }
576
+
577
+ /**
578
+ * Calculates totals for the cart page with the given information
579
+ * If no shippingMethodId provided will return the first available shipping
580
+ * method
581
+ *
582
+ * @param $customerAddress
583
+ * @param null $shippingMethodId
584
+ *
585
+ * @return array
586
+ */
587
+ protected function calculateTotalsCartPage(
588
+ $customerAddress = null,
589
+ $shippingMethodId = null
590
+ ) {
591
+ $results = [];
592
+ if (WC()->cart->is_empty()) {
593
+ return [];
594
+ }
595
+ try {
596
+ $shippingMethodsArray = [];
597
+ $selectedShippingMethod = [];
598
+ //I just care about apple address details
599
+ $this->customerAddress($customerAddress);
600
+ $cart = WC()->cart;
601
+ if ($shippingMethodId) {
602
+ WC()->session->set(
603
+ 'chosen_shipping_methods',
604
+ array($shippingMethodId['identifier'])
605
+ );
606
+ }
607
+
608
+ if ($cart->needs_shipping()) {
609
+ list(
610
+ $shippingMethodsArray, $selectedShippingMethod
611
+ )
612
+ = $this->cartShippingMethods(
613
+ $cart,
614
+ $customerAddress,
615
+ $shippingMethodId,
616
+ $shippingMethodId['identifier']
617
+ );
618
+ }
619
+ $cart->calculate_shipping();
620
+ $cart->calculate_fees();
621
+ $cart->calculate_totals();
622
+
623
+ $results = $this->cartCalculationResults(
624
+ $cart,
625
+ $selectedShippingMethod,
626
+ $shippingMethodsArray
627
+ );
628
+
629
+ $this->customerAddress();
630
+ } catch (Exception $e) {
631
+ }
632
+
633
+ return $results;
634
+ }
635
+
636
+ /**
637
+ * Add address billing and shipping data to order
638
+ *
639
+ * @param Mollie_WC_ApplePayButton_ApplePayDataObjectHttp $applePayRequestDataObject
640
+ * @param $order
641
+ *
642
+ * @return mixed
643
+ */
644
+ protected function addAddressesToOrder(
645
+ Mollie_WC_ApplePayButton_ApplePayDataObjectHttp $applePayRequestDataObject,
646
+ $order
647
+ ) {
648
+ $billingAddress = $applePayRequestDataObject->billingAddress;
649
+ $shippingAddress = $applePayRequestDataObject->shippingAddress;
650
+ //apple puts email in shippingAddress while we get it from WC's billingAddress
651
+ $billingAddress['email'] = $shippingAddress['email'];
652
+ $billingAddress['phone'] = $shippingAddress['phone'];
653
+
654
+ $order->set_address($billingAddress, 'billing');
655
+ $order->set_address($shippingAddress, 'shipping');
656
+ return $order;
657
+ }
658
+
659
+ /**
660
+ * Add shipping methods to order
661
+ *
662
+ * @param array $shippingMethod
663
+ * @param array $shippingAddress
664
+ * @param $order
665
+ *
666
+ * @return mixed
667
+ */
668
+ protected function addShippingMethodsToOrder(
669
+ array $shippingMethod,
670
+ array $shippingAddress,
671
+ $order
672
+ ) {
673
+ if ($shippingMethod) {
674
+ $calculate_tax_for = array(
675
+ 'country' => $shippingAddress['country'],
676
+ 'state' => $shippingAddress['state'],
677
+ 'postcode' => $shippingAddress['postcode'],
678
+ 'city' => $shippingAddress['city'],
679
+ );
680
+ $item = new WC_Order_Item_Shipping();
681
+ $ratesIds = explode(":", $shippingMethod['identifier']);
682
+ $shippingMethodId = $ratesIds[0];
683
+ $shippingInstanceId = $ratesIds[1];
684
+
685
+ $item->set_props(
686
+ array(
687
+ 'method_title' => $shippingMethod['label'],
688
+ 'method_id' => $shippingMethodId,
689
+ 'instance_id' => $shippingInstanceId,
690
+ 'total' => wc_format_decimal(
691
+ $shippingMethod['amount']
692
+ ),
693
+ )
694
+ );
695
+ $item->calculate_taxes($calculate_tax_for);
696
+ $order->add_item($item);
697
+ }
698
+ return $order;
699
+ }
700
+
701
+ /**
702
+ * Update order post meta
703
+ *
704
+ * @param string $orderId
705
+ * @param $order
706
+ */
707
+ protected function updateOrderPostMeta($orderId, $order)
708
+ {
709
+ //this is the logged one, if not logged in then create a new one?
710
+ update_post_meta($orderId, '_customer_user', get_current_user_id());
711
+ update_post_meta(
712
+ $orderId,
713
+ '_payment_method',
714
+ 'mollie_wc_gateway_applepay'
715
+ );
716
+ update_post_meta($orderId, '_payment_method_title', 'Apple Pay');
717
+ $order->update_status(
718
+ 'Processing',
719
+ 'Apple Pay direct order',
720
+ true
721
+ );
722
+ }
723
+
724
+ /**
725
+ * Process order payment with ApplePay gateway
726
+ *
727
+ * @param int $orderId
728
+ *
729
+ * @return array|string[]
730
+ * @throws \Mollie\Api\Exceptions\ApiException
731
+ */
732
+ protected function processOrderPayment($orderId)
733
+ {
734
+ $gateway = new Mollie_WC_Gateway_Applepay();
735
+
736
+ $result = $gateway->process_payment($orderId);
737
+ return $result;
738
+ }
739
+
740
+ /**
741
+ * Handles the order creation in cart page
742
+ *
743
+ * @return array
744
+ * @throws Exception
745
+ */
746
+ protected function createOrderFromCart()
747
+ {
748
+ $cart = WC()->cart;
749
+ $checkout = WC()->checkout();
750
+ $orderId = $checkout->create_order([]);
751
+ $order = wc_get_order($orderId);
752
+ return array($cart, $order);
753
+ }
754
+
755
+ /**
756
+ * Checks if the nonce in the data object is valid
757
+ *
758
+ * @param Mollie_WC_ApplePayButton_ApplePayDataObjectHttp $applePayRequestDataObject
759
+ *
760
+ * @return bool|int
761
+ */
762
+ protected function isNonceValid(
763
+ Mollie_WC_ApplePayButton_ApplePayDataObjectHttp $applePayRequestDataObject
764
+ ) {
765
+ $isNonceValid = wp_verify_nonce(
766
+ $applePayRequestDataObject->nonce,
767
+ 'mollie_applepay_button'
768
+ );
769
+ return $isNonceValid;
770
+ }
771
+
772
+ /**
773
+ * Calls Mollie API wallets to validate merchant session
774
+ *
775
+ * @param string $domain
776
+ * @param $validationUrl
777
+ *
778
+ * @return false|string
779
+ * @throws \Mollie\Api\Exceptions\ApiException
780
+ */
781
+ protected function validationApiWalletsEndpointCall(
782
+ $domain,
783
+ $validationUrl
784
+ ) {
785
+ $json = Mollie_WC_Plugin::getApiHelper()
786
+ ->getApiClient()
787
+ ->wallets
788
+ ->requestApplePayPaymentSession(
789
+ $domain,
790
+ $validationUrl
791
+ );
792
+ return $json;
793
+ }
794
+
795
+ }
src/Mollie/WC/ApplePayButton/ApplePayDataObjectHttp.php ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_ApplePayButton_ApplePayDataObjectHttp
4
+ {
5
+
6
+ /**
7
+ * @var mixed
8
+ */
9
+ public $nonce;
10
+ /**
11
+ * @var mixed
12
+ */
13
+ public $validationUrl;
14
+ /**
15
+ * @var mixed
16
+ */
17
+ public $simplifiedContact;
18
+ /**
19
+ * @var mixed|null
20
+ */
21
+ public $needShipping;
22
+ /**
23
+ * @var mixed
24
+ */
25
+ public $productId;
26
+ /**
27
+ * @var mixed
28
+ */
29
+ public $productQuantity;
30
+ /**
31
+ * @var array|mixed
32
+ */
33
+ public $shippingMethod;
34
+ /**
35
+ * @var string[]
36
+ */
37
+ public $billingAddress;
38
+ /**
39
+ * @var string[]
40
+ */
41
+ public $shippingAddress;
42
+ /**
43
+ * @var mixed
44
+ */
45
+ public $callerPage;
46
+
47
+ /**
48
+ * @var array
49
+ */
50
+ public $errors = [];
51
+
52
+ /**
53
+ * Resets the errors array
54
+ */
55
+ protected function resetErrors()
56
+ {
57
+ $this->errors = [];
58
+ }
59
+
60
+ /**
61
+ * Returns if the object has any errors
62
+ * @return bool
63
+ */
64
+ public function hasErrors()
65
+ {
66
+ return !empty($this->errors);
67
+ }
68
+
69
+ /**
70
+ * Set the object with the data relevant to ApplePay validation
71
+ *
72
+ * @param array $data
73
+ */
74
+ public function validationData(array $data)
75
+ {
76
+ $this->resetErrors();
77
+ if (!$this->hasRequiredFieldsValuesOrError(
78
+ $data,
79
+ Mollie_WC_ApplePayButton_PropertiesDictionary::VALIDATION_REQUIRED_FIELDS
80
+ )
81
+ ) {
82
+ return;
83
+ }
84
+ $this->assignDataObjectValues($data);
85
+ }
86
+
87
+ /**
88
+ * Set the object with the data relevant to ApplePay on update shipping contact
89
+ * Required data depends on callerPage
90
+ *
91
+ * @param array $data
92
+ */
93
+ public function updateContactData(array $data)
94
+ {
95
+ $result = $this->updateRequiredData(
96
+ $data,
97
+ Mollie_WC_ApplePayButton_PropertiesDictionary::UPDATE_CONTACT_SINGLE_PROD_REQUIRED_FIELDS,
98
+ Mollie_WC_ApplePayButton_PropertiesDictionary::UPDATE_CONTACT_CART_REQUIRED_FIELDS
99
+ );
100
+ if (!$result) {
101
+ return;
102
+ }
103
+ $this->updateSimplifiedContact($data[Mollie_WC_ApplePayButton_PropertiesDictionary::SIMPLIFIED_CONTACT]);
104
+ }
105
+
106
+ /**
107
+ * Set the object with the data relevant to ApplePay on update shipping method
108
+ * Required data depends on callerPage
109
+ *
110
+ * @param array $data
111
+ */
112
+ public function updateMethodData(array $data)
113
+ {
114
+ $result = $this->updateRequiredData(
115
+ $data,
116
+ Mollie_WC_ApplePayButton_PropertiesDictionary::UPDATE_METHOD_SINGLE_PROD_REQUIRED_FIELDS,
117
+ Mollie_WC_ApplePayButton_PropertiesDictionary::UPDATE_METHOD_CART_REQUIRED_FIELDS
118
+ );
119
+ if (!$result) {
120
+ return;
121
+ }
122
+ $this->updateSimplifiedContact($data[Mollie_WC_ApplePayButton_PropertiesDictionary::SIMPLIFIED_CONTACT]);
123
+ $this->updateShippingMethod($data);
124
+ }
125
+
126
+ /**
127
+ * Set the object with the data relevant to ApplePay on authorized order
128
+ * Required data depends on callerPage
129
+ *
130
+ * @param array $data
131
+ * @param $callerPage
132
+ */
133
+ public function orderData(array $data, $callerPage)
134
+ {
135
+ $data[Mollie_WC_ApplePayButton_PropertiesDictionary::CALLER_PAGE] = $callerPage;
136
+ $result = $this->updateRequiredData(
137
+ $data,
138
+ Mollie_WC_ApplePayButton_PropertiesDictionary::CREATE_ORDER_SINGLE_PROD_REQUIRED_FIELDS,
139
+ Mollie_WC_ApplePayButton_PropertiesDictionary::CREATE_ORDER_CART_REQUIRED_FIELDS
140
+ );
141
+ if (!$result) {
142
+ return;
143
+ }
144
+ if (!array_key_exists('emailAddress', $data[Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_CONTACT])
145
+ || !$data[Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_CONTACT]['emailAddress']
146
+ ) {
147
+ $this->errors[] = [
148
+ 'errorCode' => Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_CONTACT_INVALID,
149
+ 'contactField' => 'emailAddress'
150
+ ];
151
+
152
+ return;
153
+ }
154
+
155
+ $filteredShippingContact = filter_var_array(
156
+ $data[Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_CONTACT],
157
+ FILTER_SANITIZE_STRING
158
+ );
159
+ $this->shippingAddress = $this->completeAddress(
160
+ $filteredShippingContact,
161
+ Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_CONTACT_INVALID
162
+ );
163
+ $filteredbillingContact = filter_var_array(
164
+ $data[Mollie_WC_ApplePayButton_PropertiesDictionary::BILLING_CONTACT],
165
+ FILTER_SANITIZE_STRING
166
+ );
167
+ $this->billingAddress = $this->completeAddress(
168
+ $filteredbillingContact,
169
+ Mollie_WC_ApplePayButton_PropertiesDictionary::BILLING_CONTACT_INVALID
170
+ );
171
+ $this->updateShippingMethod($data);
172
+ }
173
+
174
+ /**
175
+ * Checks if the array contains all required fields and if those
176
+ * are not empty.
177
+ * If not it adds an unkown error to the object's error list, as this errors
178
+ * are not supported by ApplePay
179
+ *
180
+ * @param array $data
181
+ * @param array $required
182
+ *
183
+ * @return bool
184
+ */
185
+ protected function hasRequiredFieldsValuesOrError(array $data, array $required)
186
+ {
187
+ foreach ($required as $requiredField) {
188
+ if (!array_key_exists($requiredField, $data)) {
189
+ mollieWooCommerceDebug(
190
+ "ApplePay Data Error: Missing index {$requiredField}"
191
+ );
192
+
193
+ $this->errors[]= ['errorCode' => 'unknown'];
194
+ continue;
195
+ }
196
+ if (!$data[$requiredField]) {
197
+ mollieWooCommerceDebug(
198
+ "ApplePay Data Error: Missing value for {$requiredField}"
199
+ );
200
+ $this->errors[]= ['errorCode' => 'unknown'];
201
+ continue;
202
+ }
203
+ }
204
+ return !$this->hasErrors();
205
+ }
206
+
207
+ /**
208
+ * Sets the value to the appropriate field in the object
209
+ *
210
+ * @param array $data
211
+ */
212
+ protected function assignDataObjectValues(array $data)
213
+ {
214
+ foreach ($data as $key => $value) {
215
+ $filterType = $this->filterType($value);
216
+ $this->$key = filter_var($value, $filterType);
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Selector for the different filters to apply to each field
222
+ * @param $value
223
+ *
224
+ * @return int
225
+ */
226
+ protected function filterType($value)
227
+ {
228
+ $filterInt = [
229
+ Mollie_WC_ApplePayButton_PropertiesDictionary::PRODUCT_QUANTITY,
230
+ Mollie_WC_ApplePayButton_PropertiesDictionary::PRODUCT_ID
231
+ ];
232
+ $filterBoolean = [Mollie_WC_ApplePayButton_PropertiesDictionary::NEED_SHIPPING];
233
+ switch ($value) {
234
+ case in_array($value, $filterInt):
235
+ return FILTER_SANITIZE_NUMBER_INT;
236
+ break;
237
+ case in_array($value, $filterBoolean):
238
+ return FILTER_VALIDATE_BOOLEAN;
239
+ break;
240
+ default:
241
+ return FILTER_SANITIZE_STRING;
242
+ }
243
+ }
244
+
245
+ /**
246
+ * Returns the address details used in pre-authorization steps
247
+ * @param array $contactInfo
248
+ *
249
+ * @return string[]
250
+ *
251
+ */
252
+ protected function simplifiedAddress($contactInfo)
253
+ {
254
+ $required = [
255
+ 'locality' => 'locality',
256
+ 'postalCode' => 'postalCode',
257
+ 'countryCode' => 'countryCode'
258
+ ];
259
+ if (!$this->addressHasRequiredFieldsValues(
260
+ $contactInfo,
261
+ $required,
262
+ Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_CONTACT_INVALID
263
+ )
264
+ ) {
265
+ return [];
266
+ }
267
+ return [
268
+ 'city' => $contactInfo['locality'],
269
+ 'postcode' => $contactInfo['postalCode'],
270
+ 'country' => strtoupper($contactInfo['countryCode'])
271
+ ];
272
+ }
273
+
274
+ /**
275
+ * Checks if the address array contains all required fields and if those
276
+ * are not empty.
277
+ * If not it adds a contacField error to the object's error list
278
+ *
279
+ * @param array $post The address to check
280
+ * @param array $required The required fields for the given address
281
+ * @param string $errorCode Either shipping or billing kind
282
+ *
283
+ * @return bool
284
+ */
285
+ protected function addressHasRequiredFieldsValues(
286
+ array $post,
287
+ array $required,
288
+ $errorCode
289
+ ) {
290
+ foreach ($required as $requiredField => $errorValue) {
291
+ if (!array_key_exists($requiredField, $post)) {
292
+ mollieWooCommerceDebug(
293
+ "ApplePay Data Error: Missing index {$requiredField}"
294
+ );
295
+
296
+ $this->errors[]= ['errorCode' => 'unknown'];
297
+ continue;
298
+ }
299
+ if (!$post[$requiredField]) {
300
+ mollieWooCommerceDebug(
301
+ "ApplePay Data Error: Missing value for {$requiredField}"
302
+ );
303
+ $this->errors[]
304
+ = [
305
+ 'errorCode' => $errorCode,
306
+ 'contactField' => $errorValue
307
+ ];
308
+ continue;
309
+ }
310
+ }
311
+ return !$this->hasErrors();
312
+ }
313
+
314
+ /**
315
+ * Returns the address details for after authorization steps
316
+ *
317
+ * @param array $data
318
+ *
319
+ * @param string $errorCode differentiates between billing and shipping information
320
+ *
321
+ * @return string[]
322
+ */
323
+ protected function completeAddress($data, $errorCode)
324
+ {
325
+ $required = [
326
+ 'givenName' => 'name',
327
+ 'familyName' => 'name',
328
+ 'addressLines' => 'addressLines',
329
+ 'locality' => 'locality',
330
+ 'postalCode' => 'postalCode',
331
+ 'countryCode' => 'countryCode'
332
+ ];
333
+ if (!$this->addressHasRequiredFieldsValues(
334
+ $data,
335
+ $required,
336
+ $errorCode
337
+ )
338
+ ) {
339
+ return [];
340
+ }
341
+ $filter = FILTER_SANITIZE_STRING;
342
+
343
+ return [
344
+ 'first_name' => filter_var($data['givenName'], $filter),
345
+ 'last_name' => filter_var($data['familyName'], $filter),
346
+ 'email' => filter_var($data['emailAddress'], $filter),
347
+ 'phone' => filter_var($data['phoneNumber'], $filter),
348
+ 'address_1' => isset($data['addressLines'][0])
349
+ ? filter_var($data['addressLines'][0], $filter) : '',
350
+ 'address_2' => isset($data['addressLines'][1])
351
+ ? filter_var($data['addressLines'][1], $filter) : '',
352
+ 'city' => filter_var($data['locality'], $filter),
353
+ 'state' => filter_var($data['administrativeArea'], $filter),
354
+ 'postcode' => filter_var($data['postalCode'], $filter),
355
+ 'country' => strtoupper(
356
+ filter_var($data['countryCode'], $filter)
357
+ )
358
+ ];
359
+ }
360
+
361
+ /**
362
+ * @param array $data
363
+ * @param $requiredProductFields
364
+ * @param $requiredCartFields
365
+ */
366
+ protected function updateRequiredData(array $data, $requiredProductFields, $requiredCartFields)
367
+ {
368
+ $this->resetErrors();
369
+ $requiredFields = $requiredProductFields;
370
+ if (isset($data[Mollie_WC_ApplePayButton_PropertiesDictionary::CALLER_PAGE])
371
+ && $data[Mollie_WC_ApplePayButton_PropertiesDictionary::CALLER_PAGE] == 'cart'
372
+ ) {
373
+ $requiredFields = $requiredCartFields;
374
+ }
375
+ $hasRequiredFieldsValues = $this->hasRequiredFieldsValuesOrError(
376
+ $data,
377
+ $requiredFields
378
+ );
379
+ if (!$hasRequiredFieldsValues) {
380
+ return false;
381
+ }
382
+ $this->assignDataObjectValues($data);
383
+ return true;
384
+ }
385
+
386
+ /**
387
+ * @param $data
388
+ */
389
+ protected function updateSimplifiedContact($data)
390
+ {
391
+ $simplifiedContactInfo = filter_var_array(
392
+ $data,
393
+ FILTER_SANITIZE_STRING
394
+ );
395
+ $this->simplifiedContact = $this->simplifiedAddress(
396
+ $simplifiedContactInfo
397
+ );
398
+ }
399
+
400
+ /**
401
+ * @param array $data
402
+ */
403
+ protected function updateShippingMethod(array $data)
404
+ {
405
+ if (array_key_exists(
406
+ Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_METHOD, $data)) {
407
+ $this->shippingMethod = filter_var_array(
408
+ $data[Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_METHOD],
409
+ FILTER_SANITIZE_STRING
410
+ );
411
+ }
412
+ }
413
+ }
src/Mollie/WC/ApplePayButton/DataToAppleButtonScripts.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_ApplePayButton_DataToAppleButtonScripts
4
+ {
5
+ /**
6
+ * Sets the appropriate data to send to ApplePay script
7
+ * Data differs between product page and cart page
8
+ *
9
+ * @return array|bool
10
+ */
11
+ public function applePayScriptData()
12
+ {
13
+ $base_location = wc_get_base_location();
14
+ $shopCountryCode = $base_location['country'];
15
+ $currencyCode = get_woocommerce_currency();
16
+ $totalLabel = get_bloginfo('name');
17
+ if (is_product()) {
18
+ return $this->dataForProductPage(
19
+ $shopCountryCode,
20
+ $currencyCode,
21
+ $totalLabel
22
+ );
23
+ }
24
+ if (is_cart()) {
25
+ return $this->dataForCartPage(
26
+ $shopCountryCode,
27
+ $currencyCode,
28
+ $totalLabel
29
+ );
30
+ }
31
+ return [];
32
+ }
33
+
34
+ /**
35
+ * Check if the product needs shipping
36
+ *
37
+ * @param $product
38
+ *
39
+ * @return bool
40
+ */
41
+ protected function checkIfNeedShipping($product)
42
+ {
43
+ if (!wc_shipping_enabled()
44
+ || 0 === wc_get_shipping_method_count(
45
+ true
46
+ )
47
+ ) {
48
+ return false;
49
+ }
50
+ $needs_shipping = false;
51
+
52
+ if ($product->needs_shipping()) {
53
+ $needs_shipping = true;
54
+ }
55
+
56
+ return $needs_shipping;
57
+ }
58
+
59
+ /**
60
+ * @param $shopCountryCode
61
+ * @param $currencyCode
62
+ * @param $totalLabel
63
+ *
64
+ * @return array|bool
65
+ */
66
+ protected function dataForProductPage(
67
+ $shopCountryCode,
68
+ $currencyCode,
69
+ $totalLabel
70
+ ) {
71
+ $product = wc_get_product(get_the_id());
72
+ if (!$product) {
73
+ return false;
74
+ }
75
+ $isVariation = false;
76
+ if ($product->get_type() === 'variable') {
77
+ $isVariation = true;
78
+ }
79
+ $productNeedShipping = $this->checkIfNeedShipping($product);
80
+ $productId = get_the_id();
81
+ $productPrice = $product->get_price();
82
+
83
+ return [
84
+ 'product' => [
85
+ 'needShipping' => $productNeedShipping,
86
+ 'id' => $productId,
87
+ 'price' => $productPrice,
88
+ 'isVariation' => $isVariation,
89
+ ],
90
+ 'shop' => [
91
+ 'countryCode' => $shopCountryCode,
92
+ 'currencyCode' => $currencyCode,
93
+ 'totalLabel' => $totalLabel
94
+ ],
95
+ 'ajaxUrl' => admin_url('admin-ajax.php')
96
+ ];
97
+ }
98
+
99
+ /**
100
+ * @param $shopCountryCode
101
+ * @param $currencyCode
102
+ * @param $totalLabel
103
+ *
104
+ * @return array
105
+ */
106
+ protected function dataForCartPage(
107
+ $shopCountryCode,
108
+ $currencyCode,
109
+ $totalLabel
110
+ ) {
111
+ $cart = WC()->cart;
112
+
113
+ return [
114
+ 'product' => [
115
+ 'needShipping' => $cart->needs_shipping(),
116
+ 'subtotal' => $cart->get_subtotal(),
117
+
118
+ ],
119
+ 'shop' => [
120
+ 'countryCode' => $shopCountryCode,
121
+ 'currencyCode' => $currencyCode,
122
+ 'totalLabel' => $totalLabel
123
+ ],
124
+ 'ajaxUrl' => admin_url('admin-ajax.php')
125
+ ];
126
+ }
127
+
128
+ }
src/Mollie/WC/ApplePayButton/PropertiesDictionary.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_ApplePayButton_PropertiesDictionary
4
+ {
5
+
6
+ const VALIDATION_REQUIRED_FIELDS
7
+ = [
8
+ Mollie_WC_ApplePayButton_PropertiesDictionary::NONCE,
9
+ Mollie_WC_ApplePayButton_PropertiesDictionary::VALIDATION_URL
10
+ ];
11
+ const BILLING_CONTACT_INVALID = 'billing Contact Invalid';
12
+ const CREATE_ORDER_SINGLE_PROD_REQUIRED_FIELDS
13
+ = [
14
+ Mollie_WC_ApplePayButton_PropertiesDictionary::NONCE,
15
+ Mollie_WC_ApplePayButton_PropertiesDictionary::PRODUCT_ID,
16
+ self::PRODUCT_QUANTITY,
17
+ self::BILLING_CONTACT,
18
+ Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_CONTACT
19
+ ];
20
+ const UPDATE_METHOD_CART_REQUIRED_FIELDS
21
+ = [
22
+ Mollie_WC_ApplePayButton_PropertiesDictionary::NONCE,
23
+ Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_METHOD,
24
+ self::CALLER_PAGE,
25
+ Mollie_WC_ApplePayButton_PropertiesDictionary::SIMPLIFIED_CONTACT
26
+ ];
27
+ const UPDATE_CONTACT_CART_REQUIRED_FIELDS
28
+ = [
29
+ Mollie_WC_ApplePayButton_PropertiesDictionary::NONCE,
30
+ self::CALLER_PAGE,
31
+ Mollie_WC_ApplePayButton_PropertiesDictionary::SIMPLIFIED_CONTACT,
32
+ self::NEED_SHIPPING
33
+ ];
34
+ const UPDATE_CONTACT_SINGLE_PROD_REQUIRED_FIELDS
35
+ = [
36
+ Mollie_WC_ApplePayButton_PropertiesDictionary::NONCE,
37
+ Mollie_WC_ApplePayButton_PropertiesDictionary::PRODUCT_ID,
38
+ self::PRODUCT_QUANTITY,
39
+ self::CALLER_PAGE,
40
+ Mollie_WC_ApplePayButton_PropertiesDictionary::SIMPLIFIED_CONTACT,
41
+
42
+ self::NEED_SHIPPING
43
+ ];
44
+ const VALIDATION_URL = 'validationUrl';
45
+ const UPDATE_METHOD_SINGLE_PROD_REQUIRED_FIELDS
46
+ = [
47
+ Mollie_WC_ApplePayButton_PropertiesDictionary::NONCE,
48
+ Mollie_WC_ApplePayButton_PropertiesDictionary::PRODUCT_ID,
49
+ self::PRODUCT_QUANTITY,
50
+ Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_METHOD,
51
+ self::CALLER_PAGE,
52
+ Mollie_WC_ApplePayButton_PropertiesDictionary::SIMPLIFIED_CONTACT
53
+ ];
54
+ const PRODUCT_ID = 'productId';
55
+ const SIMPLIFIED_CONTACT = 'simplifiedContact';
56
+ const SHIPPING_METHOD = 'shippingMethod';
57
+ const SHIPPING_CONTACT = 'shippingContact';
58
+ const SHIPPING_CONTACT_INVALID = 'shipping Contact Invalid';
59
+ const NONCE = 'nonce';
60
+ const CREATE_ORDER_CART_REQUIRED_FIELDS
61
+ = [
62
+ Mollie_WC_ApplePayButton_PropertiesDictionary::NONCE,
63
+ Mollie_WC_ApplePayButton_PropertiesDictionary::BILLING_CONTACT,
64
+ Mollie_WC_ApplePayButton_PropertiesDictionary::SHIPPING_CONTACT
65
+ ];
66
+ const PRODUCT_QUANTITY = 'productQuantity';
67
+ const CALLER_PAGE = 'callerPage';
68
+ const BILLING_CONTACT = 'billingContact';
69
+ const NEED_SHIPPING = 'needShipping';
70
+ const UPDATE_SHIPPING_CONTACT = 'mollie_apple_pay_update_shipping_contact';
71
+ const UPDATE_SHIPPING_METHOD = 'mollie_apple_pay_update_shipping_method';
72
+ const VALIDATION = 'mollie_apple_pay_validation';
73
+ const CREATE_ORDER = 'mollie_apple_pay_create_order';
74
+ const CREATE_ORDER_CART = 'mollie_apple_pay_create_order_cart';
75
+ const REDIRECT = 'mollie_apple_pay_redirect';
76
+ }
src/Mollie/WC/ApplePayButton/ResponsesToApple.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_ApplePayButton_ResponsesToApple
4
+ {
5
+
6
+ /**
7
+ * Returns the authorization response with according success/fail status
8
+ * Adds the error list if provided to be handled by the script
9
+ * On success it adds the redirection url
10
+ *
11
+ * @param $status 0 => success, 1 => error
12
+ * @param string $orderId
13
+ * @param array $errorList
14
+ *
15
+ * @return array
16
+ */
17
+ public function authorizationResultResponse(
18
+ $status,
19
+ $orderId = '',
20
+ $errorList = []
21
+ ) {
22
+ $response = [];
23
+ if ($status === 'STATUS_SUCCESS') {
24
+ $response['returnUrl'] = $this->redirectUrlOnSuccessfulPayment(
25
+ $orderId
26
+ );
27
+ $response['responseToApple'] = ['status' => 0];
28
+ } else {
29
+ $response = [
30
+ 'status' => 1,
31
+ 'errors' => $this->applePayError($errorList)
32
+ ];
33
+ }
34
+
35
+ return $response;
36
+ }
37
+
38
+ /**
39
+ * Returns an error response to be handled by the script
40
+ *
41
+ * @param array $errorList [['errorCode'=>required, 'contactField'=>'']]
42
+ *
43
+ * @return void
44
+ */
45
+ public function responseWithDataErrors($errorList)
46
+ {
47
+ $response = [];
48
+ $response['errors'] = $this->applePayError($errorList);
49
+ $response['newTotal'] = $this->appleNewTotalResponse(
50
+ 0,
51
+ 'pending'
52
+ );
53
+ wp_send_json_error($response);
54
+ }
55
+
56
+ /**
57
+ * Creates a response formatted for ApplePay
58
+ *
59
+ * @param array $paymentDetails
60
+ *
61
+ * @return array
62
+ */
63
+ public function appleFormattedResponse(array $paymentDetails)
64
+ {
65
+ $response = [];
66
+ if ($paymentDetails['shippingMethods']) {
67
+ $response['newShippingMethods']
68
+ = $paymentDetails['shippingMethods'];
69
+ }
70
+
71
+ $response['newLineItems'] = $this->appleNewLineItemsResponse(
72
+ $paymentDetails
73
+ );
74
+
75
+ $response['newTotal'] = $this->appleNewTotalResponse(
76
+ $paymentDetails['total']
77
+ );
78
+ return $response;
79
+ }
80
+
81
+ /**
82
+ * Returns a success response to be handled by the script
83
+ *
84
+ * @param array $response
85
+ */
86
+ public function responseSuccess(array $response)
87
+ {
88
+ wp_send_json_success($response);
89
+ }
90
+
91
+ /**
92
+ * Creates an array of errors formatted
93
+ *
94
+ * @param array $errorList
95
+ * @param array $errors
96
+ *
97
+ * @return array
98
+ */
99
+ protected function applePayError($errorList, $errors = [])
100
+ {
101
+ foreach ($errorList as $error) {
102
+ array_push(
103
+ $errors,
104
+ [
105
+ "code" => $error['errorCode'],
106
+ "contactField" => array_key_exists('contactField', $error)
107
+ ? $error['contactField'] : null,
108
+ "message" => array_key_exists('contactField', $error)
109
+ ? "Missing {$error['contactField']}" : "",
110
+ ]
111
+ );
112
+ }
113
+
114
+ return $errors;
115
+ }
116
+
117
+ /**
118
+ * Creates NewTotals line
119
+ *
120
+ * @param $total
121
+ *
122
+ * @param string $type
123
+ *
124
+ * @return array
125
+ */
126
+ protected function appleNewTotalResponse($total, $type = 'final')
127
+ {
128
+ return $this->appleItemFormat(
129
+ get_bloginfo('name'),
130
+ $total,
131
+ $type
132
+ );
133
+ }
134
+
135
+ /**
136
+ * Creates item line
137
+ *
138
+ * @param $subtotalLabel
139
+ * @param $subtotal
140
+ * @param $type
141
+ *
142
+ * @return array
143
+ */
144
+ protected function appleItemFormat($subtotalLabel, $subtotal, $type)
145
+ {
146
+ return [
147
+ "label" => $subtotalLabel,
148
+ "amount" => $subtotal,
149
+ "type" => $type
150
+ ];
151
+ }
152
+
153
+ /**
154
+ * Creates NewLineItems line
155
+ *
156
+ * @param array $paymentDetails
157
+ *
158
+ * @return array[]
159
+ */
160
+ protected function appleNewLineItemsResponse(array $paymentDetails)
161
+ {
162
+ $type = 'final';
163
+ $response = [];
164
+ $response[] = $this->appleItemFormat(
165
+ 'Subtotal',
166
+ $paymentDetails['subtotal'],
167
+ $type
168
+ );
169
+
170
+ if ($paymentDetails['shipping']['amount']) {
171
+ $response[]
172
+ = $this->appleItemFormat(
173
+ $paymentDetails['shipping']['label'] ?: '',
174
+ $paymentDetails['shipping']['amount'],
175
+ $type
176
+ );
177
+ }
178
+ $response[]
179
+ = $this->appleItemFormat(
180
+ 'Estimated Tax',
181
+ $paymentDetails['taxes'],
182
+ $type
183
+
184
+ );
185
+ return $response;
186
+ }
187
+
188
+ /**
189
+ * Returns the redirect url to use on successful payment
190
+ *
191
+ * @param $orderId
192
+ *
193
+ * @return string
194
+ */
195
+ protected function redirectUrlOnSuccessfulPayment($orderId)
196
+ {
197
+ $gateway = new Mollie_WC_Gateway_Applepay();
198
+ $order = wc_get_order($orderId);
199
+ $redirect_url = $gateway->getReturnRedirectUrlForOrder($order);
200
+ // Add utm_nooverride query string
201
+ $redirect_url = add_query_arg(['utm_nooverride' => 1], $redirect_url);
202
+ mollieWooCommerceDebug(
203
+ __METHOD__
204
+ . ": Redirect url on return order {$gateway->id}, order {$orderId}: {$redirect_url}"
205
+ );
206
+
207
+ return $redirect_url;
208
+ }
209
+ }
src/Mollie/WC/Gateway/Applepay.php CHANGED
@@ -20,6 +20,15 @@ class Mollie_WC_Gateway_Applepay extends Mollie_WC_Gateway_Abstract
20
 
21
  parent::__construct();
22
  }
 
 
 
 
 
 
 
 
 
23
 
24
  /**
25
  * @return string
@@ -83,4 +92,13 @@ class Mollie_WC_Gateway_Applepay extends Mollie_WC_Gateway_Abstract
83
 
84
  return parent::getInstructions($order, $payment, $admin_instructions, $plain_text);
85
  }
 
 
 
 
 
 
 
 
 
86
  }
20
 
21
  parent::__construct();
22
  }
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ public function init_form_fields()
27
+ {
28
+ parent::init_form_fields();
29
+
30
+ $this->includeApplePayButton();
31
+ }
32
 
33
  /**
34
  * @return string
92
 
93
  return parent::getInstructions($order, $payment, $admin_instructions, $plain_text);
94
  }
95
+
96
+ protected function includeApplePayButton()
97
+ {
98
+ $fields = include Mollie_WC_Plugin::getPluginPath(
99
+ '/inc/settings/mollie_apple_pay_button_enabler.php'
100
+ );
101
+
102
+ $this->form_fields = array_merge($this->form_fields, $fields);
103
+ }
104
  }
src/Mollie/WC/Helper/ApplePayDirectHandler.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_Helper_ApplePayDirectHandler
4
+ {
5
+ /**
6
+ * @var Mollie_WC_Notice_AdminNotice
7
+ */
8
+ private $adminNotice;
9
+ /**
10
+ * @var Mollie_WC_ApplePayButton_AjaxRequests
11
+ */
12
+ private $ajaxRequests;
13
+
14
+ /**
15
+ * Mollie_WC_Helper_ApplePayDirectHandler constructor.
16
+ *
17
+ * @param Mollie_WC_Notice_AdminNotice $notice
18
+ * @param Mollie_WC_ApplePayButton_AjaxRequests $ajaxRequests
19
+ */
20
+ public function __construct(Mollie_WC_Notice_AdminNotice $notice, Mollie_WC_ApplePayButton_AjaxRequests $ajaxRequests)
21
+ {
22
+ $this->adminNotice = $notice;
23
+ $this->ajaxRequests = $ajaxRequests;
24
+
25
+ }
26
+
27
+ /**
28
+ * Initial method that checks if the device is compatible
29
+ * if so puts the button in place
30
+ * and adds all the necessary actions
31
+ */
32
+ public function bootstrap()
33
+ {
34
+ if (!$this->isApplePayCompatible()) {
35
+ $message = sprintf(
36
+ esc_html__(
37
+ '%1$sServer not compliant with Apple requirements%2$s Check %3$sApple Server requirements page%4$s to fix it in order to make the Apple Pay button work',
38
+ 'mollie-payments-for-woocommerce'
39
+ ),
40
+ '<strong>',
41
+ '</strong>',
42
+ '<a href="https://developer.apple.com/documentation/apple_pay_on_the_web/setting_up_your_server">',
43
+ '</a>'
44
+ );
45
+ $this->adminNotice->addAdminNotice('error', $message);
46
+ return;
47
+ }
48
+
49
+ if (!$this->merchantValidated()) {
50
+ $message = sprintf(
51
+ esc_html__(
52
+ '%1$sApple Pay Validation Error%2$s Check %3$sApple Server requirements page%4$s to fix it in order to make the Apple Pay button work',
53
+ 'mollie-payments-for-woocommerce'
54
+ ),
55
+ '<strong>',
56
+ '</strong>',
57
+ '<a href="https://developer.apple.com/documentation/apple_pay_on_the_web/setting_up_your_server">',
58
+ '</a>'
59
+ );
60
+
61
+ $this->adminNotice->addAdminNotice('error', $message);
62
+ }
63
+ add_action(
64
+ 'woocommerce_after_add_to_cart_form',
65
+ function () {
66
+ $this->applePayDirectButton();
67
+ }
68
+ );
69
+ add_action(
70
+ 'woocommerce_cart_totals_after_order_total',
71
+ function () {
72
+ $this->applePayDirectButton();
73
+ }
74
+ );
75
+ admin_url('admin-ajax.php');
76
+ $this->ajaxRequests->bootstrapAjaxRequest();
77
+ }
78
+
79
+ /**
80
+ * Checks if the server is HTTPS
81
+ *
82
+ * @return bool
83
+ */
84
+ private function isApplePayCompatible()
85
+ {
86
+ return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off';
87
+ }
88
+ /**
89
+ * Checks if the merchant has been validated
90
+ *
91
+ * @return bool
92
+ */
93
+ protected function merchantValidated()
94
+ {
95
+ $option = get_option('mollie_wc_applepay_validated', 'yes');
96
+
97
+ return $option == 'yes';
98
+ }
99
+
100
+ /**
101
+ * ApplePay button markup
102
+ */
103
+ protected function applePayDirectButton()
104
+ {
105
+ ?>
106
+ <div id="mollie-applepayDirect-button">
107
+ <?php wp_nonce_field('mollie_applepay_button'); ?>
108
+ </div>
109
+ <?php
110
+ }
111
+ }
112
+
src/Mollie/WC/Notice/AdminNotice.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_Notice_AdminNotice
4
+ {
5
+
6
+ public function addAdminNotice($level, $message)
7
+ {
8
+
9
+ add_action(
10
+ 'admin_notices',
11
+ function() use ($level, $message) {
12
+ ?>
13
+ <div class="notice <?= esc_attr($level) ?>">
14
+ <?= wp_kses_post($message) ?>
15
+ </div>
16
+ <?php
17
+ }
18
+ );
19
+ }
20
+
21
+ }
src/Mollie/WC/Payment/Order.php CHANGED
@@ -189,7 +189,15 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
189
  $paymentRequestData['payment']['cardToken'] = $cardToken;
190
  }
191
 
192
- return $paymentRequestData;
 
 
 
 
 
 
 
 
193
 
194
  }
195
 
189
  $paymentRequestData['payment']['cardToken'] = $cardToken;
190
  }
191
 
192
+ $applePayToken = $_POST['token'];
193
+ $applePayToken = filter_var($applePayToken, FILTER_SANITIZE_STRING);
194
+ if($applePayToken && isset($paymentRequestData['payment'])){
195
+ $encodedApplePayToken = json_encode($applePayToken);
196
+ $paymentRequestData['payment']['applePayPaymentToken'] = $encodedApplePayToken;
197
+ }
198
+
199
+
200
+ return $paymentRequestData;
201
 
202
  }
203
 
src/Mollie/WC/Payment/Payment.php CHANGED
@@ -125,6 +125,12 @@ class Mollie_WC_Payment_Payment extends Mollie_WC_Payment_Object {
125
  $paymentRequestData['cardToken'] = $cardToken;
126
  }
127
 
 
 
 
 
 
 
128
  return $paymentRequestData;
129
 
130
  }
125
  $paymentRequestData['cardToken'] = $cardToken;
126
  }
127
 
128
+ $applePayToken = $_POST['token'];
129
+ $applePayToken = filter_var($applePayToken, FILTER_SANITIZE_STRING);
130
+ if($applePayToken){
131
+ $encodedApplePayToken = json_encode($applePayToken);
132
+ $paymentRequestData['applePayPaymentToken'] = $encodedApplePayToken;
133
+ }
134
  return $paymentRequestData;
135
 
136
  }
src/Mollie/WC/Plugin.php CHANGED
@@ -8,7 +8,7 @@ class Mollie_WC_Plugin
8
  {
9
  const PLUGIN_ID = 'mollie-payments-for-woocommerce';
10
  const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
11
- const PLUGIN_VERSION = '5.7.1';
12
 
13
  const DB_VERSION = '1.0';
14
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
@@ -242,6 +242,7 @@ class Mollie_WC_Plugin
242
  // Enqueue Scripts
243
  add_action('wp_enqueue_scripts', [__CLASS__, 'enqueueFrontendScripts']);
244
  add_action('wp_enqueue_scripts', [__CLASS__, 'enqueueComponentsAssets']);
 
245
 
246
  add_action(
247
  Mollie_WC_Payment_OrderItemsRefunder::ACTION_AFTER_REFUND_ORDER_ITEMS,
@@ -264,6 +265,7 @@ class Mollie_WC_Plugin
264
  return $settings;
265
  }
266
  );
 
267
 
268
  self::initDb();
269
  self::schedulePendingPaymentOrdersExpirationCheck();
@@ -273,6 +275,58 @@ class Mollie_WC_Plugin
273
  self::$initiated = true;
274
  }
275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  /**
277
  * @param Refund $refund
278
  * @param WC_Order $order
@@ -344,6 +398,27 @@ class Mollie_WC_Plugin
344
  filemtime(Mollie_WC_Plugin::getPluginPath('/public/css/mollie-components.min.css')),
345
  'screen'
346
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  wp_register_script('mollie', 'https://js.mollie.com/v1/mollie.js', [], null, true);
348
  wp_register_script(
349
  'mollie-components',
@@ -376,7 +451,7 @@ class Mollie_WC_Plugin
376
  if (is_admin() || !mollieWooCommerceIsCheckoutContext()) {
377
  return;
378
  }
379
-
380
  try {
381
  $merchantProfileId = mollieWooCommerceMerchantProfileId();
382
  } catch (ApiException $exception) {
8
  {
9
  const PLUGIN_ID = 'mollie-payments-for-woocommerce';
10
  const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
11
+ const PLUGIN_VERSION = '5.8.1';
12
 
13
  const DB_VERSION = '1.0';
14
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
242
  // Enqueue Scripts
243
  add_action('wp_enqueue_scripts', [__CLASS__, 'enqueueFrontendScripts']);
244
  add_action('wp_enqueue_scripts', [__CLASS__, 'enqueueComponentsAssets']);
245
+ add_action('wp_enqueue_scripts', [__CLASS__, 'enqueueApplePayDirectScripts']);
246
 
247
  add_action(
248
  Mollie_WC_Payment_OrderItemsRefunder::ACTION_AFTER_REFUND_ORDER_ITEMS,
265
  return $settings;
266
  }
267
  );
268
+ self::mollieApplePayDirectHandling();
269
 
270
  self::initDb();
271
  self::schedulePendingPaymentOrdersExpirationCheck();
275
  self::$initiated = true;
276
  }
277
 
278
+
279
+ /**
280
+ * Enqueues the ApplePay button scripts if enabled and in correct page
281
+ */
282
+ public static function enqueueApplePayDirectScripts()
283
+ {
284
+ if (mollieWooCommerceIsApplePayDirectEnabled() && is_product()) {
285
+ $dataToScripts = new Mollie_WC_ApplePayButton_DataToAppleButtonScripts();
286
+ wp_enqueue_style('mollie-applepaydirect');
287
+ wp_enqueue_script('mollie_applepaydirect');
288
+ wp_localize_script(
289
+ 'mollie_applepaydirect',
290
+ 'mollieApplePayDirectData',
291
+ $dataToScripts->applePayScriptData()
292
+ );
293
+ }
294
+ if (mollieWooCommerceIsApplePayDirectEnabled() && is_cart()) {
295
+ $dataToScripts = new Mollie_WC_ApplePayButton_DataToAppleButtonScripts();
296
+ wp_enqueue_style('mollie-applepaydirect');
297
+ wp_enqueue_script('mollie_applepaydirectCart');
298
+ wp_localize_script(
299
+ 'mollie_applepaydirectCart',
300
+ 'mollieApplePayDirectDataCart',
301
+ $dataToScripts->applePayScriptData()
302
+ );
303
+ }
304
+ }
305
+
306
+ /**
307
+ * Bootstrap the ApplePay button logic if feature enabled
308
+ * Serves the validation string required by Apple when the known url is called
309
+ */
310
+ public static function mollieApplePayDirectHandling()
311
+ {
312
+ if (mollieWooCommerceIsApplePayDirectEnabled()) {
313
+ $requestUri = filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL); //phpcs:ignore
314
+ $validationPath = '/.well-known/apple-developer-merchantid-domain-association';
315
+ if(strpos($requestUri, $validationPath) === 0){
316
+ echo('7B227073704964223A2244394337463730314338433646324336463344363536433039393434453332323030423137364631353245353844393134304331433533414138323436453630222C2276657273696F6E223A312C22637265617465644F6E223A313535373438323935353137362C227369676E6174757265223A22333038303036303932613836343838366637306430313037303261303830333038303032303130313331306633303064303630393630383634383031363530333034303230313035303033303830303630393261383634383836663730643031303730313030303061303830333038323033653633303832303338626130303330323031303230323038363836306636393964396363613730663330306130363038326138363438636533643034303330323330376133313265333032633036303335353034303330633235343137303730366336353230343137303730366336393633363137343639366636653230343936653734363536373732363137343639366636653230343334313230326432303437333333313236333032343036303335353034306230633164343137303730366336353230343336353732373436393636363936333631373436393666366532303431373537343638366637323639373437393331313333303131303630333535303430613063306134313730373036633635323034393665363332653331306233303039303630333535303430363133303235353533333031653137306433313336333033363330333333313338333133363334333035613137306433323331333033363330333233313338333133363334333035613330363233313238333032363036303335353034303330633166363536333633326437333664373032643632373236663662363537323264373336393637366535663535343333343264353334313465343434323466353833313134333031323036303335353034306230633062363934663533323035333739373337343635366437333331313333303131303630333535303430613063306134313730373036633635323034393665363332653331306233303039303630333535303430363133303235353533333035393330313330363037326138363438636533643032303130363038326138363438636533643033303130373033343230303034383233306664616263333963663735653230326335306439396234353132653633376532613930316464366362336530623163643462353236373938663863663465626465383161323561386332316534633333646463653865326139366332663661666131393330333435633465383761343432366365393531623132393561333832303231313330383230323064333034353036303832623036303130353035303730313031303433393330333733303335303630383262303630313035303530373330303138363239363837343734373033613266326636663633373337303265363137303730366336353265363336663664326636663633373337303330333432643631373037303663363536313639363336313333333033323330316430363033353531643065303431363034313430323234333030623961656565643436333139376134613635613239396534323731383231633435333030633036303335353164313330313031666630343032333030303330316630363033353531643233303431383330313638303134323366323439633434663933653465663237653663346636323836633366613262626664326534623330383230313164303630333535316432303034383230313134333038323031313033303832303130633036303932613836343838366637363336343035303133303831666533303831633330363038326230363031303530353037303230323330383162363063383162333532363536633639363136653633363532303666366532303734363836393733323036333635373237343639363636393633363137343635323036323739323036313665373932303730363137323734373932303631373337333735366436353733323036313633363336353730373436313665363336353230366636363230373436383635323037343638363536653230363137303730366336393633363136323663363532303733373436313665363436313732363432303734363537323664373332303631366536343230363336663665363436393734363936663665373332303666363632303735373336353263323036333635373237343639363636393633363137343635323037303666366336393633373932303631366536343230363336353732373436393636363936333631373436393666366532303730373236313633373436393633363532303733373436313734363536643635366537343733326533303336303630383262303630313035303530373032303131363261363837343734373033613266326637373737373732653631373037303663363532653633366636643266363336353732373436393636363936333631373436353631373537343638366637323639373437393266333033343036303335353164316630343264333032623330323961303237613032353836323336383734373437303361326632663633373236633265363137303730366336353265363336663664326636313730373036633635363136393633363133333265363337323663333030653036303335353164306630313031666630343034303330323037383033303066303630393261383634383836663736333634303631643034303230353030333030613036303832613836343863653364303430333032303334393030333034363032323130306461316336336165386265356636346638653131653836353639333762396236396334373262653933656163333233336131363739333665346138643565383330323231303062643561666266383639663363306361323734623266646465346637313731353963623362643731393962326361306666343039646536353961383262323464333038323032656533303832303237356130303330323031303230323038343936643266626633613938646139373330306130363038326138363438636533643034303330323330363733313162333031393036303335353034303330633132343137303730366336353230353236663666373432303433343132303264323034373333333132363330323430363033353530343062306331643431373037303663363532303433363537323734363936363639363336313734363936663665323034313735373436383666373236393734373933313133333031313036303335353034306130633061343137303730366336353230343936653633326533313062333030393036303335353034303631333032353535333330316531373064333133343330333533303336333233333334333633333330356131373064333233393330333533303336333233333334333633333330356133303761333132653330326330363033353530343033306332353431373037303663363532303431373037303663363936333631373436393666366532303439366537343635363737323631373436393666366532303433343132303264323034373333333132363330323430363033353530343062306331643431373037303663363532303433363537323734363936363639363336313734363936663665323034313735373436383666373236393734373933313133333031313036303335353034306130633061343137303730366336353230343936653633326533313062333030393036303335353034303631333032353535333330353933303133303630373261383634386365336430323031303630383261383634386365336430333031303730333432303030346630313731313834313964373634383564353161356532353831303737366538383061326566646537626165346465303864666334623933653133333536643536363562333561653232643039373736306432323465376262613038666437363137636538386362373662623636373062656338653832393834666635343435613338316637333038316634333034363036303832623036303130353035303730313031303433613330333833303336303630383262303630313035303530373330303138363261363837343734373033613266326636663633373337303265363137303730366336353265363336663664326636663633373337303330333432643631373037303663363537323666366637343633363136373333333031643036303335353164306530343136303431343233663234396334346639336534656632376536633466363238366333666132626266643265346233303066303630333535316431333031303166663034303533303033303130316666333031663036303335353164323330343138333031363830313462626230646561313538333338383961613438613939646562656264656261666461636232346162333033373036303335353164316630343330333032653330326361303261613032383836323636383734373437303361326632663633373236633265363137303730366336353265363336663664326636313730373036633635373236663666373436333631363733333265363337323663333030653036303335353164306630313031666630343034303330323031303633303130303630613261383634383836663736333634303630323065303430323035303033303061303630383261383634386365336430343033303230333637303033303634303233303361636637323833353131363939623138366662333563333536636136326266663431376564643930663735346461323865626566313963383135653432623738396638393866373962353939663938643534313064386639646539633266653032333033323264643534343231623061333035373736633564663333383362393036376664313737633263323136643936346663363732363938323132366635346638376137643162393963623962303938393231363130363939306630393932316430303030333138323031386233303832303138373032303130313330383138363330376133313265333032633036303335353034303330633235343137303730366336353230343137303730366336393633363137343639366636653230343936653734363536373732363137343639366636653230343334313230326432303437333333313236333032343036303335353034306230633164343137303730366336353230343336353732373436393636363936333631373436393666366532303431373537343638366637323639373437393331313333303131303630333535303430613063306134313730373036633635323034393665363332653331306233303039303630333535303430363133303235353533303230383638363066363939643963636137306633303064303630393630383634383031363530333034303230313035303061303831393533303138303630393261383634383836663730643031303930333331306230363039326138363438383666373064303130373031333031633036303932613836343838366637306430313039303533313066313730643331333933303335333133303331333033303339333133353561333032613036303932613836343838366637306430313039333433313164333031623330306430363039363038363438303136353033303430323031303530306131306130363038326138363438636533643034303330323330326630363039326138363438383666373064303130393034333132323034323035613437363366643264396534366338346162356331346462383563633833663831303934316536323838306363663138636536376131613630656633356661333030613036303832613836343863653364303430333032303434363330343430323230363436636338323861383361333062353136313731323266633462333532386432373762373937646264333861633064396263643439393864633832303634383032323030366663656534646432316661313165653665353834346561393565643465643034323939636666363333656437623233343461383835613433636431613662303030303030303030303030227D');
317
+ exit();
318
+ }
319
+
320
+ $notices = new Mollie_WC_Notice_AdminNotice();
321
+ $responseTemplates = new Mollie_WC_ApplePayButton_ResponsesToApple();
322
+ $ajaxRequests = new Mollie_WC_ApplePayButton_AjaxRequests( $responseTemplates);
323
+ $applePayHandler = new Mollie_WC_Helper_ApplePayDirectHandler($notices, $ajaxRequests);
324
+ $applePayHandler->bootstrap();
325
+ }
326
+ }
327
+
328
+
329
+
330
  /**
331
  * @param Refund $refund
332
  * @param WC_Order $order
398
  filemtime(Mollie_WC_Plugin::getPluginPath('/public/css/mollie-components.min.css')),
399
  'screen'
400
  );
401
+ wp_register_style(
402
+ 'mollie-applepaydirect',
403
+ Mollie_WC_Plugin::getPluginUrl('/public/css/mollie-applepaydirect.min.css'),
404
+ [],
405
+ filemtime(Mollie_WC_Plugin::getPluginPath('/public/css/mollie-applepaydirect.min.css')),
406
+ 'screen'
407
+ );
408
+ wp_register_script(
409
+ 'mollie_applepaydirect',
410
+ Mollie_WC_Plugin::getPluginUrl('/public/js/applepayDirect.min.js'),
411
+ ['underscore', 'jquery'],
412
+ filemtime(Mollie_WC_Plugin::getPluginPath('/public/js/applepayDirect.min.js')),
413
+ true
414
+ );
415
+ wp_register_script(
416
+ 'mollie_applepaydirectCart',
417
+ Mollie_WC_Plugin::getPluginUrl('/public/js/applepayDirectCart.min.js'),
418
+ ['underscore', 'jquery'],
419
+ filemtime(Mollie_WC_Plugin::getPluginPath('/public/js/applepayDirectCart.min.js')),
420
+ true
421
+ );
422
  wp_register_script('mollie', 'https://js.mollie.com/v1/mollie.js', [], null, true);
423
  wp_register_script(
424
  'mollie-components',
451
  if (is_admin() || !mollieWooCommerceIsCheckoutContext()) {
452
  return;
453
  }
454
+
455
  try {
456
  $merchantProfileId = mollieWooCommerceMerchantProfileId();
457
  } catch (ApiException $exception) {
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit704c776347bd87cd071dc65cc05a5bb2::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit2a4c092891c7dea9ab746c2aa1f610ed::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -163,6 +163,11 @@ return array(
163
  'Mollie\\Api\\Types\\SequenceType' => $vendorDir . '/mollie/mollie-api-php/src/Types/SequenceType.php',
164
  'Mollie\\Api\\Types\\SettlementStatus' => $vendorDir . '/mollie/mollie-api-php/src/Types/SettlementStatus.php',
165
  'Mollie\\Api\\Types\\SubscriptionStatus' => $vendorDir . '/mollie/mollie-api-php/src/Types/SubscriptionStatus.php',
 
 
 
 
 
166
  'Mollie_WC_Components_Styles' => $baseDir . '/src/Mollie/WC/Components/Styles.php',
167
  'Mollie_WC_Components_StylesPropertiesDictionary' => $baseDir . '/src/Mollie/WC/Components/StylesPropertiesDictionary.php',
168
  'Mollie_WC_Exception' => $baseDir . '/src/Mollie/WC/Exception.php',
@@ -193,12 +198,14 @@ return array(
193
  'Mollie_WC_Gateway_Przelewy24' => $baseDir . '/src/Mollie/WC/Gateway/Przelewy24.php',
194
  'Mollie_WC_Gateway_Sofort' => $baseDir . '/src/Mollie/WC/Gateway/Sofort.php',
195
  'Mollie_WC_Helper_Api' => $baseDir . '/src/Mollie/WC/Helper/Api.php',
 
196
  'Mollie_WC_Helper_Data' => $baseDir . '/src/Mollie/WC/Helper/Data.php',
197
  'Mollie_WC_Helper_OrderLines' => $baseDir . '/src/Mollie/WC/Helper/OrderLines.php',
198
  'Mollie_WC_Helper_PaymentFactory' => $baseDir . '/src/Mollie/WC/Helper/PaymentFactory.php',
199
  'Mollie_WC_Helper_PaymentMethodsIconUrl' => $baseDir . '/src/Mollie/WC/Helper/PaymentMethodsIconUrl.php',
200
  'Mollie_WC_Helper_Settings' => $baseDir . '/src/Mollie/WC/Helper/Settings.php',
201
  'Mollie_WC_Helper_Status' => $baseDir . '/src/Mollie/WC/Helper/Status.php',
 
202
  'Mollie_WC_OrderLineStatus' => $baseDir . '/src/Mollie/WC/OrderLineStatus.php',
203
  'Mollie_WC_Payment_Object' => $baseDir . '/src/Mollie/WC/Payment/Object.php',
204
  'Mollie_WC_Payment_Order' => $baseDir . '/src/Mollie/WC/Payment/Order.php',
163
  'Mollie\\Api\\Types\\SequenceType' => $vendorDir . '/mollie/mollie-api-php/src/Types/SequenceType.php',
164
  'Mollie\\Api\\Types\\SettlementStatus' => $vendorDir . '/mollie/mollie-api-php/src/Types/SettlementStatus.php',
165
  'Mollie\\Api\\Types\\SubscriptionStatus' => $vendorDir . '/mollie/mollie-api-php/src/Types/SubscriptionStatus.php',
166
+ 'Mollie_WC_ApplePayButton_AjaxRequests' => $baseDir . '/src/Mollie/WC/ApplePayButton/AjaxRequests.php',
167
+ 'Mollie_WC_ApplePayButton_ApplePayDataObjectHttp' => $baseDir . '/src/Mollie/WC/ApplePayButton/ApplePayDataObjectHttp.php',
168
+ 'Mollie_WC_ApplePayButton_DataToAppleButtonScripts' => $baseDir . '/src/Mollie/WC/ApplePayButton/DataToAppleButtonScripts.php',
169
+ 'Mollie_WC_ApplePayButton_PropertiesDictionary' => $baseDir . '/src/Mollie/WC/ApplePayButton/PropertiesDictionary.php',
170
+ 'Mollie_WC_ApplePayButton_ResponsesToApple' => $baseDir . '/src/Mollie/WC/ApplePayButton/ResponsesToApple.php',
171
  'Mollie_WC_Components_Styles' => $baseDir . '/src/Mollie/WC/Components/Styles.php',
172
  'Mollie_WC_Components_StylesPropertiesDictionary' => $baseDir . '/src/Mollie/WC/Components/StylesPropertiesDictionary.php',
173
  'Mollie_WC_Exception' => $baseDir . '/src/Mollie/WC/Exception.php',
198
  'Mollie_WC_Gateway_Przelewy24' => $baseDir . '/src/Mollie/WC/Gateway/Przelewy24.php',
199
  'Mollie_WC_Gateway_Sofort' => $baseDir . '/src/Mollie/WC/Gateway/Sofort.php',
200
  'Mollie_WC_Helper_Api' => $baseDir . '/src/Mollie/WC/Helper/Api.php',
201
+ 'Mollie_WC_Helper_ApplePayDirectHandler' => $baseDir . '/src/Mollie/WC/Helper/ApplePayDirectHandler.php',
202
  'Mollie_WC_Helper_Data' => $baseDir . '/src/Mollie/WC/Helper/Data.php',
203
  'Mollie_WC_Helper_OrderLines' => $baseDir . '/src/Mollie/WC/Helper/OrderLines.php',
204
  'Mollie_WC_Helper_PaymentFactory' => $baseDir . '/src/Mollie/WC/Helper/PaymentFactory.php',
205
  'Mollie_WC_Helper_PaymentMethodsIconUrl' => $baseDir . '/src/Mollie/WC/Helper/PaymentMethodsIconUrl.php',
206
  'Mollie_WC_Helper_Settings' => $baseDir . '/src/Mollie/WC/Helper/Settings.php',
207
  'Mollie_WC_Helper_Status' => $baseDir . '/src/Mollie/WC/Helper/Status.php',
208
+ 'Mollie_WC_Notice_AdminNotice' => $baseDir . '/src/Mollie/WC/Notice/AdminNotice.php',
209
  'Mollie_WC_OrderLineStatus' => $baseDir . '/src/Mollie/WC/OrderLineStatus.php',
210
  'Mollie_WC_Payment_Object' => $baseDir . '/src/Mollie/WC/Payment/Object.php',
211
  'Mollie_WC_Payment_Order' => $baseDir . '/src/Mollie/WC/Payment/Order.php',
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit704c776347bd87cd071dc65cc05a5bb2
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit704c776347bd87cd071dc65cc05a5bb2
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit704c776347bd87cd071dc65cc05a5bb2', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit704c776347bd87cd071dc65cc05a5bb2', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
- call_user_func(\Composer\Autoload\ComposerStaticInit704c776347bd87cd071dc65cc05a5bb2::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit704c776347bd87cd071dc65cc05a5bb2
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInit704c776347bd87cd071dc65cc05a5bb2::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequire704c776347bd87cd071dc65cc05a5bb2($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequire704c776347bd87cd071dc65cc05a5bb2($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit2a4c092891c7dea9ab746c2aa1f610ed
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit2a4c092891c7dea9ab746c2aa1f610ed', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit2a4c092891c7dea9ab746c2aa1f610ed', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit2a4c092891c7dea9ab746c2aa1f610ed::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInit2a4c092891c7dea9ab746c2aa1f610ed::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire2a4c092891c7dea9ab746c2aa1f610ed($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequire2a4c092891c7dea9ab746c2aa1f610ed($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit704c776347bd87cd071dc65cc05a5bb2
8
  {
9
  public static $files = array (
10
  '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
@@ -229,6 +229,11 @@ class ComposerStaticInit704c776347bd87cd071dc65cc05a5bb2
229
  'Mollie\\Api\\Types\\SequenceType' => __DIR__ . '/..' . '/mollie/mollie-api-php/src/Types/SequenceType.php',
230
  'Mollie\\Api\\Types\\SettlementStatus' => __DIR__ . '/..' . '/mollie/mollie-api-php/src/Types/SettlementStatus.php',
231
  'Mollie\\Api\\Types\\SubscriptionStatus' => __DIR__ . '/..' . '/mollie/mollie-api-php/src/Types/SubscriptionStatus.php',
 
 
 
 
 
232
  'Mollie_WC_Components_Styles' => __DIR__ . '/../..' . '/src/Mollie/WC/Components/Styles.php',
233
  'Mollie_WC_Components_StylesPropertiesDictionary' => __DIR__ . '/../..' . '/src/Mollie/WC/Components/StylesPropertiesDictionary.php',
234
  'Mollie_WC_Exception' => __DIR__ . '/../..' . '/src/Mollie/WC/Exception.php',
@@ -259,12 +264,14 @@ class ComposerStaticInit704c776347bd87cd071dc65cc05a5bb2
259
  'Mollie_WC_Gateway_Przelewy24' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Przelewy24.php',
260
  'Mollie_WC_Gateway_Sofort' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Sofort.php',
261
  'Mollie_WC_Helper_Api' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/Api.php',
 
262
  'Mollie_WC_Helper_Data' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/Data.php',
263
  'Mollie_WC_Helper_OrderLines' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/OrderLines.php',
264
  'Mollie_WC_Helper_PaymentFactory' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/PaymentFactory.php',
265
  'Mollie_WC_Helper_PaymentMethodsIconUrl' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/PaymentMethodsIconUrl.php',
266
  'Mollie_WC_Helper_Settings' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/Settings.php',
267
  'Mollie_WC_Helper_Status' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/Status.php',
 
268
  'Mollie_WC_OrderLineStatus' => __DIR__ . '/../..' . '/src/Mollie/WC/OrderLineStatus.php',
269
  'Mollie_WC_Payment_Object' => __DIR__ . '/../..' . '/src/Mollie/WC/Payment/Object.php',
270
  'Mollie_WC_Payment_Order' => __DIR__ . '/../..' . '/src/Mollie/WC/Payment/Order.php',
@@ -287,10 +294,10 @@ class ComposerStaticInit704c776347bd87cd071dc65cc05a5bb2
287
  public static function getInitializer(ClassLoader $loader)
288
  {
289
  return \Closure::bind(function () use ($loader) {
290
- $loader->prefixLengthsPsr4 = ComposerStaticInit704c776347bd87cd071dc65cc05a5bb2::$prefixLengthsPsr4;
291
- $loader->prefixDirsPsr4 = ComposerStaticInit704c776347bd87cd071dc65cc05a5bb2::$prefixDirsPsr4;
292
- $loader->prefixesPsr0 = ComposerStaticInit704c776347bd87cd071dc65cc05a5bb2::$prefixesPsr0;
293
- $loader->classMap = ComposerStaticInit704c776347bd87cd071dc65cc05a5bb2::$classMap;
294
 
295
  }, null, ClassLoader::class);
296
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit2a4c092891c7dea9ab746c2aa1f610ed
8
  {
9
  public static $files = array (
10
  '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
229
  'Mollie\\Api\\Types\\SequenceType' => __DIR__ . '/..' . '/mollie/mollie-api-php/src/Types/SequenceType.php',
230
  'Mollie\\Api\\Types\\SettlementStatus' => __DIR__ . '/..' . '/mollie/mollie-api-php/src/Types/SettlementStatus.php',
231
  'Mollie\\Api\\Types\\SubscriptionStatus' => __DIR__ . '/..' . '/mollie/mollie-api-php/src/Types/SubscriptionStatus.php',
232
+ 'Mollie_WC_ApplePayButton_AjaxRequests' => __DIR__ . '/../..' . '/src/Mollie/WC/ApplePayButton/AjaxRequests.php',
233
+ 'Mollie_WC_ApplePayButton_ApplePayDataObjectHttp' => __DIR__ . '/../..' . '/src/Mollie/WC/ApplePayButton/ApplePayDataObjectHttp.php',
234
+ 'Mollie_WC_ApplePayButton_DataToAppleButtonScripts' => __DIR__ . '/../..' . '/src/Mollie/WC/ApplePayButton/DataToAppleButtonScripts.php',
235
+ 'Mollie_WC_ApplePayButton_PropertiesDictionary' => __DIR__ . '/../..' . '/src/Mollie/WC/ApplePayButton/PropertiesDictionary.php',
236
+ 'Mollie_WC_ApplePayButton_ResponsesToApple' => __DIR__ . '/../..' . '/src/Mollie/WC/ApplePayButton/ResponsesToApple.php',
237
  'Mollie_WC_Components_Styles' => __DIR__ . '/../..' . '/src/Mollie/WC/Components/Styles.php',
238
  'Mollie_WC_Components_StylesPropertiesDictionary' => __DIR__ . '/../..' . '/src/Mollie/WC/Components/StylesPropertiesDictionary.php',
239
  'Mollie_WC_Exception' => __DIR__ . '/../..' . '/src/Mollie/WC/Exception.php',
264
  'Mollie_WC_Gateway_Przelewy24' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Przelewy24.php',
265
  'Mollie_WC_Gateway_Sofort' => __DIR__ . '/../..' . '/src/Mollie/WC/Gateway/Sofort.php',
266
  'Mollie_WC_Helper_Api' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/Api.php',
267
+ 'Mollie_WC_Helper_ApplePayDirectHandler' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/ApplePayDirectHandler.php',
268
  'Mollie_WC_Helper_Data' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/Data.php',
269
  'Mollie_WC_Helper_OrderLines' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/OrderLines.php',
270
  'Mollie_WC_Helper_PaymentFactory' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/PaymentFactory.php',
271
  'Mollie_WC_Helper_PaymentMethodsIconUrl' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/PaymentMethodsIconUrl.php',
272
  'Mollie_WC_Helper_Settings' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/Settings.php',
273
  'Mollie_WC_Helper_Status' => __DIR__ . '/../..' . '/src/Mollie/WC/Helper/Status.php',
274
+ 'Mollie_WC_Notice_AdminNotice' => __DIR__ . '/../..' . '/src/Mollie/WC/Notice/AdminNotice.php',
275
  'Mollie_WC_OrderLineStatus' => __DIR__ . '/../..' . '/src/Mollie/WC/OrderLineStatus.php',
276
  'Mollie_WC_Payment_Object' => __DIR__ . '/../..' . '/src/Mollie/WC/Payment/Object.php',
277
  'Mollie_WC_Payment_Order' => __DIR__ . '/../..' . '/src/Mollie/WC/Payment/Order.php',
294
  public static function getInitializer(ClassLoader $loader)
295
  {
296
  return \Closure::bind(function () use ($loader) {
297
+ $loader->prefixLengthsPsr4 = ComposerStaticInit2a4c092891c7dea9ab746c2aa1f610ed::$prefixLengthsPsr4;
298
+ $loader->prefixDirsPsr4 = ComposerStaticInit2a4c092891c7dea9ab746c2aa1f610ed::$prefixDirsPsr4;
299
+ $loader->prefixesPsr0 = ComposerStaticInit2a4c092891c7dea9ab746c2aa1f610ed::$prefixesPsr0;
300
+ $loader->classMap = ComposerStaticInit2a4c092891c7dea9ab746c2aa1f610ed::$classMap;
301
 
302
  }, null, ClassLoader::class);
303
  }