Mollie Payments for WooCommerce - Version 6.4.0

Version Description

  • 19-05-2021 =

  • Feature - PayPal Button for digital goods

  • Fix - Repair subscription method triggering on parent order

  • Fix - Surcharge breaking PDF invoices

  • Fix - Mollie Components fail when coupon code is applied on checkout

  • Fix - Test mode notice links to old settings page

  • Fix - nl_NL(formal) wrong translation string

Download this release

Release Info

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

Code changes from version 6.3.0 to 6.4.0

Files changed (105) hide show
  1. inc/settings/mollie_paypal_button_enabler.php +134 -0
  2. inc/utils.php +42 -0
  3. languages/mollie-payments-for-woocommerce-nl_NL.mo +0 -0
  4. languages/mollie-payments-for-woocommerce-nl_NL.po +6 -3
  5. languages/mollie-payments-for-woocommerce-nl_NL_formal.mo +0 -0
  6. languages/mollie-payments-for-woocommerce-nl_NL_formal.po +6 -3
  7. mollie-payments-for-woocommerce.php +2 -2
  8. public/css/mollie-gateway-icons.min.css +1 -1
  9. public/images/PayPal_Buttons/buy-gold-de.png +0 -0
  10. public/images/PayPal_Buttons/buy-gold-en.png +0 -0
  11. public/images/PayPal_Buttons/buy-gold-nl.png +0 -0
  12. public/images/PayPal_Buttons/checkout-gold-de.png +0 -0
  13. public/images/PayPal_Buttons/checkout-gold-en.png +0 -0
  14. public/images/PayPal_Buttons/checkout-gold-nl.png +0 -0
  15. public/images/PayPal_Buttons/checkout-silver-de.png +0 -0
  16. public/images/PayPal_Buttons/checkout-silver-en.png +0 -0
  17. public/images/PayPal_Buttons/checkout-silver-nl.png +0 -0
  18. public/images/PayPal_Buttons/de/buy/pill-black.png +0 -0
  19. public/images/PayPal_Buttons/de/buy/pill-blue.png +0 -0
  20. public/images/PayPal_Buttons/de/buy/pill-golden.png +0 -0
  21. public/images/PayPal_Buttons/de/buy/pill-gray.png +0 -0
  22. public/images/PayPal_Buttons/de/buy/pill-white.png +0 -0
  23. public/images/PayPal_Buttons/de/buy/rounded-black.png +0 -0
  24. public/images/PayPal_Buttons/de/buy/rounded-blue.png +0 -0
  25. public/images/PayPal_Buttons/de/buy/rounded-golden.png +0 -0
  26. public/images/PayPal_Buttons/de/buy/rounded-gray.png +0 -0
  27. public/images/PayPal_Buttons/de/buy/rounded-white.png +0 -0
  28. public/images/PayPal_Buttons/de/checkout/pill-black.png +0 -0
  29. public/images/PayPal_Buttons/de/checkout/pill-blue.png +0 -0
  30. public/images/PayPal_Buttons/de/checkout/pill-golden.png +0 -0
  31. public/images/PayPal_Buttons/de/checkout/pill-gray.png +0 -0
  32. public/images/PayPal_Buttons/de/checkout/pill-white.png +0 -0
  33. public/images/PayPal_Buttons/de/checkout/rounded-black.png +0 -0
  34. public/images/PayPal_Buttons/de/checkout/rounded-blue.png +0 -0
  35. public/images/PayPal_Buttons/de/checkout/rounded-golden.png +0 -0
  36. public/images/PayPal_Buttons/de/checkout/rounded-gray.png +0 -0
  37. public/images/PayPal_Buttons/de/checkout/rounded-white.png +0 -0
  38. public/images/PayPal_Buttons/en/buy/pill-blue.png +0 -0
  39. public/images/PayPal_Buttons/en/buy/pill-golden.png +0 -0
  40. public/images/PayPal_Buttons/en/buy/pill-gray.png +0 -0
  41. public/images/PayPal_Buttons/en/buy/pill-white.png +0 -0
  42. public/images/PayPal_Buttons/en/buy/rounded-black.png +0 -0
  43. public/images/PayPal_Buttons/en/buy/rounded-blue.png +0 -0
  44. public/images/PayPal_Buttons/en/buy/rounded-golden.png +0 -0
  45. public/images/PayPal_Buttons/en/buy/rounded-gray.png +0 -0
  46. public/images/PayPal_Buttons/en/buy/rounded-white.png +0 -0
  47. public/images/PayPal_Buttons/en/checkout/pill-black.png +0 -0
  48. public/images/PayPal_Buttons/en/checkout/pill-blue.png +0 -0
  49. public/images/PayPal_Buttons/en/checkout/pill-golden.png +0 -0
  50. public/images/PayPal_Buttons/en/checkout/pill-gray.png +0 -0
  51. public/images/PayPal_Buttons/en/checkout/pill-white.png +0 -0
  52. public/images/PayPal_Buttons/en/checkout/rounded-black.png +0 -0
  53. public/images/PayPal_Buttons/en/checkout/rounded-blue.png +0 -0
  54. public/images/PayPal_Buttons/en/checkout/rounded-golden.png +0 -0
  55. public/images/PayPal_Buttons/en/checkout/rounded-gray.png +0 -0
  56. public/images/PayPal_Buttons/en/checkout/rounded-white.png +0 -0
  57. public/images/PayPal_Buttons/{buy-gold-fr.png → fr/buy/rounded-gold.png} +0 -0
  58. public/images/PayPal_Buttons/{checkout-gold-fr.png → fr/checkout/rounded-gold.png} +0 -0
  59. public/images/PayPal_Buttons/{checkout-silver-fr.png → fr/checkout/rounded-silver.png} +0 -0
  60. public/images/PayPal_Buttons/nl/buy/pill-black.png +0 -0
  61. public/images/PayPal_Buttons/nl/buy/pill-blue.png +0 -0
  62. public/images/PayPal_Buttons/nl/buy/pill-golden.png +0 -0
  63. public/images/PayPal_Buttons/nl/buy/pill-gray.png +0 -0
  64. public/images/PayPal_Buttons/nl/buy/pill-white.png +0 -0
  65. public/images/PayPal_Buttons/nl/buy/rounded-black.png +0 -0
  66. public/images/PayPal_Buttons/nl/buy/rounded-blue.png +0 -0
  67. public/images/PayPal_Buttons/nl/buy/rounded-golden.png +0 -0
  68. public/images/PayPal_Buttons/nl/buy/rounded-gray.png +0 -0
  69. public/images/PayPal_Buttons/nl/buy/rounded-white.png +0 -0
  70. public/images/PayPal_Buttons/nl/checkout/pill-black.png +0 -0
  71. public/images/PayPal_Buttons/nl/checkout/pill-blue.png +0 -0
  72. public/images/PayPal_Buttons/nl/checkout/pill-golden.png +0 -0
  73. public/images/PayPal_Buttons/nl/checkout/pill-gray.png +0 -0
  74. public/images/PayPal_Buttons/nl/checkout/pill-white.png +0 -0
  75. public/images/PayPal_Buttons/nl/checkout/rounded-black.png +0 -0
  76. public/images/PayPal_Buttons/nl/checkout/rounded-blue.png +0 -0
  77. public/images/PayPal_Buttons/nl/checkout/rounded-golden.png +0 -0
  78. public/images/PayPal_Buttons/nl/checkout/rounded-gray.png +0 -0
  79. public/images/PayPal_Buttons/nl/checkout/rounded-white.png +0 -0
  80. public/images/PayPal_Buttons/{buy-gold-pl.png → pl/buy/rounded-gold.png} +0 -0
  81. public/images/PayPal_Buttons/{checkout-gold-pl.png → pl/checkout/rounded-gold.png} +0 -0
  82. public/images/PayPal_Buttons/{checkout-silver-pl.png → pl/checkout/rounded-silver.png} +0 -0
  83. public/js/applepayDirect.min.js +1 -1
  84. public/js/applepayDirectCart.min.js +1 -1
  85. public/js/entrypoints.json +10 -0
  86. public/js/gatewaySettings.min.js +1 -1
  87. public/js/manifest.json +2 -0
  88. public/js/mollie-components.min.js +1 -1
  89. public/js/paypalButton.min.js +1 -0
  90. public/js/paypalButtonCart.min.js +1 -0
  91. readme.txt +10 -1
  92. src/Mollie/WC/Gateway/Abstract.php +28 -1
  93. src/Mollie/WC/Gateway/PayPal.php +20 -0
  94. src/Mollie/WC/Helper/GatewaySurchargeHandler.php +21 -2
  95. src/Mollie/WC/Helper/MaybeFixSubscription.php +7 -6
  96. src/Mollie/WC/Helper/OrderLines.php +1 -1
  97. src/Mollie/WC/Helper/PayPalButtonHandler.php +105 -0
  98. src/Mollie/WC/Helper/Settings.php +55 -23
  99. src/Mollie/WC/PayPalButton/AjaxRequests.php +238 -0
  100. src/Mollie/WC/PayPalButton/DataToPayPalScripts.php +83 -0
  101. src/Mollie/WC/PayPalButton/PayPalDataObjectHttp.php +174 -0
  102. src/Mollie/WC/PayPalButton/PropertiesDictionary.php +25 -0
  103. src/Mollie/WC/PayPalButton/WCOrderCalculator.php +182 -0
  104. src/Mollie/WC/Payment/Order.php +37 -4
  105. src/Mollie/WC/Plugin.php +77 -3
inc/settings/mollie_paypal_button_enabler.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $pluginName = Mollie_WC_Plugin::PLUGIN_ID;
3
+
4
+ return [
5
+ [
6
+ 'id' => $pluginName . '_' . 'title',
7
+ 'title' => __(
8
+ 'PayPay button display settings',
9
+ 'mollie-payments-for-woocommerce'
10
+ ),
11
+ 'type' => 'title',
12
+ 'description' => sprintf(__(
13
+ '%1sThe PayPal button is optimized for digital goods. And will only appear if the product has no shipping. %2sThe customer\'s address information can only be retrieved if the transaction has been done with the %3sOrders API%4s.%5s%6s',
14
+ 'mollie-payments-for-woocommerce'
15
+ ),'<p>','<p>','<a href="' . esc_url(admin_url('admin.php?page=wc-settings&tab=mollie_settings&section=advanced')) . '">','</a>','</p>','</p>') ,
16
+ ],
17
+ 'mollie_paypal_button_enabled_cart' => [
18
+ 'type' => 'checkbox',
19
+ 'title' => __(
20
+ 'Display on cart page',
21
+ 'mollie-payments-for-woocommerce'
22
+ ),
23
+ 'description' => __(
24
+ 'Enable the PayPal button to be used in the cart page.',
25
+ 'mollie-payments-for-woocommerce'
26
+ ),
27
+ 'default' => 'no',
28
+ ],
29
+ 'mollie_paypal_button_enabled_product' => [
30
+ 'type' => 'checkbox',
31
+ 'title' => __(
32
+ 'Display on product page',
33
+ 'mollie-payments-for-woocommerce'
34
+ ),
35
+ 'description' => __(
36
+ 'Enable the PayPal button to be used in the product page.',
37
+ 'mollie-payments-for-woocommerce'
38
+ ),
39
+ 'default' => 'no',
40
+ ],
41
+ 'color' => [
42
+ 'type' => 'select',
43
+ 'id' => 'mollie_paypal_buttton_color',
44
+ 'title' => _x('Button text language and color', 'Mollie PayPal Button Settings', 'mollie-payments-for-woocommerce'),
45
+ 'description' => sprintf(
46
+ _x(
47
+ 'Select the text and the colour of the button.',
48
+ 'Mollie PayPal Button Settings',
49
+ 'mollie-payments-for-woocommerce'
50
+ )
51
+ ),
52
+ 'default' => 'buy-gold',
53
+ 'options' => [
54
+ 'en-buy-pill-blue' => _x('English -- Buy with PayPal - Pill blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
55
+ 'en-buy-rounded-blue' => _x('English -- Buy with PayPal - Rounded blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
56
+ 'en-buy-pill-golden' => _x('English -- Buy with PayPal - Pill golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
57
+ 'en-buy-rounded-golden' => _x('English -- Buy with PayPal - Rounded golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
58
+ 'en-buy-pill-gray' => _x('English -- Buy with PayPal - Pill gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
59
+ 'en-buy-rounded-gray' => _x('English -- Buy with PayPal - Rounded gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
60
+ 'en-buy-pill-white' => _x('English -- Buy with PayPal - Pill white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
61
+ 'en-buy-rounded-white' => _x('English -- Buy with PayPal - Rounded white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
62
+ 'en-checkout-pill-black' => _x('English -- Checkout with PayPal - Pill black', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
63
+ 'en-checkout-rounded-black' => _x('English -- Checkout with PayPal - Rounded black', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
64
+ 'en-checkout-pill-blue' => _x('English -- Checkout with PayPal - Pill blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
65
+ 'en-checkout-rounded-blue' => _x('English -- Checkout with PayPal - Rounded blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
66
+ 'en-checkout-pill-golden' => _x('English -- Checkout with PayPal - Pill golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
67
+ 'en-checkout-rounded-golden' => _x('English -- Checkout with PayPal - Rounded golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
68
+ 'en-checkout-pill-gray' => _x('English -- Checkout with PayPal - Pill gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
69
+ 'en-checkout-rounded-gray' => _x('English -- Checkout with PayPal - Rounded gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
70
+ 'en-checkout-pill-white' => _x('English -- Checkout with PayPal - Pill white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
71
+ 'en-checkout-rounded-white' => _x('English -- Checkout with PayPal - Rounded white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
72
+ 'nl-buy-pill-black' => _x('Dutch -- Buy with PayPal - Pill black', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
73
+ 'nl-buy-rounded-black' => _x('Dutch -- Buy with PayPal - Rounded black', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
74
+ 'nl-buy-pill-blue' => _x('Dutch -- Buy with PayPal - Pill blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
75
+ 'nl-buy-rounded-blue' => _x('Dutch -- Buy with PayPal - Rounded blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
76
+ 'nl-buy-pill-golden' => _x('Dutch -- Buy with PayPal - Pill golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
77
+ 'nl-buy-rounded-golden' => _x('Dutch -- Buy with PayPal - Rounded golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
78
+ 'nl-buy-pill-gray' => _x('Dutch -- Buy with PayPal - Pill gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
79
+ 'nl-buy-rounded-gray' => _x('Dutch -- Buy with PayPal - Rounded gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
80
+ 'nl-buy-pill-white' => _x('Dutch -- Buy with PayPal - Pill white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
81
+ 'nl-buy-rounded-white' => _x('Dutch -- Buy with PayPal - Rounded white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
82
+ 'nl-checkout-pill-black' => _x('Dutch -- Checkout with PayPal - Pill black', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
83
+ 'nl-checkout-rounded-black' => _x('Dutch -- Checkout with PayPal - Rounded black', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
84
+ 'nl-checkout-pill-blue' => _x('Dutch -- Checkout with PayPal - Pill blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
85
+ 'nl-checkout-rounded-blue' => _x('Dutch -- Checkout with PayPal - Rounded blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
86
+ 'nl-checkout-pill-golden' => _x('Dutch -- Checkout with PayPal - Pill golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
87
+ 'nl-checkout-rounded-golden' => _x('Dutch -- Checkout with PayPal - Rounded golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
88
+ 'nl-checkout-pill-gray' => _x('Dutch -- Checkout with PayPal - Pill gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
89
+ 'nl-checkout-rounded-gray' => _x('Dutch -- Checkout with PayPal - Rounded gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
90
+ 'nl-checkout-pill-white' => _x('Dutch -- Checkout with PayPal - Pill white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
91
+ 'nl-checkout-rounded-white' => _x('Dutch -- Checkout with PayPal - Rounded white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
92
+ 'de-buy-pill-black' => _x('German -- Buy with PayPal - Pill black', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
93
+ 'de-buy-rounded-black' => _x('German -- Buy with PayPal - Rounded black', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
94
+ 'de-buy-pill-blue' => _x('German -- Buy with PayPal - Pill blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
95
+ 'de-buy-rounded-blue' => _x('German -- Buy with PayPal - Rounded blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
96
+ 'de-buy-pill-golden' => _x('German -- Buy with PayPal - Pill golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
97
+ 'de-buy-rounded-golden' => _x('German -- Buy with PayPal - Rounded golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
98
+ 'de-buy-pill-gray' => _x('German -- Buy with PayPal - Pill gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
99
+ 'de-buy-rounded-gray' => _x('German -- Buy with PayPal - Rounded gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
100
+ 'de-buy-pill-white' => _x('German -- Buy with PayPal - Pill white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
101
+ 'de-buy-rounded-white' => _x('German -- Buy with PayPal - Rounded white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
102
+ 'de-checkout-pill-black' => _x('German -- Checkout with PayPal - Pill black', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
103
+ 'de-checkout-rounded-black' => _x('German -- Checkout with PayPal - Rounded black', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
104
+ 'de-checkout-pill-blue' => _x('German -- Checkout with PayPal - Pill blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
105
+ 'de-checkout-rounded-blue' => _x('German -- Checkout with PayPal - Rounded blue', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
106
+ 'de-checkout-pill-golden' => _x('German -- Checkout with PayPal - Pill golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
107
+ 'de-checkout-rounded-golden' => _x('German -- Checkout with PayPal - Rounded golden', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
108
+ 'de-checkout-pill-gray' => _x('German -- Checkout with PayPal - Pill gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
109
+ 'de-checkout-rounded-gray' => _x('German -- Checkout with PayPal - Rounded gray', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
110
+ 'de-checkout-pill-white' => _x('German -- Checkout with PayPal - Pill white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
111
+ 'de-checkout-rounded-white' => _x('German -- Checkout with PayPal - Rounded white', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
112
+ 'fr-buy-rounded-gold' => _x('French -- Buy with PayPal - Gold', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
113
+ 'fr-checkout-rounded-gold' => _x('French -- Checkout with PayPal - Gold', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
114
+ 'fr-checkout-rounded-silver' => _x('French -- Checkout with PayPal - Silver', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
115
+ 'pl-buy-rounded-gold' => _x('Polish -- Buy with PayPal - Gold', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
116
+ 'pl-checkout-rounded-gold' => _x('Polish -- Checkout with PayPal - Gold', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
117
+ 'pl-checkout-rounded-silver' => _x('Polish -- Checkout with PayPal - Silver', 'Mollie PayPal button Settings', 'mollie-payments-for-woocommerce'),
118
+ ],
119
+ ],
120
+ 'mollie_paypal_button_minimum_amount' => [
121
+ 'type' => 'number',
122
+ 'title' => __(
123
+ 'Minimum amount to display button',
124
+ 'mollie-payments-for-woocommerce'
125
+ ),
126
+ 'description' => __(
127
+ 'If the product or the cart total amount is under this number, then the button will not show up.',
128
+ 'mollie-payments-for-woocommerce'
129
+ ),
130
+ 'custom_attributes'=>['step'=>'0.01', 'min'=>'0', 'max'=>'100000000'],
131
+ 'default' => 0,
132
+ 'desc_tip' => true,
133
+ ]
134
+ ];
inc/utils.php CHANGED
@@ -181,6 +181,48 @@ function mollieWooCommerceisApplePayDirectEnabled($page)
181
  $pageToCheck = 'mollie_apple_pay_button_enabled_'.$page;
182
  return mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_applepay_settings', $pageToCheck);
183
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
 
185
  function checkIndexExistOrDefault($array, $key, $default)
186
  {
181
  $pageToCheck = 'mollie_apple_pay_button_enabled_'.$page;
182
  return mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_applepay_settings', $pageToCheck);
183
  }
184
+ /**
185
+ * Check if the PayPal gateway is enabled and then if the button is enabled too.
186
+ *
187
+ * @param $page string setting to check between cart or product
188
+ *
189
+ * @return bool
190
+ */
191
+ function mollieWooCommerceIsPayPalButtonEnabled($page)
192
+ {
193
+ $payPalGatewayEnabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_paypal_settings', 'enabled');
194
+
195
+ if (!$payPalGatewayEnabled) {
196
+ return false;
197
+ }
198
+ $settingToCheck = 'mollie_paypal_button_enabled_'.$page;
199
+ return mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_paypal_settings', $settingToCheck);
200
+ }
201
+
202
+ /**
203
+ * Check if the product needs shipping
204
+ *
205
+ * @param $product
206
+ *
207
+ * @return bool
208
+ */
209
+ function mollieWooCommerceCheckIfNeedShipping($product)
210
+ {
211
+ if (!wc_shipping_enabled()
212
+ || 0 === wc_get_shipping_method_count(
213
+ true
214
+ )
215
+ ) {
216
+ return false;
217
+ }
218
+ $needs_shipping = false;
219
+
220
+ if ($product->needs_shipping()) {
221
+ $needs_shipping = true;
222
+ }
223
+
224
+ return $needs_shipping;
225
+ }
226
 
227
  function checkIndexExistOrDefault($array, $key, $default)
228
  {
languages/mollie-payments-for-woocommerce-nl_NL.mo CHANGED
Binary file
languages/mollie-payments-for-woocommerce-nl_NL.po CHANGED
@@ -2,14 +2,17 @@
2
  # This file is distributed under the same license as the Plugins - Mollie Payments for WooCommerce - Stable (latest release) package.
3
  msgid ""
4
  msgstr ""
5
- "PO-Revision-Date: 2021-02-01 14:16+0100\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
9
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
10
- "X-Generator: GlotPress/3.0.0-alpha.2\n"
11
  "Language: nl\n"
12
  "Project-Id-Version: Plugins - Mollie Payments for WooCommerce - Stable (latest release)\n"
 
 
 
13
 
14
  #: src/Mollie/WC/Plugin.php:620
15
  msgid "Some products in the cart cannot be purchased with the selected gateway. Please, select another gateway"
@@ -713,7 +716,7 @@ msgstr "Bestelstatus na geannuleerde betaling"
713
  #: src/Mollie/WC/Gateway/BankTransfer.php:185
714
  #: src/Mollie/WC/Gateway/DirectDebit.php:80 src/Mollie/WC/Gateway/Ideal.php:121
715
  msgid "Payment completed by <strong>%s</strong> (IBAN (last 4 digits): %s, BIC: %s)"
716
- msgstr "Betaling voltooid met <strong>%s</strong> (IBAN (ten minste 4 cijfers): %s, BIC: %s)"
717
 
718
  #: src/Mollie/WC/Gateway/Abstract.php:1620
719
  msgid "Your order has been cancelled."
2
  # This file is distributed under the same license as the Plugins - Mollie Payments for WooCommerce - Stable (latest release) package.
3
  msgid ""
4
  msgstr ""
5
+ "PO-Revision-Date: 2021-04-12 15:32+0200\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
9
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
10
+ "X-Generator: Poedit 2.4.2\n"
11
  "Language: nl\n"
12
  "Project-Id-Version: Plugins - Mollie Payments for WooCommerce - Stable (latest release)\n"
13
+ "POT-Creation-Date: \n"
14
+ "Last-Translator: \n"
15
+ "Language-Team: \n"
16
 
17
  #: src/Mollie/WC/Plugin.php:620
18
  msgid "Some products in the cart cannot be purchased with the selected gateway. Please, select another gateway"
716
  #: src/Mollie/WC/Gateway/BankTransfer.php:185
717
  #: src/Mollie/WC/Gateway/DirectDebit.php:80 src/Mollie/WC/Gateway/Ideal.php:121
718
  msgid "Payment completed by <strong>%s</strong> (IBAN (last 4 digits): %s, BIC: %s)"
719
+ msgstr "Betaling voltooid met <strong>%s</strong> (IBAN (laatste 4 cijfers): %s, BIC: %s)"
720
 
721
  #: src/Mollie/WC/Gateway/Abstract.php:1620
722
  msgid "Your order has been cancelled."
languages/mollie-payments-for-woocommerce-nl_NL_formal.mo CHANGED
Binary file
languages/mollie-payments-for-woocommerce-nl_NL_formal.po CHANGED
@@ -2,14 +2,17 @@
2
  # This file is distributed under the same license as the Plugins - Mollie Payments for WooCommerce - Stable (latest release) package.
3
  msgid ""
4
  msgstr ""
5
- "PO-Revision-Date: 2021-02-01 14:16+0100\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
9
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
10
- "X-Generator: GlotPress/3.0.0-alpha.2\n"
11
  "Language: nl\n"
12
  "Project-Id-Version: Plugins - Mollie Payments for WooCommerce - Stable (latest release)\n"
 
 
 
13
 
14
  #: src/Mollie/WC/Plugin.php:620
15
  msgid "Some products in the cart cannot be purchased with the selected gateway. Please, select another gateway"
@@ -713,7 +716,7 @@ msgstr "Bestelstatus na geannuleerde betaling"
713
  #: src/Mollie/WC/Gateway/BankTransfer.php:185
714
  #: src/Mollie/WC/Gateway/DirectDebit.php:80 src/Mollie/WC/Gateway/Ideal.php:121
715
  msgid "Payment completed by <strong>%s</strong> (IBAN (last 4 digits): %s, BIC: %s)"
716
- msgstr "Betaling voltooid met <strong>%s</strong> (IBAN (ten minste 4 cijfers): %s, BIC: %s)"
717
 
718
  #: src/Mollie/WC/Gateway/Abstract.php:1620
719
  msgid "Your order has been cancelled."
2
  # This file is distributed under the same license as the Plugins - Mollie Payments for WooCommerce - Stable (latest release) package.
3
  msgid ""
4
  msgstr ""
5
+ "PO-Revision-Date: 2021-04-12 15:32+0200\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
9
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
10
+ "X-Generator: Poedit 2.4.2\n"
11
  "Language: nl\n"
12
  "Project-Id-Version: Plugins - Mollie Payments for WooCommerce - Stable (latest release)\n"
13
+ "POT-Creation-Date: \n"
14
+ "Last-Translator: \n"
15
+ "Language-Team: \n"
16
 
17
  #: src/Mollie/WC/Plugin.php:620
18
  msgid "Some products in the cart cannot be purchased with the selected gateway. Please, select another gateway"
716
  #: src/Mollie/WC/Gateway/BankTransfer.php:185
717
  #: src/Mollie/WC/Gateway/DirectDebit.php:80 src/Mollie/WC/Gateway/Ideal.php:121
718
  msgid "Payment completed by <strong>%s</strong> (IBAN (last 4 digits): %s, BIC: %s)"
719
+ msgstr "Betaling voltooid met <strong>%s</strong> (IBAN (laatste 4 cijfers): %s, BIC: %s)"
720
 
721
  #: src/Mollie/WC/Gateway/Abstract.php:1620
722
  msgid "Your order has been cancelled."
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: 6.3.0
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
  * Requires at least: 3.8
@@ -12,7 +12,7 @@
12
  * Domain Path: /languages
13
  * License: GPLv2 or later
14
  * WC requires at least: 3.0
15
- * WC tested up to: 5.2
16
  */
17
 
18
 
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: 6.4.0
7
  * Author: Mollie
8
  * Author URI: https://www.mollie.com
9
  * Requires at least: 3.8
12
  * Domain Path: /languages
13
  * License: GPLv2 or later
14
  * WC requires at least: 3.0
15
+ * WC tested up to: 5.3
16
  */
17
 
18
 
public/css/mollie-gateway-icons.min.css CHANGED
@@ -1 +1 @@
1
- .mollie-gateway-icon{width:32px;vertical-align:bottom}label .mollie-gateway-icon{float:right}.mollie_custom_icon{padding:1em}
1
+ .mollie-gateway-icon{width:32px;vertical-align:bottom}label .mollie-gateway-icon{float:right}.mollie_custom_icon{padding:1em}#mol-paypal-settings-icon{margin-left:1em}
public/images/PayPal_Buttons/buy-gold-de.png DELETED
Binary file
public/images/PayPal_Buttons/buy-gold-en.png DELETED
Binary file
public/images/PayPal_Buttons/buy-gold-nl.png DELETED
Binary file
public/images/PayPal_Buttons/checkout-gold-de.png DELETED
Binary file
public/images/PayPal_Buttons/checkout-gold-en.png DELETED
Binary file
public/images/PayPal_Buttons/checkout-gold-nl.png DELETED
Binary file
public/images/PayPal_Buttons/checkout-silver-de.png DELETED
Binary file
public/images/PayPal_Buttons/checkout-silver-en.png DELETED
Binary file
public/images/PayPal_Buttons/checkout-silver-nl.png DELETED
Binary file
public/images/PayPal_Buttons/de/buy/pill-black.png ADDED
Binary file
public/images/PayPal_Buttons/de/buy/pill-blue.png ADDED
Binary file
public/images/PayPal_Buttons/de/buy/pill-golden.png ADDED
Binary file
public/images/PayPal_Buttons/de/buy/pill-gray.png ADDED
Binary file
public/images/PayPal_Buttons/de/buy/pill-white.png ADDED
Binary file
public/images/PayPal_Buttons/de/buy/rounded-black.png ADDED
Binary file
public/images/PayPal_Buttons/de/buy/rounded-blue.png ADDED
Binary file
public/images/PayPal_Buttons/de/buy/rounded-golden.png ADDED
Binary file
public/images/PayPal_Buttons/de/buy/rounded-gray.png ADDED
Binary file
public/images/PayPal_Buttons/de/buy/rounded-white.png ADDED
Binary file
public/images/PayPal_Buttons/de/checkout/pill-black.png ADDED
Binary file
public/images/PayPal_Buttons/de/checkout/pill-blue.png ADDED
Binary file
public/images/PayPal_Buttons/de/checkout/pill-golden.png ADDED
Binary file
public/images/PayPal_Buttons/de/checkout/pill-gray.png ADDED
Binary file
public/images/PayPal_Buttons/de/checkout/pill-white.png ADDED
Binary file
public/images/PayPal_Buttons/de/checkout/rounded-black.png ADDED
Binary file
public/images/PayPal_Buttons/de/checkout/rounded-blue.png ADDED
Binary file
public/images/PayPal_Buttons/de/checkout/rounded-golden.png ADDED
Binary file
public/images/PayPal_Buttons/de/checkout/rounded-gray.png ADDED
Binary file
public/images/PayPal_Buttons/de/checkout/rounded-white.png ADDED
Binary file
public/images/PayPal_Buttons/en/buy/pill-blue.png ADDED
Binary file
public/images/PayPal_Buttons/en/buy/pill-golden.png ADDED
Binary file
public/images/PayPal_Buttons/en/buy/pill-gray.png ADDED
Binary file
public/images/PayPal_Buttons/en/buy/pill-white.png ADDED
Binary file
public/images/PayPal_Buttons/en/buy/rounded-black.png ADDED
Binary file
public/images/PayPal_Buttons/en/buy/rounded-blue.png ADDED
Binary file
public/images/PayPal_Buttons/en/buy/rounded-golden.png ADDED
Binary file
public/images/PayPal_Buttons/en/buy/rounded-gray.png ADDED
Binary file
public/images/PayPal_Buttons/en/buy/rounded-white.png ADDED
Binary file
public/images/PayPal_Buttons/en/checkout/pill-black.png ADDED
Binary file
public/images/PayPal_Buttons/en/checkout/pill-blue.png ADDED
Binary file
public/images/PayPal_Buttons/en/checkout/pill-golden.png ADDED
Binary file
public/images/PayPal_Buttons/en/checkout/pill-gray.png ADDED
Binary file
public/images/PayPal_Buttons/en/checkout/pill-white.png ADDED
Binary file
public/images/PayPal_Buttons/en/checkout/rounded-black.png ADDED
Binary file
public/images/PayPal_Buttons/en/checkout/rounded-blue.png ADDED
Binary file
public/images/PayPal_Buttons/en/checkout/rounded-golden.png ADDED
Binary file
public/images/PayPal_Buttons/en/checkout/rounded-gray.png ADDED
Binary file
public/images/PayPal_Buttons/en/checkout/rounded-white.png ADDED
Binary file
public/images/PayPal_Buttons/{buy-gold-fr.png → fr/buy/rounded-gold.png} RENAMED
File without changes
public/images/PayPal_Buttons/{checkout-gold-fr.png → fr/checkout/rounded-gold.png} RENAMED
File without changes
public/images/PayPal_Buttons/{checkout-silver-fr.png → fr/checkout/rounded-silver.png} RENAMED
File without changes
public/images/PayPal_Buttons/nl/buy/pill-black.png ADDED
Binary file
public/images/PayPal_Buttons/nl/buy/pill-blue.png ADDED
Binary file
public/images/PayPal_Buttons/nl/buy/pill-golden.png ADDED
Binary file
public/images/PayPal_Buttons/nl/buy/pill-gray.png ADDED
Binary file
public/images/PayPal_Buttons/nl/buy/pill-white.png ADDED
Binary file
public/images/PayPal_Buttons/nl/buy/rounded-black.png ADDED
Binary file
public/images/PayPal_Buttons/nl/buy/rounded-blue.png ADDED
Binary file
public/images/PayPal_Buttons/nl/buy/rounded-golden.png ADDED
Binary file
public/images/PayPal_Buttons/nl/buy/rounded-gray.png ADDED
Binary file
public/images/PayPal_Buttons/nl/buy/rounded-white.png ADDED
Binary file
public/images/PayPal_Buttons/nl/checkout/pill-black.png ADDED
Binary file
public/images/PayPal_Buttons/nl/checkout/pill-blue.png ADDED
Binary file
public/images/PayPal_Buttons/nl/checkout/pill-golden.png ADDED
Binary file
public/images/PayPal_Buttons/nl/checkout/pill-gray.png ADDED
Binary file
public/images/PayPal_Buttons/nl/checkout/pill-white.png ADDED
Binary file
public/images/PayPal_Buttons/nl/checkout/rounded-black.png ADDED
Binary file
public/images/PayPal_Buttons/nl/checkout/rounded-blue.png ADDED
Binary file
public/images/PayPal_Buttons/nl/checkout/rounded-golden.png ADDED
Binary file
public/images/PayPal_Buttons/nl/checkout/rounded-gray.png ADDED
Binary file
public/images/PayPal_Buttons/nl/checkout/rounded-white.png ADDED
Binary file
public/images/PayPal_Buttons/{buy-gold-pl.png → pl/buy/rounded-gold.png} RENAMED
File without changes
public/images/PayPal_Buttons/{checkout-gold-pl.png → pl/checkout/rounded-gold.png} RENAMED
File without changes
public/images/PayPal_Buttons/{checkout-silver-pl.png → pl/checkout/rounded-silver.png} RENAMED
File without changes
public/js/applepayDirect.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.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 r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));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()))return!1;var n=document.createElement("button");return n.setAttribute("id","mollie_applepay_button"),n.classList.add("apple-pay-button"),n.classList.add("apple-pay-button-black"),t.appendChild(n),!0}},fmef:function(e,t,n){"use strict";n.r(t);var o=n("nxB1"),r=n("OiFV"),a=n("uXQx");!function(e){var t=e._,n=e.mollieApplePayDirectData,i=e.jQuery;if(!t.isEmpty(n)){var c=n.product,u=c.id,l=c.needShipping,p=void 0===l||l,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(u&&f&&y&&_&&Object(r.a)()){var S=document.getElementById("_wpnonce").value,w=u,j=1,O=[],P=[],C="";if(document.querySelector("input.qty").addEventListener("change",(function(e){j=e.currentTarget.value})),d){var x=document.querySelector("#mollie_applepay_button");i(".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 A=j*f;document.querySelector("#mollie_applepay_button").addEventListener("click",(function(e){var t=new ApplePaySession(3,Object(a.a)(y,h,g,A));t.begin(),p&&(t.onshippingmethodselected=function(e){var n=this;i.ajax({url:_,method:"POST",data:{action:"mollie_apple_pay_update_shipping_method",shippingMethod:e.shippingMethod,productId:u,callerPage:"productDetail",productQuantity:j,simplifiedContact:O,nonce:S},complete:function(e,t){},success:function(t,r,a){var i=t.data;P=e.shippingMethod,!1===t.success&&(i.errors=Object(o.a)(i.errors)),n.completeShippingMethodSelection(i)},error:function(e,n,o){console.warn(n,o),t.abort()}})},t.onshippingcontactselected=function(e){var n=this;i.ajax({url:_,method:"POST",data:{action:"mollie_apple_pay_update_shipping_contact",productId:u,callerPage:"productDetail",productQuantity:j,simplifiedContact:e.shippingContact,needShipping:p,nonce:S},complete:function(e,t){},success:function(t,r,a){var i=t.data;O=e.shippingContact,!1===t.success&&(i.errors=Object(o.a)(i.errors)),i.newShippingMethods&&(P=i.newShippingMethods[0]),n.completeShippingContactSelection(i)},error:function(e,n,o){console.warn(n,o),t.abort()}})}),t.onvalidatemerchant=function(e){i.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){i.ajax({url:_,method:"POST",data:{action:"mollie_apple_pay_create_order",productId:w,productQuantity:j,shippingContact:e.payment.shippingContact,billingContact:e.payment.billingContact,token:e.payment.token,shippingMethod:P,"mollie-payments-for-woocommerce_issuer_applepay":"applepay",nonce:S},complete:function(e,t){},success:function(e,n,r){var a=e.data;!0===e.success?(C=a.returnUrl,t.completePayment(a.responseToApple),window.location.href=C):(a.errors=Object(o.a)(a.errors),t.completePayment(a))},error:function(e,n,o){console.warn(n,o),t.abort()}})}}))}}}(window)},nxB1:function(e,t,n){"use strict";function o(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,a=function(){};return{s:a,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return c=e.done,e},e:function(e){u=!0,i=e},f:function(){try{c||null==n.return||n.return()}finally{if(u)throw i}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function a(e){var t,n=[],r=o(e);try{for(r.s();!(t=r.n()).done;){var a=t.value,i=a.contactField,c=void 0===i?null:i,u=a.code,l=void 0===u?null:u,p=a.message,s=c?new ApplePayError(l,c,void 0===p?null:p):new ApplePayError(l);n.push(s)}}catch(e){r.e(e)}finally{r.f()}return n}n.d(t,"a",(function(){return a}))},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"}}}}});
1
+ !function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.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 r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));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()))return!1;var n=document.createElement("button");return n.setAttribute("id","mollie_applepay_button"),n.classList.add("apple-pay-button"),n.classList.add("apple-pay-button-black"),t.appendChild(n),!0}},fmef:function(e,t,n){"use strict";n.r(t);var o=n("nxB1"),r=n("OiFV"),a=n("uXQx");!function(e){var t=e._,n=e.mollieApplePayDirectData,i=e.jQuery;if(!t.isEmpty(n)){var c=n.product,u=c.id,l=c.needShipping,p=void 0===l||l,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(u&&f&&y&&_&&Object(r.a)()){var S=document.getElementById("_wpnonce").value,w=u,j=1,O=[],P=[],C="";if(document.querySelector("input.qty").addEventListener("change",(function(e){j=e.currentTarget.value})),d){var x=document.querySelector("#mollie_applepay_button");i(".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 A=j*f;document.querySelector("#mollie_applepay_button").addEventListener("click",(function(e){var t=new ApplePaySession(3,Object(a.a)(y,h,g,A));t.begin(),p&&(t.onshippingmethodselected=function(e){var n=this;i.ajax({url:_,method:"POST",data:{action:"mollie_apple_pay_update_shipping_method",shippingMethod:e.shippingMethod,productId:u,callerPage:"productDetail",productQuantity:j,simplifiedContact:O,nonce:S},complete:function(e,t){},success:function(t,r,a){var i=t.data;P=e.shippingMethod,!1===t.success&&(i.errors=Object(o.a)(i.errors)),n.completeShippingMethodSelection(i)},error:function(e,n,o){console.warn(n,o),t.abort()}})},t.onshippingcontactselected=function(e){var n=this;i.ajax({url:_,method:"POST",data:{action:"mollie_apple_pay_update_shipping_contact",productId:u,callerPage:"productDetail",productQuantity:j,simplifiedContact:e.shippingContact,needShipping:p,nonce:S},complete:function(e,t){},success:function(t,r,a){var i=t.data;O=e.shippingContact,!1===t.success&&(i.errors=Object(o.a)(i.errors)),i.newShippingMethods&&(P=i.newShippingMethods[0]),n.completeShippingContactSelection(i)},error:function(e,n,o){console.warn(n,o),t.abort()}})}),t.onvalidatemerchant=function(e){i.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){i.ajax({url:_,method:"POST",data:{action:"mollie_apple_pay_create_order",productId:w,productQuantity:j,shippingContact:e.payment.shippingContact,billingContact:e.payment.billingContact,token:e.payment.token,shippingMethod:P,"mollie-payments-for-woocommerce_issuer_applepay":"applepay",nonce:S},complete:function(e,t){},success:function(e,n,r){var a=e.data;!0===e.success?(C=a.returnUrl,t.completePayment(a.responseToApple),window.location.href=C):(a.errors=Object(o.a)(a.errors),t.completePayment(a))},error:function(e,n,o){console.warn(n,o),t.abort()}})}}))}}}(window)},nxB1:function(e,t,n){"use strict";function o(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,a=function(){};return{s:a,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return c=e.done,e},e:function(e){u=!0,i=e},f:function(){try{c||null==n.return||n.return()}finally{if(u)throw i}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function a(e){var t,n=[],r=o(e);try{for(r.s();!(t=r.n()).done;){var a=t.value,i=a.contactField,c=void 0===i?null:i,u=a.code,l=void 0===u?null:u,p=a.message,s=c?new ApplePayError(l,c,void 0===p?null:p):new ApplePayError(l);n.push(s)}}catch(e){r.e(e)}finally{r.f()}return n}n.d(t,"a",(function(){return a}))},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 CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.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 r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));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()))return!1;var n=document.createElement("button");return n.setAttribute("id","mollie_applepay_button"),n.classList.add("apple-pay-button"),n.classList.add("apple-pay-button-black"),t.appendChild(n),!0}},RX5I:function(e,t,n){"use strict";n.r(t);var o=n("nxB1"),r=n("uXQx"),a=n("OiFV");!function(e){var t=e._,n=e.mollieApplePayDirectDataCart,i=e.jQuery;if(!t.isEmpty(n)){var c=n.product,l=c.needShipping,u=void 0===l||l,p=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(p&&d&&b){var v=document.getElementById("_wpnonce").value,g=[],_=[],S="",w=function(){var e=new ApplePaySession(3,Object(r.a)(d,m,h,p));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:g,nonce:v},complete:function(e,t){},success:function(e,r,a){var i=e.data;_=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:u,nonce:v},complete:function(e,t){},success:function(e,r,a){var i=e.data;g=t.shippingContact,!1===e.success&&(i.errors=Object(o.a)(i.errors)),i.newShippingMethods&&(_=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:_,"mollie-payments-for-woocommerce_issuer_applepay":"applepay",nonce:v},complete:function(e,t){},success:function(t,n,r){var a=t.data;!0===t.success?(S=a.returnUrl,e.completePayment(a.responseToApple),window.location.href=S):(a.errors=Object(o.a)(a.errors),e.completePayment(a))},error:function(t,n,o){console.warn(n,o),e.abort()}})}};Object(a.a)()&&(i(document.body).on("updated_cart_totals",(function(e){Object(a.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,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,a=function(){};return{s:a,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,l=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return c=e.done,e},e:function(e){l=!0,i=e},f:function(){try{c||null==n.return||n.return()}finally{if(l)throw i}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function a(e){var t,n=[],r=o(e);try{for(r.s();!(t=r.n()).done;){var a=t.value,i=a.contactField,c=void 0===i?null:i,l=a.code,u=void 0===l?null:l,p=a.message,s=c?new ApplePayError(u,c,void 0===p?null:p):new ApplePayError(u);n.push(s)}}catch(e){r.e(e)}finally{r.f()}return n}n.d(t,"a",(function(){return a}))},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"}}}}});
1
+ !function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.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 r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));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()))return!1;var n=document.createElement("button");return n.setAttribute("id","mollie_applepay_button"),n.classList.add("apple-pay-button"),n.classList.add("apple-pay-button-black"),t.appendChild(n),!0}},RX5I:function(e,t,n){"use strict";n.r(t);var o=n("nxB1"),r=n("uXQx"),a=n("OiFV");!function(e){var t=e._,n=e.mollieApplePayDirectDataCart,i=e.jQuery;if(!t.isEmpty(n)){var c=n.product,l=c.needShipping,u=void 0===l||l,p=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(p&&d&&b){var v=document.getElementById("_wpnonce").value,g=[],_=[],S="",w=function(){var e=new ApplePaySession(3,Object(r.a)(d,m,h,p));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:g,nonce:v},complete:function(e,t){},success:function(e,r,a){var i=e.data;_=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:u,nonce:v},complete:function(e,t){},success:function(e,r,a){var i=e.data;g=t.shippingContact,!1===e.success&&(i.errors=Object(o.a)(i.errors)),i.newShippingMethods&&(_=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:_,"mollie-payments-for-woocommerce_issuer_applepay":"applepay",nonce:v},complete:function(e,t){},success:function(t,n,r){var a=t.data;!0===t.success?(S=a.returnUrl,e.completePayment(a.responseToApple),window.location.href=S):(a.errors=Object(o.a)(a.errors),e.completePayment(a))},error:function(t,n,o){console.warn(n,o),e.abort()}})}};Object(a.a)()&&(i(document.body).on("updated_cart_totals",(function(e){Object(a.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,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,a=function(){};return{s:a,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return c=e.done,e},e:function(e){l=!0,i=e},f:function(){try{c||null==n.return||n.return()}finally{if(l)throw i}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function a(e){var t,n=[],r=o(e);try{for(r.s();!(t=r.n()).done;){var a=t.value,i=a.contactField,c=void 0===i?null:i,l=a.code,u=void 0===l?null:l,p=a.message,s=c?new ApplePayError(u,c,void 0===p?null:p):new ApplePayError(u);n.push(s)}}catch(e){r.e(e)}finally{r.f()}return n}n.d(t,"a",(function(){return a}))},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/entrypoints.json CHANGED
@@ -20,6 +20,16 @@
20
  "/public/js/applepayDirectCart.min.js"
21
  ]
22
  },
 
 
 
 
 
 
 
 
 
 
23
  "settings.min": {
24
  "js": [
25
  "/public/js/settings.min.js"
20
  "/public/js/applepayDirectCart.min.js"
21
  ]
22
  },
23
+ "paypalButton.min": {
24
+ "js": [
25
+ "/public/js/paypalButton.min.js"
26
+ ]
27
+ },
28
+ "paypalButtonCart.min": {
29
+ "js": [
30
+ "/public/js/paypalButtonCart.min.js"
31
+ ]
32
+ },
33
  "settings.min": {
34
  "js": [
35
  "/public/js/settings.min.js"
public/js/gatewaySettings.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},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="6cVz")}({"6cVz":function(e,t){var n,r,o,i,c,u,a,l,d;n=window,r=n._,o=n.gatewaySettingsData,i=n.jQuery,c=o.isEnabledIcon,u=o.uploadFieldName,a=o.enableFieldName,l=o.iconUrl,d=o.message,r.isEmpty(o)||(document.addEventListener("DOMContentLoaded",(function(e){if(c){var t=document.querySelector("#"+u);r.isEmpty(l)?t.insertAdjacentHTML("afterend",'<div class="mollie_custom_icon"><p>'+d+"</p></div>"):t.insertAdjacentHTML("afterend",'<div class="mollie_custom_icon"><img src="'+l+'" alt="custom icon image" width="100px"></div>')}})),i((function(e){e("#"+a).change((function(){e(this).is(":checked")?e("#"+u).closest("tr").show():e("#"+u).closest("tr").hide()})).change()})))}});
1
+ !function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.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 r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));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="6cVz")}({"6cVz":function(e,t){var n,o,r,i,a,c,l,u,s,d;n=window,o=n._,r=n.gatewaySettingsData,i=n.jQuery,a=r.isEnabledIcon,c=r.uploadFieldName,l=r.enableFieldName,u=r.iconUrl,s=r.message,d=r.pluginUrlImages,o.isEmpty(r)||(document.addEventListener("DOMContentLoaded",(function(e){if(a){var t=document.querySelector("#"+c);o.isEmpty(u)?t.insertAdjacentHTML("afterend",'<div class="mollie_custom_icon"><p>'+s+"</p></div>"):t.insertAdjacentHTML("afterend",'<div class="mollie_custom_icon"><img src="'+u+'" alt="custom icon image" width="100px"></div>')}})),i((function(e){e("#"+l).change((function(){e(this).is(":checked")?e("#"+c).closest("tr").show():e("#"+c).closest("tr").hide()})).change();var t=e("#mollie_wc_gateway_paypal_color");t.change((function(){var n,o,r=d+"/PayPal_Buttons/"+(n=t.val(),(o=n.split("-"))[0]+"/"+o[1]+"/"+o[2]+"-"+o[3]+".png"),i=e("#mol-paypal-settings-icon");i.length&&i.remove(),t.after("<img id='mol-paypal-settings-icon' width='200px' src="+r+" alt='PayPal_Icon'/>")})).change()})))}});
public/js/manifest.json CHANGED
@@ -6,5 +6,7 @@
6
  "public/js/gatewaySettings.min.js": "/public/js/gatewaySettings.min.js",
7
  "public/js/gatewaySurcharge.min.js": "/public/js/gatewaySurcharge.min.js",
8
  "public/js/mollie-components.min.js": "/public/js/mollie-components.min.js",
 
 
9
  "public/js/settings.min.js": "/public/js/settings.min.js"
10
  }
6
  "public/js/gatewaySettings.min.js": "/public/js/gatewaySettings.min.js",
7
  "public/js/gatewaySurcharge.min.js": "/public/js/gatewaySurcharge.min.js",
8
  "public/js/mollie-components.min.js": "/public/js/mollie-components.min.js",
9
+ "public/js/paypalButton.min.js": "/public/js/paypalButton.min.js",
10
+ "public/js/paypalButtonCart.min.js": "/public/js/paypalButtonCart.min.js",
11
  "public/js/settings.min.js": "/public/js/settings.min.js"
12
  }
public/js/mollie-components.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/public/js/",t(t.s="hgRJ")}({hgRJ:function(e,n){function t(e,n,t,r,o,c,u){try{var a=e[c](u),i=a.value}catch(e){return void t(e)}a.done?n(i):Promise.resolve(i).then(r,o)}function r(e){return function(){var n=this,r=arguments;return new Promise((function(o,c){var u=e.apply(n,r);function a(e){t(u,o,c,a,i,"next",e)}function i(e){t(u,o,c,a,i,"throw",e)}a(void 0)}))}}function o(){return!1}function c(e){return e?e.querySelector(".wc_payment_methods"):null}function u(e,n){return n?n.querySelector(".payment_method_mollie_wc_gateway_".concat(e)):null}function a(e){return e?e.querySelector("#mollie-notice"):null}function i(e){return e?e.querySelector(".mollie-components"):null}function l(e,n){var t,r,o,u=p(c(document)).parentNode||null,i=a(document),l=(r=(t=n).content,o=t.type,'\n <div id="mollie-notice" class="woocommerce-'.concat(o,'">\n ').concat(r,"\n </div>\n "));i&&i.remove(),u?(u.insertAdjacentHTML("beforebegin",l),function(e){var n=a(document);n||(n=c(document));e.scroll_to_notices(e(n))}(e)):alert(n.content)}function s(e){return e.querySelector(".cardToken")}function f(e){return m.apply(this,arguments)}function m(){return(m=r(regeneratorRuntime.mark((function e(n){var t,r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.createToken(".cardToken");case 2:if(t=e.sent,r=t.token,!(o=t.error)){e.next=7;break}throw new Error(o.message||"");case 7:return e.abrupt("return",r);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function d(e,n){n&&(n.value=e,n.setAttribute("value",e))}function p(e){return e?e.closest("form"):null}function y(e){e.off("checkout_place_order",o),e.off("submit",b)}function v(e){var n=u(e,document),t=n?n.querySelector("#payment_method_mollie_wc_gateway_".concat(e)):null;return t&&t.checked||!1}function b(e){return g.apply(this,arguments)}function g(){return(g=r(regeneratorRuntime.mark((function e(n){var t,r,o,c,u,a,i,m,b,g,h,_,w;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t="",r=n.data,o=r.jQuery,c=r.mollie,u=r.gateway,a=r.gatewayContainer,i=r.messages,m=p(a),b=o(m),g=o(document.body),v(u)){e.next=9;break}return y(b),b.submit(),e.abrupt("return");case 9:return n.preventDefault(),n.stopImmediatePropagation(),e.prev=11,e.next=14,f(c);case 14:t=e.sent,e.next=24;break;case 17:return e.prev=17,e.t0=e.catch(11),h=e.t0,_=h.message,message=void 0===_?i.defaultErrorMessage:_,(w=h)&&l(o,{content:w,type:"error"}),b.removeClass("processing").unblock(),g.trigger("checkout_error"),e.abrupt("return");case 24:y(b),t&&d(t,s(a)),b.submit();case 27:case"end":return e.stop()}}),e,null,[[11,17]])})))).apply(this,arguments)}function h(e,n,t,r,o){t.forEach((function(t){return function(e,n,t,r,o){var c=t.name,u=function(e,n,t,r){var o;return r.has(e)&&(o=r.get(e)),o||(o=n.createComponent(e,t)),o}(c,e,n,r);i(o).insertAdjacentHTML("beforeend",'<div id="'.concat(c,'"></div>')),u.mount("#".concat(c));var a,l,s=(a=c,(l=o)?l.querySelector(".mollie-component--".concat(a)):null);s?(!function(e,n){var t=n.label;e.insertAdjacentHTML("beforebegin",'<b class="mollie-component-label">'.concat(t,"</b>"))}(s,t),function(e,n){var t=n.name;e.insertAdjacentHTML("afterend",'<div role="alert" id="'.concat(t,'-errors"></div>'))}(s,t),!r.has(c)&&r.set(c,u)):console.warn("Component ".concat(c," not found in the DOM. Probably had problem during mount."))}(e,n,t,r,o)}))}!function(e){var n=e._,t=e.Mollie,r=e.mollieComponentsSettings,c=e.jQuery;if(!n.isEmpty(r)&&n.isFunction(t)){var a="updated_checkout",l=new Map,s=c(document),f=r.merchantProfileId,m=r.options,d=r.isCheckoutPayPage,v=new t(f,m);d&&(a="payment_method_selected"),s.on(a,(function(){return function(e,n,t,r){t.options,t.merchantProfileId;var c=t.componentsSettings,a=t.componentsAttributes,l=t.enabledGateways,s=t.messages;!function(e){e.forEach((function(e){return e.unmount()}))}(r),l.forEach((function(t){var l,f=u(t,document),m=i(f),d=p(f),v=e(d);f?d?(y(v),(l=m)&&(l.innerText=""),function(e){e.insertAdjacentHTML("beforeend",'<input type="hidden" name="cardToken" class="cardToken" value="" />')}(m),h(n,c[t],a,r,f),v.on("checkout_place_order",o),v.on("submit",null,{jQuery:e,mollie:n,gateway:t,gatewayContainer:f,messages:s},b)):console.warn("Cannot initialize Mollie Components, no form found."):console.warn("Cannot initialize Mollie Components for gateway ".concat(t,"."))}))}(c,v,r,l)}))}}(window)}});
1
+ !function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/public/js/",t(t.s="hgRJ")}({hgRJ:function(e,n){function t(e,n,t,r,o,c,a){try{var u=e[c](a),i=u.value}catch(e){return void t(e)}u.done?n(i):Promise.resolve(i).then(r,o)}function r(e){return function(){var n=this,r=arguments;return new Promise((function(o,c){var a=e.apply(n,r);function u(e){t(a,o,c,u,i,"next",e)}function i(e){t(a,o,c,u,i,"throw",e)}u(void 0)}))}}function o(){return!1}function c(){return!0}function a(e){return e?e.querySelector(".wc_payment_methods"):null}function u(e,n){return n?n.querySelector(".payment_method_mollie_wc_gateway_".concat(e)):null}function i(e){return e?e.querySelector("#mollie-notice"):null}function l(e){return e?e.querySelector(".mollie-components"):null}function s(e,n){var t,r,o,c=y(a(document)).parentNode||null,u=i(document),l=(r=(t=n).content,o=t.type,'\n <div id="mollie-notice" class="woocommerce-'.concat(o,'">\n ').concat(r,"\n </div>\n "));u&&u.remove(),c?(c.insertAdjacentHTML("beforebegin",l),function(e){var n=i(document);n||(n=a(document));e.scroll_to_notices(e(n))}(e)):alert(n.content)}function f(e){return e.querySelector(".cardToken")}function d(e){return m.apply(this,arguments)}function m(){return(m=r(regeneratorRuntime.mark((function e(n){var t,r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.createToken(".cardToken");case 2:if(t=e.sent,r=t.token,!(o=t.error)){e.next=7;break}throw new Error(o.message||"");case 7:return e.abrupt("return",r);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function p(e,n){n&&(n.value=e,n.setAttribute("value",e))}function y(e){return e?e.closest("form"):null}function v(e){e.off("checkout_place_order",o),e.off("submit",h)}function b(e){var n=u(e,document),t=n?n.querySelector("#payment_method_mollie_wc_gateway_".concat(e)):null;return t&&t.checked||!1}function h(e){return g.apply(this,arguments)}function g(){return(g=r(regeneratorRuntime.mark((function e(n){var t,r,o,c,a,u,i,l,m,h,g,_,w;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t="",r=n.data,o=r.jQuery,c=r.mollie,a=r.gateway,u=r.gatewayContainer,i=r.messages,l=y(u),m=o(l),h=o(document.body),b(a)){e.next=9;break}return v(m),m.submit(),e.abrupt("return");case 9:return n.preventDefault(),n.stopImmediatePropagation(),e.prev=11,e.next=14,d(c);case 14:t=e.sent,e.next=24;break;case 17:return e.prev=17,e.t0=e.catch(11),g=e.t0,_=g.message,message=void 0===_?i.defaultErrorMessage:_,(w=g)&&s(o,{content:w,type:"error"}),m.removeClass("processing").unblock(),h.trigger("checkout_error"),e.abrupt("return");case 24:v(m),t&&p(t,f(u)),m.submit();case 27:case"end":return e.stop()}}),e,null,[[11,17]])})))).apply(this,arguments)}function _(e,n,t,r,o){t.forEach((function(t){return function(e,n,t,r,o){var c=t.name,a=function(e,n,t,r){var o;return r.has(e)&&(o=r.get(e)),o||(o=n.createComponent(e,t)),o}(c,e,n,r);l(o).insertAdjacentHTML("beforeend",'<div id="'.concat(c,'"></div>')),a.mount("#".concat(c));var u,i,s=(u=c,(i=o)?i.querySelector(".mollie-component--".concat(u)):null);s?(!function(e,n){var t=n.label;e.insertAdjacentHTML("beforebegin",'<b class="mollie-component-label">'.concat(t,"</b>"))}(s,t),function(e,n){var t=n.name;e.insertAdjacentHTML("afterend",'<div role="alert" id="'.concat(t,'-errors"></div>'))}(s,t),!r.has(c)&&r.set(c,a)):console.warn("Component ".concat(c," not found in the DOM. Probably had problem during mount."))}(e,n,t,r,o)}))}function w(e,n,t,r){t.options,t.merchantProfileId;var c=t.componentsSettings,a=t.componentsAttributes,i=t.enabledGateways,s=t.messages;!function(e){e.forEach((function(e){return e.unmount()}))}(r),i.forEach((function(t){var i,f=u(t,document),d=l(f),m=y(f),p=e(m);f?m?(v(p),(i=d)&&(i.innerText=""),function(e){e.insertAdjacentHTML("beforeend",'<input type="hidden" name="cardToken" class="cardToken" value="" />')}(d),_(n,c[t],a,r,f),p.on("checkout_place_order",o),p.on("submit",null,{jQuery:e,mollie:n,gateway:t,gatewayContainer:f,messages:s},h)):console.warn("Cannot initialize Mollie Components, no form found."):console.warn("Cannot initialize Mollie Components for gateway ".concat(t,"."))}))}!function(e){var n=e._,t=e.Mollie,r=e.mollieComponentsSettings,o=e.jQuery;if(!n.isEmpty(r)&&n.isFunction(t)){var a="updated_checkout",i=new Map,l=o(document),s=r.merchantProfileId,f=r.options,d=r.isCheckoutPayPage,m=new t(s,f);if(d)return a="payment_method_selected",void l.on(a,(function(){return w(o,m,r,i)}));l.on(a,p()),l.on("update_checkout",p())}function p(){return function(){var e=JSON.parse(JSON.stringify(r));r.enabledGateways.forEach((function(n,t){u(n,document)||(e.enabledGateways.splice(t,1),o('form[name="checkout"]').on("checkout_place_order",c))})),n.isEmpty(e.enabledGateways)||w(o,m,e,i)}}}(window)}});
public/js/paypalButton.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.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 r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));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="GBNm")}({GBNm:function(e,t){!function(e){var t=e._,n=e.molliepaypalbutton,o=e.jQuery;if(!t.isEmpty(n)){var r=n.product,a=r.id,i=r.needShipping,u=void 0===i||i,l=r.isVariation,c=void 0!==l&&l,d=r.price,s=r.minFee,p=n.ajaxUrl;if(a&&d&&p){var f=document.querySelector("#mollie-PayPal-button"),m=function(e){var t=e*d;o.ajax({url:p,method:"POST",data:{action:"mollie_paypal_update_amount",productId:_,productQuantity:e,nonce:v},success:function(e){t=parseFloat(e.data),function(e){e?y():b()}(parseFloat(s)>t)},error:function(e){console.warn(e)}})},y=function(){null!==f.parentNode&&f.parentNode.removeChild(f)},b=function(){document.getElementsByClassName("entry-summary")[0].appendChild(f)},v=f.children[0].value,_=a,g=1,j="";if(document.querySelector("input.qty").addEventListener("change",(function(e){g=e.currentTarget.value,m(g)})),m(g),c&&(o(".single_variation_wrap").on("show_variation",(function(e,t){t.variation_id&&(_=t.variation_id),f.disabled=!1,f.classList.remove("buttonDisabled")})),f.disabled=!0,f.classList.add("buttonDisabled")),null!=f.parentNode){var S=!1;document.querySelector("#mollie-PayPal-button").addEventListener("click",(function(e){null!==f.parentNode&&(f.disabled=!0,f.classList.add("buttonDisabled"),S||(S=!0,o.ajax({url:p,method:"POST",data:{action:"mollie_paypal_create_order",productId:_,productQuantity:g,needShipping:u,"mollie-payments-for-woocommerce_issuer_paypal_button":"paypal",nonce:v},success:function(e){var t=e.data;!0===e.success?(j=t.redirect,window.location.href=j):console.log(e.data)},error:function(e,t,n){f.disabled=!1,f.classList.remove("buttonDisabled"),console.warn(t,n)}})))}))}}}}(window)}});
public/js/paypalButtonCart.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},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="mS9U")}({mS9U:function(e,t){function n(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,a=function(){};return{s:a,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,u=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return u=e.done,e},e:function(e){i=!0,l=e},f:function(){try{u||null==n.return||n.return()}finally{if(i)throw l}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}!function(e){var t=e._,r=e.molliepaypalButtonCart,o=e.jQuery;if(!t.isEmpty(r)){var a=r.product,l=a.needShipping,u=void 0===l||l,i=a.minFee,c=r.ajaxUrl;if(c){var d="",f=document.getElementById("mollie-PayPal-button"),s=function(e){e&&m()},m=function(){null!==(f=document.getElementById("mollie-PayPal-button")).parentNode&&f.parentNode.removeChild(f)},y=function(e){return parseFloat(e.textContent).toFixed(2)},p=function(){var e=document.getElementsByClassName("cart-subtotal")[0].getElementsByClassName("woocommerce-Price-amount")[0].childNodes[0].cloneNode(!0),t=e.lastChild;e.removeChild(t);var r=parseFloat(y(e));return r+=function(){var e=document.getElementsByClassName("tax-rate");if(0===e.length)return 0;var t,r=0,o=n(e);try{for(o.s();!(t=o.n()).done;){var a=t.value.getElementsByClassName("woocommerce-Price-amount")[0].cloneNode(!0),l=a.lastChild;a.removeChild(l),r+=parseFloat(y(a))}}catch(e){o.e(e)}finally{o.f()}return r}()},v=function(){var e=p();return i>e},b=function(){var e=document.getElementById("mollie-PayPal-button");if(e){var t=!1,n=e.children[0].value;e.addEventListener("click",(function(r){e&&(e.disabled=!0,e.classList.add("buttonDisabled"),t||(t=!0,o.ajax({url:c,method:"POST",data:{action:"mollie_paypal_create_order_cart","mollie-payments-for-woocommerce_issuer_paypal_button":"paypal",needShipping:u,nonce:n},success:function(e){var t=e.data;!0===e.success?(d=t.redirect,window.location.href=d):console.log(e.data)},error:function(e,t,n){f.disabled=!1,f.classList.remove("buttonDisabled"),console.warn(t,n)}})))}))}};o(document.body).on("updated_cart_totals",(function(e){var t=document.getElementById("mollie-PayPal-button");null!=t&&null!=t.parentNode&&(s(v()),b())})),null!=f&&null!=f.parentNode&&(s(v()),b())}}}(window)}});
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.7
6
- Stable tag: 6.3.0
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,15 @@ Automatic updates should work like a charm; as always though, ensure you backup
181
 
182
  == Changelog ==
183
 
 
 
 
 
 
 
 
 
 
184
  = 6.3.0 - 29-04-2021 =
185
 
186
  * Feature - Allow choosing between Payment/Order API
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.7
6
+ Stable tag: 6.4.0
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
+ = 6.4.0 - 19-05-2021 =
185
+
186
+ * Feature - PayPal Button for digital goods
187
+ * Fix - Repair subscription method triggering on parent order
188
+ * Fix - Surcharge breaking PDF invoices
189
+ * Fix - Mollie Components fail when coupon code is applied on checkout
190
+ * Fix - Test mode notice links to old settings page
191
+ * Fix - nl_NL(formal) wrong translation string
192
+
193
  = 6.3.0 - 29-04-2021 =
194
 
195
  * Feature - Allow choosing between Payment/Order API
src/Mollie/WC/Gateway/Abstract.php CHANGED
@@ -155,7 +155,8 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
155
  'uploadFieldName' => $uploadFieldName,
156
  'enableFieldName' => $enabledFieldName,
157
  'iconUrl' => $gatewayIconUrl,
158
- 'message'=>$message
 
159
  ]
160
  );
161
  }
@@ -869,6 +870,10 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
869
  return;
870
  }
871
 
 
 
 
 
872
  // Get payment method title
873
  $payment_method_title = $this->getPaymentMethodTitle( $payment );
874
 
@@ -2697,4 +2702,26 @@ abstract class Mollie_WC_Gateway_Abstract extends WC_Payment_Gateway
2697
 
2698
  return $url;
2699
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2700
  }
155
  'uploadFieldName' => $uploadFieldName,
156
  'enableFieldName' => $enabledFieldName,
157
  'iconUrl' => $gatewayIconUrl,
158
+ 'message'=>$message,
159
+ 'pluginUrlImages'=>plugins_url( 'public/images', M4W_FILE )
160
  ]
161
  );
162
  }
870
  return;
871
  }
872
 
873
+ if($payment->method == 'paypal' && $payment->billingAddress){
874
+ $this->setBillingAddressAfterPayment($payment, $order);
875
+ }
876
+
877
  // Get payment method title
878
  $payment_method_title = $this->getPaymentMethodTitle( $payment );
879
 
2702
 
2703
  return $url;
2704
  }
2705
+
2706
+ /**
2707
+ * @param \Mollie\Api\Resources\Payment|\Mollie\Api\Resources\Order $payment
2708
+ * @param WC_Order $order
2709
+ */
2710
+ protected function setBillingAddressAfterPayment( $payment, $order)
2711
+ {
2712
+ $billingAddress = $payment->billingAddress;
2713
+ $wooBillingAddress = [
2714
+ 'first_name' => $billingAddress->givenName,
2715
+ 'last_name' => $billingAddress->familyName,
2716
+ 'email' => $billingAddress->email,
2717
+ 'phone' => null,
2718
+ 'address_1' => $billingAddress->streetAndNumber,
2719
+ 'address_2' => null,
2720
+ 'city' => $billingAddress->city,
2721
+ 'state' => null,
2722
+ 'postcode' => $billingAddress->postalCode,
2723
+ 'country' => $billingAddress->country,
2724
+ ];
2725
+ $order->set_address($wooBillingAddress, 'billing');
2726
+ }
2727
  }
src/Mollie/WC/Gateway/PayPal.php CHANGED
@@ -17,6 +17,16 @@ class Mollie_WC_Gateway_PayPal extends Mollie_WC_Gateway_Abstract
17
  parent::__construct();
18
  }
19
 
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * @return string
22
  */
@@ -71,4 +81,14 @@ class Mollie_WC_Gateway_PayPal extends Mollie_WC_Gateway_Abstract
71
  return parent::getInstructions($order, $payment, $admin_instructions, $plain_text);
72
 
73
  }
 
 
 
 
 
 
 
 
 
 
74
  }
17
  parent::__construct();
18
  }
19
 
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ public function init_form_fields()
24
+ {
25
+ parent::init_form_fields();
26
+
27
+ $this->includePayPalButton();
28
+ }
29
+
30
  /**
31
  * @return string
32
  */
81
  return parent::getInstructions($order, $payment, $admin_instructions, $plain_text);
82
 
83
  }
84
+
85
+
86
+ protected function includePayPalButton()
87
+ {
88
+ $fields = include Mollie_WC_Plugin::getPluginPath(
89
+ '/inc/settings/mollie_paypal_button_enabler.php'
90
+ );
91
+
92
+ $this->form_fields = array_merge($this->form_fields, $fields);
93
+ }
94
  }
src/Mollie/WC/Helper/GatewaySurchargeHandler.php CHANGED
@@ -25,7 +25,8 @@ class Mollie_WC_Helper_GatewaySurchargeHandler
25
  add_action( 'woocommerce_order_item_meta_end',[$this, 'setHiddenOrderId'], 10, 4);
26
  }
27
 
28
- public function setHiddenOrderId($item_id, $item, $order, $bool){
 
29
  ?>
30
  <input type="hidden" name="mollie-woocommerce-orderId" value="<?php echo $order->get_id() ?>">
31
  <?php
@@ -44,6 +45,23 @@ class Mollie_WC_Helper_GatewaySurchargeHandler
44
  );
45
  }
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  public function updateSurchargeOrderPay(){
48
  $orderId = isset($_POST['orderId'])?filter_var($_POST['orderId'], FILTER_SANITIZE_NUMBER_INT):false;
49
  if(!$orderId){
@@ -76,7 +94,7 @@ class Mollie_WC_Helper_GatewaySurchargeHandler
76
  $surchargeName = $this->buildFeeName($gateway);
77
 
78
 
79
- if($amount >0){
80
  $this->orderAddFee($order, $amount, $surchargeName);
81
  $order->calculate_totals();
82
  $newTotal = $order->get_total();
@@ -275,6 +293,7 @@ class Mollie_WC_Helper_GatewaySurchargeHandler
275
  $item_fee->set_name( $surchargeName );
276
  $item_fee->set_amount( $amount );
277
  $item_fee->set_total( $amount );
 
278
  $order->add_item( $item_fee );
279
  $order->calculate_totals();
280
  }
25
  add_action( 'woocommerce_order_item_meta_end',[$this, 'setHiddenOrderId'], 10, 4);
26
  }
27
 
28
+ public function setHiddenOrderId($item_id, $item, $order, $bool = false)
29
+ {
30
  ?>
31
  <input type="hidden" name="mollie-woocommerce-orderId" value="<?php echo $order->get_id() ?>">
32
  <?php
45
  );
46
  }
47
 
48
+ public function addSurchargeFeeProductPage($order, $gateway){
49
+ $gatewaySettings = $this->gatewaySettings($gateway);
50
+ if (!isset($gatewaySettings['payment_surcharge']) || $gatewaySettings['payment_surcharge'] == self::NO_FEE) {
51
+ return $order;
52
+ }
53
+ $order->calculate_totals();
54
+ $amount = $this->calculteFeeAmountOrder($order, $gatewaySettings);
55
+
56
+ if($amount > 0){
57
+ $surchargeName = $this->buildFeeName($gateway);
58
+ $this->orderRemoveFee($order);
59
+ $this->orderAddFee($order, $amount, $surchargeName);
60
+ $order->calculate_totals();
61
+ }
62
+ return $order;
63
+ }
64
+
65
  public function updateSurchargeOrderPay(){
66
  $orderId = isset($_POST['orderId'])?filter_var($_POST['orderId'], FILTER_SANITIZE_NUMBER_INT):false;
67
  if(!$orderId){
94
  $surchargeName = $this->buildFeeName($gateway);
95
 
96
 
97
+ if($amount > 0){
98
  $this->orderAddFee($order, $amount, $surchargeName);
99
  $order->calculate_totals();
100
  $newTotal = $order->get_total();
293
  $item_fee->set_name( $surchargeName );
294
  $item_fee->set_amount( $amount );
295
  $item_fee->set_total( $amount );
296
+ $item_fee->set_tax_status('none');
297
  $order->add_item( $item_fee );
298
  $order->calculate_totals();
299
  }
src/Mollie/WC/Helper/MaybeFixSubscription.php CHANGED
@@ -22,7 +22,6 @@ class Mollie_WC_Helper_MaybeFixSubscription
22
  [
23
  'subscriptions_per_page' => '-1',
24
  'meta_query' => [
25
- 'relation' => 'OR',
26
  [
27
  'key' => '_mollie_customer_id',
28
  'value' => '',
@@ -36,11 +35,13 @@ class Mollie_WC_Helper_MaybeFixSubscription
36
  //cst_*
37
  if (strlen($customer) < 5) {
38
  $parent = $subscription->get_parent();
39
- $subscription->update_meta_data('_mollie_customer_id', $parent->get_meta('_mollie_customer_id'));
40
- $subscription->update_meta_data('_mollie_order_id', $parent->get_meta('_mollie_order_id'));
41
- $subscription->update_meta_data('_mollie_payment_id', $parent->get_meta('_mollie_payment_id'));
42
- $subscription->update_meta_data('_mollie_payment_mode', $parent->get_meta('_mollie_payment_mode'));
43
- $subscription->save();
 
 
44
  }
45
  }
46
  update_option('mollie_wc_fix_subscriptions', true);
22
  [
23
  'subscriptions_per_page' => '-1',
24
  'meta_query' => [
 
25
  [
26
  'key' => '_mollie_customer_id',
27
  'value' => '',
35
  //cst_*
36
  if (strlen($customer) < 5) {
37
  $parent = $subscription->get_parent();
38
+ if($parent){
39
+ $subscription->update_meta_data('_mollie_customer_id', $parent->get_meta('_mollie_customer_id'));
40
+ $subscription->update_meta_data('_mollie_order_id', $parent->get_meta('_mollie_order_id'));
41
+ $subscription->update_meta_data('_mollie_payment_id', $parent->get_meta('_mollie_payment_id'));
42
+ $subscription->update_meta_data('_mollie_payment_mode', $parent->get_meta('_mollie_payment_mode'));
43
+ $subscription->save();
44
+ }
45
  }
46
  }
47
  update_option('mollie_wc_fix_subscriptions', true);
src/Mollie/WC/Helper/OrderLines.php CHANGED
@@ -51,7 +51,7 @@ class Mollie_WC_Helper_OrderLines {
51
  public function order_lines() {
52
 
53
  $this->process_items();
54
- $this->process_shipping();
55
  $this->process_fees();
56
  $this->process_gift_cards();
57
 
51
  public function order_lines() {
52
 
53
  $this->process_items();
54
+ $this->process_shipping();
55
  $this->process_fees();
56
  $this->process_gift_cards();
57
 
src/Mollie/WC/Helper/PayPalButtonHandler.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_Helper_PayPalButtonHandler
4
+ {
5
+ /**
6
+ * @var Mollie_WC_PayPalButton_AjaxRequests
7
+ */
8
+ private $ajaxRequests;
9
+
10
+ /**
11
+ * Mollie_WC_Helper_PayPalHandler constructor.
12
+ *
13
+ * @param Mollie_WC_PayPalButton_AjaxRequests $ajaxRequests
14
+ */
15
+ public function __construct(Mollie_WC_PayPalButton_AjaxRequests $ajaxRequests)
16
+ {
17
+ $this->ajaxRequests = $ajaxRequests;
18
+ }
19
+
20
+ /**
21
+ * Initial method that puts the button in place
22
+ * and adds all the necessary actions
23
+ */
24
+ public function bootstrap($enabledInProduct, $enabledInCart)
25
+ {
26
+ //y no hay shipping enseño, luego ya la cantidad en js
27
+
28
+ if($enabledInProduct){
29
+ add_action(
30
+ 'woocommerce_after_single_product',
31
+ function () {
32
+ $product = wc_get_product(get_the_id());
33
+ if (!$product || $product->is_type('subscription')) {
34
+ return;
35
+ }
36
+ $productNeedShipping = mollieWooCommerceCheckIfNeedShipping($product);
37
+ if(!$productNeedShipping){
38
+ $this->renderPayPalButton();
39
+ }
40
+ }
41
+ );
42
+ }
43
+ if($enabledInCart){
44
+ add_action(
45
+ 'woocommerce_cart_totals_after_order_total',
46
+ function () {
47
+ $cart = WC()->cart;
48
+ foreach ($cart->get_cart_contents() as $product){
49
+ if($product['data']->is_type('subscription')){
50
+ return;
51
+ }
52
+ }
53
+ if(!$cart->needs_shipping()){
54
+ $this->renderPayPalButton();
55
+ }
56
+ }
57
+ );
58
+ }
59
+
60
+ admin_url('admin-ajax.php');
61
+ $this->ajaxRequests->bootstrapAjaxRequest();
62
+ }
63
+
64
+ /**
65
+ * PayPal button markup
66
+ */
67
+ protected function renderPayPalButton()
68
+ {
69
+ $whichPayPalButton = $this->whichPayPalButton();
70
+ $assetsImagesUrl
71
+ = Mollie_WC_Plugin::getPluginUrl($whichPayPalButton);
72
+
73
+ ?>
74
+ <div id="mollie-PayPal-button" class="mol-PayPal">
75
+ <?php wp_nonce_field('mollie_PayPal_button'); ?>
76
+ <input type="image" src="<?php echo esc_url( $assetsImagesUrl)?>" alt="PayPal Button">
77
+ </div>
78
+ <?php
79
+ }
80
+
81
+ /**
82
+ * Build the name of the button from the settings to return the chosen one
83
+ *
84
+ * @retun string the path of the chosen button image
85
+ */
86
+ protected function whichPayPalButton()
87
+ {
88
+ $paypalSettings = get_option('mollie_wc_gateway_paypal_settings');
89
+ if(!$paypalSettings){
90
+ return "";
91
+ }
92
+ $colorSetting = isset( $paypalSettings['color']) ? $paypalSettings['color'] : "en-checkout-pill-golden";
93
+ $dataArray = explode('-', $colorSetting);//[0]lang [1]folder [2]first part filename [3] second part filename
94
+ $fixPath = 'public/images/PayPal_Buttons/';
95
+ $buildButtonName = "{$dataArray[0]}/{$dataArray[1]}/{$dataArray[2]}-{$dataArray[3]}.png";
96
+ $path = "{$fixPath}{$buildButtonName}";
97
+ if(file_exists(M4W_PLUGIN_DIR . '/'. $path)){
98
+ return "{$fixPath}{$buildButtonName}";
99
+ }else{
100
+ return "{$fixPath}/en/checkout/pill-golden.png";
101
+ }
102
+
103
+ }
104
+ }
105
+
src/Mollie/WC/Helper/Settings.php CHANGED
@@ -56,6 +56,14 @@ class Mollie_WC_Helper_Settings
56
  ),
57
  'default' => 'yes'
58
  ],
 
 
 
 
 
 
 
 
59
  'title' => [
60
  'title' => __('Title', 'mollie-payments-for-woocommerce'),
61
  'type' => 'text',
@@ -69,6 +77,19 @@ class Mollie_WC_Helper_Settings
69
  'default' => $defaultTitle,
70
  'desc_tip' => true,
71
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  'display_logo' => [
73
  'title' => __(
74
  'Display logo',
@@ -81,6 +102,32 @@ class Mollie_WC_Helper_Settings
81
  ),
82
  'default' => 'yes'
83
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  'enable_custom_logo' => [
85
  'title' => __(
86
  'Enable custom logo',
@@ -107,28 +154,13 @@ class Mollie_WC_Helper_Settings
107
  ),
108
  'desc_tip' => true,
109
  ],
110
- 'description' => [
111
- 'title' => __('Description', 'mollie-payments-for-woocommerce'),
112
- 'type' => 'textarea',
113
- 'description' => sprintf(
114
- __(
115
- 'Payment method description that the customer will see on your checkout. Default <code>%s</code>',
116
- 'mollie-payments-for-woocommerce'
117
- ),
118
- $defaultDescription
119
- ),
120
- 'default' => $defaultDescription,
121
- 'desc_tip' => true,
122
- ],
123
- 'allowed_countries' => [
124
- 'title' => __(
125
- 'Sell to specific countries',
126
- 'mollie-payments-for-woocommerce'
127
- ),
128
- 'desc' => '',
129
- 'css' => 'min-width: 350px;',
130
- 'default' => [],
131
- 'type' => 'multi_select_countries',
132
  ],
133
  'payment_surcharge' => [
134
  'title' => __(
@@ -199,7 +231,7 @@ class Mollie_WC_Helper_Settings
199
  'custom_attributes'=>['step'=>'0.01', 'min'=>'0.01', 'max'=>'999'],
200
  'default' => '0.01',
201
  'desc_tip' => true,
202
- ],
203
  ];
204
 
205
  if ($paymentConfirmation) {
56
  ),
57
  'default' => 'yes'
58
  ],
59
+ [
60
+ 'id' => $defaultTitle . '_' . 'title',
61
+ 'title' => sprintf(__(
62
+ '%s display settings',
63
+ 'mollie-payments-for-woocommerce'
64
+ ), $defaultTitle),
65
+ 'type' => 'title'
66
+ ],
67
  'title' => [
68
  'title' => __('Title', 'mollie-payments-for-woocommerce'),
69
  'type' => 'text',
77
  'default' => $defaultTitle,
78
  'desc_tip' => true,
79
  ],
80
+ 'description' => [
81
+ 'title' => __('Description', 'mollie-payments-for-woocommerce'),
82
+ 'type' => 'textarea',
83
+ 'description' => sprintf(
84
+ __(
85
+ 'Payment method description that the customer will see on your checkout. Default <code>%s</code>',
86
+ 'mollie-payments-for-woocommerce'
87
+ ),
88
+ $defaultDescription
89
+ ),
90
+ 'default' => $defaultDescription,
91
+ 'desc_tip' => true,
92
+ ],
93
  'display_logo' => [
94
  'title' => __(
95
  'Display logo',
102
  ),
103
  'default' => 'yes'
104
  ],
105
+ [
106
+ 'id' => $defaultTitle . '_' . 'title',
107
+ 'title' => sprintf(__(
108
+ 'Sales countries',
109
+ 'mollie-payments-for-woocommerce'
110
+ )),
111
+ 'type' => 'title'
112
+ ],
113
+ 'allowed_countries' => [
114
+ 'title' => __(
115
+ 'Sell to specific countries',
116
+ 'mollie-payments-for-woocommerce'
117
+ ),
118
+ 'desc' => '',
119
+ 'css' => 'min-width: 350px;',
120
+ 'default' => [],
121
+ 'type' => 'multi_select_countries',
122
+ ],
123
+ [
124
+ 'id' => $defaultTitle . '_' . 'custom_logo',
125
+ 'title' => sprintf(__(
126
+ '%s custom logo',
127
+ 'mollie-payments-for-woocommerce'
128
+ ), $defaultTitle),
129
+ 'type' => 'title'
130
+ ],
131
  'enable_custom_logo' => [
132
  'title' => __(
133
  'Enable custom logo',
154
  ),
155
  'desc_tip' => true,
156
  ],
157
+ [
158
+ 'id' => $defaultTitle . '_' . 'surcharge',
159
+ 'title' => sprintf(__(
160
+ '%s surcharge',
161
+ 'mollie-payments-for-woocommerce'
162
+ ), $defaultTitle),
163
+ 'type' => 'title'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  ],
165
  'payment_surcharge' => [
166
  'title' => __(
231
  'custom_attributes'=>['step'=>'0.01', 'min'=>'0.01', 'max'=>'999'],
232
  'default' => '0.01',
233
  'desc_tip' => true,
234
+ ]
235
  ];
236
 
237
  if ($paymentConfirmation) {
src/Mollie/WC/PayPalButton/AjaxRequests.php ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_PayPalButton_AjaxRequests
4
+ {
5
+
6
+ /**
7
+ * Adds all the Ajax actions to perform the whole workflow
8
+ */
9
+ public function bootstrapAjaxRequest()
10
+ {
11
+
12
+ add_action(
13
+ 'wp_ajax_' . Mollie_WC_PayPalButton_PropertiesDictionary::CREATE_ORDER,
14
+ array($this, 'createWcOrder')
15
+ );
16
+ add_action(
17
+ 'wp_ajax_nopriv_' . Mollie_WC_PayPalButton_PropertiesDictionary::CREATE_ORDER,
18
+ array($this, 'createWcOrder')
19
+ );
20
+ add_action(
21
+ 'wp_ajax_' . Mollie_WC_PayPalButton_PropertiesDictionary::CREATE_ORDER_CART,
22
+ array($this, 'createWcOrderFromCart')
23
+ );
24
+ add_action(
25
+ 'wp_ajax_nopriv_' . Mollie_WC_PayPalButton_PropertiesDictionary::CREATE_ORDER_CART,
26
+ array($this, 'createWcOrderFromCart')
27
+ );
28
+ add_action(
29
+ 'wp_ajax_' . Mollie_WC_PayPalButton_PropertiesDictionary::UPDATE_AMOUNT,
30
+ array($this, 'updateAmount')
31
+ );
32
+ add_action(
33
+ 'wp_ajax_nopriv_' . Mollie_WC_PayPalButton_PropertiesDictionary::UPDATE_AMOUNT,
34
+ array($this, 'updateAmount')
35
+ );
36
+
37
+ }
38
+
39
+ /**
40
+ * Creates the order from the product detail page and process the payment
41
+ * On error returns an array of errors to be handled by the script
42
+ * On success returns the status success
43
+ * and the url to redirect the user
44
+ *
45
+ * @throws WC_Data_Exception
46
+ * @throws \Mollie\Api\Exceptions\ApiException
47
+ */
48
+ public function createWcOrder()
49
+ {
50
+ $payPalRequestDataObject = $this->payPalDataObjectHttp();
51
+ $payPalRequestDataObject->orderData($_POST, 'productDetail');
52
+ if (!$this->isNonceValid($payPalRequestDataObject)) {
53
+ return;
54
+ }
55
+
56
+ $order = wc_create_order();
57
+ $order->add_product(
58
+ wc_get_product($payPalRequestDataObject->productId),
59
+ $payPalRequestDataObject->productQuantity
60
+ );
61
+
62
+ $surchargeHandler = new Mollie_WC_Helper_GatewaySurchargeHandler();
63
+ $order = $surchargeHandler->addSurchargeFeeProductPage($order, 'mollie_wc_gateway_paypal');
64
+
65
+ $orderId = $order->get_id();
66
+ $order->calculate_totals();
67
+ $this->updateOrderPostMeta($orderId, $order);
68
+
69
+ $result = $this->processOrderPayment($orderId);
70
+
71
+ if (isset($result['result'])
72
+ && 'success' === $result['result']
73
+ ) {
74
+ wp_send_json_success($result);
75
+ } else {
76
+ /* translators: Placeholder 1: Payment method title */
77
+ $message = sprintf(
78
+ __(
79
+ 'Could not create %s payment.',
80
+ 'mollie-payments-for-woocommerce'
81
+ ),
82
+ 'PayPal'
83
+ );
84
+
85
+ mollieWooCommerceDebug($message, 'error');
86
+ wp_send_json_error($message);
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Creates the order from the cart page and process the payment
92
+ * On error returns an array of errors to be handled by the script
93
+ * On success returns the status success
94
+ * and the url to redirect the user
95
+ *
96
+ * @throws WC_Data_Exception
97
+ * @throws \Mollie\Api\Exceptions\ApiException
98
+ */
99
+ public function createWcOrderFromCart()
100
+ {
101
+ $payPalRequestDataObject = $this->payPalDataObjectHttp();
102
+ $payPalRequestDataObject->orderData($_POST, 'cart');
103
+ if (!$this->isNonceValid($payPalRequestDataObject)) {
104
+ return;
105
+ }
106
+
107
+ list($cart, $order) = $this->createOrderFromCart();
108
+ $orderId = $order->get_id();
109
+ $order->calculate_totals();
110
+ $surchargeHandler = new Mollie_WC_Helper_GatewaySurchargeHandler();
111
+ $order = $surchargeHandler->addSurchargeFeeProductPage($order, 'mollie_wc_gateway_paypal');
112
+ $this->updateOrderPostMeta($orderId, $order);
113
+ $result = $this->processOrderPayment($orderId);
114
+ if (isset($result['result'])
115
+ && 'success' === $result['result']
116
+ ) {
117
+ $cart->empty_cart();
118
+ wp_send_json_success($result);
119
+ } else {
120
+ /* translators: Placeholder 1: Payment method title */
121
+ $message = sprintf(
122
+ __(
123
+ 'Could not create %s payment.',
124
+ 'mollie-payments-for-woocommerce'
125
+ ),
126
+ 'PayPal'
127
+ );
128
+
129
+ Mollie_WC_Plugin::addNotice($message, 'error');
130
+ wp_send_json_error($message);
131
+ }
132
+ }
133
+
134
+ public function updateAmount(){
135
+ $payPalRequestDataObject = $this->payPalDataObjectHttp();
136
+ $payPalRequestDataObject->orderData($_POST, 'productDetail');
137
+
138
+ if (!$this->isNonceValid($payPalRequestDataObject)) {
139
+ wp_send_json_error('no nonce');
140
+ }
141
+
142
+ $order = new Mollie_WC_PayPalButton_WCOrderCalculator();
143
+ $order->set_currency( get_woocommerce_currency() );
144
+ $order->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) );
145
+ $order->add_product(
146
+ wc_get_product($payPalRequestDataObject->productId),
147
+ $payPalRequestDataObject->productQuantity
148
+ );
149
+
150
+ $updatedAmount = $order->calculate_totals();
151
+
152
+ wp_send_json_success($updatedAmount);
153
+ }
154
+
155
+
156
+
157
+ /**
158
+ * Data Object to collect and validate all needed data collected
159
+ * through HTTP
160
+ *
161
+ * @return Mollie_WC_PayPalButton_PayPalDataObjectHttp
162
+ */
163
+ protected function PayPalDataObjectHttp()
164
+ {
165
+ return new Mollie_WC_PayPalButton_PayPalDataObjectHttp();
166
+ }
167
+
168
+ /**
169
+ * Update order post meta
170
+ *
171
+ * @param string $orderId
172
+ * @param $order
173
+ */
174
+ protected function updateOrderPostMeta($orderId, $order)
175
+ {
176
+ update_post_meta($orderId, '_customer_user', get_current_user_id());
177
+ update_post_meta(
178
+ $orderId,
179
+ '_payment_method',
180
+ 'mollie_wc_gateway_paypal'
181
+ );
182
+ update_post_meta($orderId, '_payment_method_title', 'PayPal');
183
+ $order->update_status(
184
+ 'Processing',
185
+ 'PayPal Button order',
186
+ true
187
+ );
188
+ }
189
+
190
+ /**
191
+ * Process order payment with PayPal gateway
192
+ *
193
+ * @param int $orderId
194
+ *
195
+ * @return array|string[]
196
+ * @throws \Mollie\Api\Exceptions\ApiException
197
+ */
198
+ protected function processOrderPayment($orderId)
199
+ {
200
+ $gateway = new Mollie_WC_Gateway_PayPal();
201
+
202
+ $result = $gateway->process_payment($orderId);
203
+ return $result;
204
+ }
205
+
206
+ /**
207
+ * Handles the order creation in cart page
208
+ *
209
+ * @return array
210
+ * @throws Exception
211
+ */
212
+ protected function createOrderFromCart()
213
+ {
214
+ $cart = WC()->cart;
215
+ $checkout = WC()->checkout();
216
+ $orderId = $checkout->create_order([]);
217
+ $order = wc_get_order($orderId);
218
+ return array($cart, $order);
219
+ }
220
+
221
+ /**
222
+ * Checks if the nonce in the data object is valid
223
+ *
224
+ * @param Mollie_WC_PayPalButton_PayPalDataObjectHttp $PayPalRequestDataObject
225
+ *
226
+ * @return bool|int
227
+ */
228
+ protected function isNonceValid(
229
+ Mollie_WC_PayPalButton_PayPalDataObjectHttp $PayPalRequestDataObject
230
+ ) {
231
+ $isNonceValid = wp_verify_nonce(
232
+ $PayPalRequestDataObject->nonce,
233
+ 'mollie_PayPal_button'
234
+ );
235
+ return $isNonceValid;
236
+ }
237
+
238
+ }
src/Mollie/WC/PayPalButton/DataToPayPalScripts.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_PayPalButton_DataToPayPalScripts
4
+ {
5
+ /**
6
+ * Sets the appropriate data to send to PayPal script
7
+ * Data differs between product page and cart page
8
+ *
9
+ * @return array|bool
10
+ */
11
+ public function paypalbuttonScriptData()
12
+ {
13
+ $paypalSettings = get_option('mollie_wc_gateway_paypal_settings', false);
14
+ $minAmount = 0;
15
+ if ($paypalSettings) {
16
+ $minAmount
17
+ = isset($paypalSettings['mollie_paypal_button_minimum_amount'])
18
+ && $paypalSettings['mollie_paypal_button_minimum_amount'] > 0
19
+ ? $paypalSettings['mollie_paypal_button_minimum_amount'] : 0;
20
+ }
21
+
22
+ if (is_product()) {
23
+ return $this->dataForProductPage($minAmount);
24
+ }
25
+ if (is_cart()) {
26
+ return $this->dataForCartPage($minAmount);
27
+ }
28
+ return [];
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @param $minAmount
34
+ *
35
+ * @return array|bool
36
+ */
37
+ protected function dataForProductPage($minAmount)
38
+ {
39
+
40
+ $product = wc_get_product(get_the_id());
41
+ if (!$product) {
42
+ return false;
43
+ }
44
+ $isVariation = false;
45
+ if ($product->get_type() === 'variable') {
46
+ $isVariation = true;
47
+ }
48
+ $productNeedShipping = mollieWooCommerceCheckIfNeedShipping($product);
49
+ $productId = get_the_id();
50
+ $productPrice = $product->get_price();
51
+
52
+ return [
53
+ 'product' => [
54
+ 'needShipping' => $productNeedShipping,
55
+ 'id' => $productId,
56
+ 'price' => $productPrice,
57
+ 'isVariation' => $isVariation,
58
+ 'minFee' =>$minAmount
59
+ ],
60
+ 'ajaxUrl' => admin_url('admin-ajax.php')
61
+ ];
62
+ }
63
+
64
+ /**
65
+ *
66
+ * @param $minAmount
67
+ *
68
+ * @return array
69
+ */
70
+ protected function dataForCartPage($minAmount)
71
+ {
72
+ $cart = WC()->cart;
73
+ return [
74
+ 'product' => [
75
+ 'needShipping' => $cart->needs_shipping(),
76
+ 'minFee' =>$minAmount
77
+
78
+ ],
79
+ 'ajaxUrl' => admin_url('admin-ajax.php')
80
+ ];
81
+ }
82
+
83
+ }
src/Mollie/WC/PayPalButton/PayPalDataObjectHttp.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_PayPalButton_PayPalDataObjectHttp
4
+ {
5
+
6
+ /**
7
+ * @var mixed
8
+ */
9
+ public $nonce;
10
+ /**
11
+ * @var mixed|null
12
+ */
13
+ public $needShipping;
14
+ /**
15
+ * @var mixed
16
+ */
17
+ public $productId;
18
+ /**
19
+ * @var mixed
20
+ */
21
+ public $productQuantity;
22
+
23
+ /**
24
+ * @var mixed
25
+ */
26
+ public $callerPage;
27
+
28
+ /**
29
+ * @var array
30
+ */
31
+ public $errors = [];
32
+
33
+ /**
34
+ * Resets the errors array
35
+ */
36
+ protected function resetErrors()
37
+ {
38
+ $this->errors = [];
39
+ }
40
+
41
+ /**
42
+ * Returns if the object has any errors
43
+ * @return bool
44
+ */
45
+ public function hasErrors()
46
+ {
47
+ return !empty($this->errors);
48
+ }
49
+
50
+
51
+ /**
52
+ * Set the object with the data relevant to PayPal
53
+ * Required data depends on callerPage
54
+ *
55
+ * @param array $data
56
+ * @param $callerPage
57
+ */
58
+ public function orderData(array $data, $callerPage)
59
+ {
60
+ $data[Mollie_WC_PayPalButton_PropertiesDictionary::CALLER_PAGE] = $callerPage;
61
+ $this->updateRequiredData(
62
+ $data,
63
+ Mollie_WC_PayPalButton_PropertiesDictionary::CREATE_ORDER_SINGLE_PROD_REQUIRED_FIELDS,
64
+ Mollie_WC_PayPalButton_PropertiesDictionary::CREATE_ORDER_CART_REQUIRED_FIELDS
65
+ );
66
+ }
67
+
68
+ /**
69
+ * Checks if the array contains all required fields and if those
70
+ * are not empty.
71
+ * If not it adds an unkown error to the object's error list, as this errors
72
+ * are not supported by ApplePay
73
+ *
74
+ * @param array $data
75
+ * @param array $required
76
+ *
77
+ * @return bool
78
+ */
79
+ protected function hasRequiredFieldsValuesOrError(array $data, array $required)
80
+ {
81
+ foreach ($required as $requiredField) {
82
+ if (!array_key_exists($requiredField, $data)) {
83
+ mollieWooCommerceDebug(
84
+ "PayPal Data Error: Missing index {$requiredField}"
85
+ );
86
+
87
+ $this->errors[]= ['errorCode' => 'unknown'];
88
+ continue;
89
+ }
90
+ if (!$data[$requiredField]) {
91
+ mollieWooCommerceDebug(
92
+ "PayPal Data Error: Missing value for {$requiredField}"
93
+ );
94
+ $this->errors[]= ['errorCode' => 'unknown'];
95
+ continue;
96
+ }
97
+ }
98
+ return !$this->hasErrors();
99
+ }
100
+
101
+ /**
102
+ * Sets the value to the appropriate field in the object
103
+ *
104
+ * @param array $data
105
+ */
106
+ protected function assignDataObjectValues(array $data)
107
+ {
108
+ $allowedKeys = [
109
+ Mollie_WC_PayPalButton_PropertiesDictionary::NONCE,
110
+ Mollie_WC_PayPalButton_PropertiesDictionary::PRODUCT_QUANTITY,
111
+ Mollie_WC_PayPalButton_PropertiesDictionary::PRODUCT_ID,
112
+ Mollie_WC_PayPalButton_PropertiesDictionary::NEED_SHIPPING
113
+ ];
114
+ foreach ($data as $key => $value) {
115
+ if(in_array($key, $allowedKeys)){
116
+ $filterType = $this->filterType($key);
117
+ $this->$key = filter_var($value, $filterType);
118
+ }
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Selector for the different filters to apply to each field
124
+ * @param $value
125
+ *
126
+ * @return int
127
+ */
128
+ protected function filterType($value)
129
+ {
130
+ $filterInt = [
131
+ Mollie_WC_PayPalButton_PropertiesDictionary::PRODUCT_QUANTITY,
132
+ Mollie_WC_PayPalButton_PropertiesDictionary::PRODUCT_ID
133
+ ];
134
+ $filterBoolean = [Mollie_WC_PayPalButton_PropertiesDictionary::NEED_SHIPPING];
135
+ switch ($value) {
136
+ case in_array($value, $filterInt):
137
+ return FILTER_SANITIZE_NUMBER_INT;
138
+ break;
139
+ case in_array($value, $filterBoolean):
140
+ return FILTER_VALIDATE_BOOLEAN;
141
+ break;
142
+ default:
143
+ return FILTER_SANITIZE_STRING;
144
+ }
145
+ }
146
+
147
+
148
+ /**
149
+ * @param array $data
150
+ * @param $requiredProductFields
151
+ * @param $requiredCartFields
152
+ *
153
+ * @return bool
154
+ */
155
+ protected function updateRequiredData(array $data, $requiredProductFields, $requiredCartFields)
156
+ {
157
+ $this->resetErrors();
158
+ $requiredFields = $requiredProductFields;
159
+ if (isset($data[Mollie_WC_PayPalButton_PropertiesDictionary::CALLER_PAGE])
160
+ && $data[Mollie_WC_PayPalButton_PropertiesDictionary::CALLER_PAGE] == 'cart'
161
+ ) {
162
+ $requiredFields = $requiredCartFields;
163
+ }
164
+ $hasRequiredFieldsValues = $this->hasRequiredFieldsValuesOrError(
165
+ $data,
166
+ $requiredFields
167
+ );
168
+ if (!$hasRequiredFieldsValues) {
169
+ return false;
170
+ }
171
+ $this->assignDataObjectValues($data);
172
+ return true;
173
+ }
174
+ }
src/Mollie/WC/PayPalButton/PropertiesDictionary.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_PayPalButton_PropertiesDictionary
4
+ {
5
+ const CREATE_ORDER_SINGLE_PROD_REQUIRED_FIELDS
6
+ = [
7
+ Mollie_WC_PayPalButton_PropertiesDictionary::NONCE,
8
+ Mollie_WC_PayPalButton_PropertiesDictionary::PRODUCT_ID,
9
+ self::PRODUCT_QUANTITY
10
+ ];
11
+ const CREATE_ORDER_CART_REQUIRED_FIELDS
12
+ = [
13
+ Mollie_WC_PayPalButton_PropertiesDictionary::NONCE
14
+ ];
15
+
16
+ const PRODUCT_ID = 'productId';
17
+ const NONCE = 'nonce';
18
+ const PRODUCT_QUANTITY = 'productQuantity';
19
+ const CALLER_PAGE = 'callerPage';
20
+ const NEED_SHIPPING = 'needShipping';
21
+ const CREATE_ORDER = 'mollie_paypal_create_order';
22
+ const CREATE_ORDER_CART = 'mollie_paypal_create_order_cart';
23
+ const UPDATE_AMOUNT = 'mollie_paypal_update_amount';
24
+ const REDIRECT = 'mollie_paypal_redirect';
25
+ }
src/Mollie/WC/PayPalButton/WCOrderCalculator.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mollie_WC_PayPalButton_WCOrderCalculator extends WC_Order
4
+ {
5
+ /**
6
+ * Calculate totals by looking at the contents of the order.
7
+ *
8
+ * @since 2.2
9
+ * @param bool $and_taxes Calc taxes if true.
10
+ * @return float calculated grand total.
11
+ */
12
+ public function calculate_totals( $and_taxes = true ) {
13
+ do_action( 'woocommerce_order_before_calculate_totals', $and_taxes, $this );
14
+
15
+ $fees_total = 0;
16
+ $shipping_total = 0;
17
+ $cart_subtotal_tax = 0;
18
+ $cart_total_tax = 0;
19
+
20
+ $cart_subtotal = $this->get_cart_subtotal_for_order();
21
+ $cart_total = $this->get_cart_total_for_order();
22
+
23
+ // Sum shipping costs.
24
+ foreach ( $this->get_shipping_methods() as $shipping ) {
25
+ $shipping_total += $this->round( $shipping->get_total(), wc_get_price_decimals() );
26
+ }
27
+
28
+ $this->set_shipping_total( $shipping_total );
29
+
30
+ // Sum fee costs.
31
+ foreach ( $this->get_fees() as $item ) {
32
+ $fee_total = $item->get_total();
33
+
34
+ if ( 0 > $fee_total ) {
35
+ $max_discount = $this->round( $cart_total + $fees_total + $shipping_total, wc_get_price_decimals() ) * -1;
36
+
37
+ if ( $fee_total < $max_discount && 0 > $max_discount ) {
38
+ $item->set_total( $max_discount );
39
+ }
40
+ }
41
+ $fees_total += $item->get_total();
42
+ }
43
+
44
+ // Calculate taxes for items, shipping, discounts. Note; this also triggers save().
45
+ if ( $and_taxes ) {
46
+ $this->calculate_taxes();
47
+ }
48
+
49
+ // Sum taxes again so we can work out how much tax was discounted. This uses original values, not those possibly rounded to 2dp.
50
+ foreach ( $this->get_items() as $item ) {
51
+ $taxes = $item->get_taxes();
52
+
53
+ foreach ( $taxes['total'] as $tax_rate_id => $tax ) {
54
+ $cart_total_tax += (float) $tax;
55
+ }
56
+
57
+ foreach ( $taxes['subtotal'] as $tax_rate_id => $tax ) {
58
+ $cart_subtotal_tax += (float) $tax;
59
+ }
60
+ }
61
+
62
+ $this->set_discount_total( $this->round( $cart_subtotal - $cart_total, wc_get_price_decimals() ) );
63
+ $this->set_discount_tax( wc_round_tax_total( $cart_subtotal_tax - $cart_total_tax ) );
64
+ $this->set_total( $this->round( $cart_total + $fees_total + $this->get_shipping_total() + $this->get_cart_tax() + $this->get_shipping_tax(), wc_get_price_decimals() ) );
65
+
66
+ do_action( 'woocommerce_order_after_calculate_totals', $and_taxes, $this );
67
+
68
+
69
+ return $this->get_total();
70
+ }
71
+ /**
72
+ * Update tax lines for the order based on the line item taxes themselves.
73
+ */
74
+ public function update_taxes() {
75
+ $cart_taxes = array();
76
+ $shipping_taxes = array();
77
+ $existing_taxes = $this->get_taxes();
78
+ $saved_rate_ids = array();
79
+
80
+ foreach ( $this->get_items( array( 'line_item', 'fee' ) ) as $item_id => $item ) {
81
+ $taxes = $item->get_taxes();
82
+ foreach ( $taxes['total'] as $tax_rate_id => $tax ) {
83
+ $tax_amount = $this->round_line_tax( $tax, false );
84
+
85
+ $cart_taxes[ $tax_rate_id ] = isset( $cart_taxes[ $tax_rate_id ] ) ? $cart_taxes[ $tax_rate_id ] + $tax_amount : $tax_amount;
86
+ }
87
+ }
88
+
89
+ foreach ( $this->get_shipping_methods() as $item_id => $item ) {
90
+ $taxes = $item->get_taxes();
91
+ foreach ( $taxes['total'] as $tax_rate_id => $tax ) {
92
+ $tax_amount = (float) $tax;
93
+
94
+ if ( 'yes' !== get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
95
+ $tax_amount = wc_round_tax_total( $tax_amount );
96
+ }
97
+
98
+ $shipping_taxes[ $tax_rate_id ] = isset( $shipping_taxes[ $tax_rate_id ] ) ? $shipping_taxes[ $tax_rate_id ] + $tax_amount : $tax_amount;
99
+ }
100
+ }
101
+
102
+ foreach ( $existing_taxes as $tax ) {
103
+ // Remove taxes which no longer exist for cart/shipping.
104
+ if ( ( ! array_key_exists( $tax->get_rate_id(), $cart_taxes ) && ! array_key_exists( $tax->get_rate_id(), $shipping_taxes ) ) || in_array( $tax->get_rate_id(), $saved_rate_ids, true ) ) {
105
+ $this->remove_item( $tax->get_id() );
106
+ continue;
107
+ }
108
+ $saved_rate_ids[] = $tax->get_rate_id();
109
+ $tax->set_tax_total( isset( $cart_taxes[ $tax->get_rate_id() ] ) ? $cart_taxes[ $tax->get_rate_id() ] : 0 );
110
+ $tax->set_shipping_tax_total( ! empty( $shipping_taxes[ $tax->get_rate_id() ] ) ? $shipping_taxes[ $tax->get_rate_id() ] : 0 );
111
+ $tax->save();
112
+ }
113
+
114
+ $new_rate_ids = wp_parse_id_list( array_diff( array_keys( $cart_taxes + $shipping_taxes ), $saved_rate_ids ) );
115
+
116
+ // New taxes.
117
+ foreach ( $new_rate_ids as $tax_rate_id ) {
118
+ $item = new WC_Order_Item_Tax();
119
+ $item->set_rate( $tax_rate_id );
120
+ $item->set_tax_total( isset( $cart_taxes[ $tax_rate_id ] ) ? $cart_taxes[ $tax_rate_id ] : 0 );
121
+ $item->set_shipping_tax_total( ! empty( $shipping_taxes[ $tax_rate_id ] ) ? $shipping_taxes[ $tax_rate_id ] : 0 );
122
+ $this->add_item( $item );
123
+ }
124
+
125
+ $this->set_shipping_tax( array_sum( $shipping_taxes ) );
126
+ $this->set_cart_tax( array_sum( $cart_taxes ) );
127
+
128
+ }
129
+
130
+
131
+ public function add_product( $product, $qty = 1, $args = array() ) {
132
+ if ( $product ) {
133
+ $default_args = array(
134
+ 'name' => $product->get_name(),
135
+ 'tax_class' => $product->get_tax_class(),
136
+ 'product_id' => $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id(),
137
+ 'variation_id' => $product->is_type( 'variation' ) ? $product->get_id() : 0,
138
+ 'variation' => $product->is_type( 'variation' ) ? $product->get_attributes() : array(),
139
+ 'subtotal' => wc_get_price_excluding_tax( $product, array( 'qty' => $qty ) ),
140
+ 'total' => wc_get_price_excluding_tax( $product, array( 'qty' => $qty ) ),
141
+ 'quantity' => $qty,
142
+ );
143
+ } else {
144
+ $default_args = array(
145
+ 'quantity' => $qty,
146
+ );
147
+ }
148
+
149
+ $args = wp_parse_args( $args, $default_args );
150
+
151
+ // BW compatibility with old args.
152
+ if ( isset( $args['totals'] ) ) {
153
+ foreach ( $args['totals'] as $key => $value ) {
154
+ if ( 'tax' === $key ) {
155
+ $args['total_tax'] = $value;
156
+ } elseif ( 'tax_data' === $key ) {
157
+ $args['taxes'] = $value;
158
+ } else {
159
+ $args[ $key ] = $value;
160
+ }
161
+ }
162
+ }
163
+
164
+ $item = new WC_Order_Item_Product();
165
+ $item->set_props( $args );
166
+ $item->set_backorder_meta();
167
+ $item->set_order_id( $this->get_id() );
168
+
169
+ $this->add_item( $item );
170
+ wc_do_deprecated_action( 'woocommerce_order_add_product', array( $this->get_id(), $item->get_id(), $product, $qty, $args ), '3.0', 'woocommerce_new_order_item action instead' );
171
+ delete_transient( 'wc_order_' . $this->get_id() . '_needs_processing' );
172
+ return $item->get_id();
173
+ }
174
+
175
+ protected function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP )
176
+ {
177
+ if ( ! is_numeric( $val ) ) {
178
+ $val = floatval( $val );
179
+ }
180
+ return round( $val, $precision, $mode );
181
+ }
182
+ }
src/Mollie/WC/Payment/Order.php CHANGED
@@ -73,8 +73,11 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
73
  $selectedIssuer = $gateway->getSelectedIssuer();
74
  $returnUrl = $gateway->getReturnUrl( $order );
75
  $webhookUrl = $gateway->getWebhookUrl( $order );
76
- $billingAddress = $this->createBillingAddress($order);
77
- $shippingAddress = $this->createShippingAddress($order);
 
 
 
78
 
79
  // Generate order lines for Mollie Orders
80
  $orderLinesHelper = Mollie_WC_Plugin::getOrderLinesHelper(
@@ -101,7 +104,7 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
101
  'issuer' => $selectedIssuer
102
  ),
103
  'locale' => $paymentLocale,
104
- 'billingAddress' => $billingAddress,
105
  'metadata' => apply_filters(
106
  Mollie_WC_Plugin::PLUGIN_ID . '_payment_object_metadata',
107
  array(
@@ -111,7 +114,6 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
111
  ),
112
  'lines' => $orderLines['lines'],
113
  'orderNumber' => $order->get_order_number(),
114
- // TODO David: use order number or order id?
115
  );
116
 
117
  // Add sequenceType for subscriptions first payments
@@ -245,6 +247,22 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
245
  // Add messages to log
246
  Mollie_WC_Plugin::debug( __METHOD__ . " called for order {$orderId}" );
247
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  $order->payment_complete($payment->id);
249
 
250
  // Add messages to log
@@ -340,6 +358,21 @@ class Mollie_WC_Payment_Order extends Mollie_WC_Payment_Object {
340
  // Add messages to log
341
  Mollie_WC_Plugin::debug( __METHOD__ . ' called for order ' . $orderId );
342
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
  $order->payment_complete($payment->id);
344
  // Add messages to log
345
  Mollie_WC_Plugin::debug( __METHOD__ . ' WooCommerce payment_complete() processed and returned to ' . __METHOD__ . ' for order ' . $orderId );
73
  $selectedIssuer = $gateway->getSelectedIssuer();
74
  $returnUrl = $gateway->getReturnUrl( $order );
75
  $webhookUrl = $gateway->getWebhookUrl( $order );
76
+ if($mollieMethod !== 'paypal' || ($mollieMethod === 'paypal' && $order->get_billing_first_name() !== '')){
77
+ $billingAddress = $this->createBillingAddress($order);
78
+ $shippingAddress = $this->createShippingAddress($order);
79
+ }
80
+
81
 
82
  // Generate order lines for Mollie Orders
83
  $orderLinesHelper = Mollie_WC_Plugin::getOrderLinesHelper(
104
  'issuer' => $selectedIssuer
105
  ),
106
  'locale' => $paymentLocale,
107
+ 'billingAddress' => $billingAddress? $billingAddress: null,
108
  'metadata' => apply_filters(
109
  Mollie_WC_Plugin::PLUGIN_ID . '_payment_object_metadata',
110
  array(
114
  ),
115
  'lines' => $orderLines['lines'],
116
  'orderNumber' => $order->get_order_number(),
 
117
  );
118
 
119
  // Add sequenceType for subscriptions first payments
247
  // Add messages to log
248
  Mollie_WC_Plugin::debug( __METHOD__ . " called for order {$orderId}" );
249
 
250
+ if($payment->method === 'paypal'){
251
+ $address = $payment->shippingAddress;
252
+ $filter = FILTER_SANITIZE_STRING;
253
+ $shippingAddress = [
254
+ 'first_name' => filter_var($address->givenName, $filter),
255
+ 'last_name' => filter_var($address->familyName, $filter),
256
+ 'email' => filter_var($address->email, $filter),
257
+ 'postcode' => filter_var($address->postalCode, $filter),
258
+ 'country' => strtoupper(filter_var($address->country, $filter)),
259
+ 'city' => filter_var($address->city, $filter),
260
+ 'address_1' => filter_var($address->streetAndNumber, $filter)
261
+ ];
262
+
263
+ $order->set_address($shippingAddress, 'shipping');
264
+ }
265
+
266
  $order->payment_complete($payment->id);
267
 
268
  // Add messages to log
358
  // Add messages to log
359
  Mollie_WC_Plugin::debug( __METHOD__ . ' called for order ' . $orderId );
360
 
361
+ if($payment->method === 'paypal'){
362
+ $address = $payment->shippingAddress;
363
+ $filter = FILTER_SANITIZE_STRING;
364
+ $shippingAddress = [
365
+ 'first_name' => filter_var($address->givenName, $filter),
366
+ 'last_name' => filter_var($address->familyName, $filter),
367
+ 'email' => filter_var($address->email, $filter),
368
+ 'postcode' => filter_var($address->postalCode, $filter),
369
+ 'country' => strtoupper(filter_var($address->country, $filter)),
370
+ 'city' => filter_var($address->city, $filter),
371
+ 'address_1' => filter_var($address->streetAndNumber, $filter)
372
+ ];
373
+
374
+ $order->set_address($shippingAddress, 'shipping');
375
+ }
376
  $order->payment_complete($payment->id);
377
  // Add messages to log
378
  Mollie_WC_Plugin::debug( __METHOD__ . ' WooCommerce payment_complete() processed and returned to ' . __METHOD__ . ' for order ' . $orderId );
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 = '6.3.0';
12
 
13
  const DB_VERSION = '1.0';
14
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
@@ -274,6 +274,9 @@ class Mollie_WC_Plugin
274
  self::mollieApplePayDirectHandling();
275
  self::gatewaySurchargeHandling();
276
 
 
 
 
277
  self::initDb();
278
  self::schedulePendingPaymentOrdersExpirationCheck();
279
  self::registerFrontendScripts();
@@ -308,7 +311,7 @@ class Mollie_WC_Plugin
308
  '<strong>',
309
  '</strong>',
310
  '<a href="' . esc_url(
311
- admin_url('admin.php?page=wc-settings&tab=checkout')
312
  ) . '">',
313
  '</a>'
314
  );
@@ -598,6 +601,49 @@ class Mollie_WC_Plugin
598
  }
599
  }
600
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601
  /**
602
  * Bootstrap the ApplePay button logic if feature enabled
603
  */
@@ -615,7 +661,21 @@ class Mollie_WC_Plugin
615
  }
616
  }
617
 
618
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
619
 
620
  /**
621
  * @param Refund $refund
@@ -708,6 +768,20 @@ class Mollie_WC_Plugin
708
  filemtime(Mollie_WC_Plugin::getPluginPath('/public/js/applepayDirect.min.js')),
709
  true
710
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
711
  wp_register_script(
712
  'mollie_applepaydirectCart',
713
  Mollie_WC_Plugin::getPluginUrl('/public/js/applepayDirectCart.min.js'),
8
  {
9
  const PLUGIN_ID = 'mollie-payments-for-woocommerce';
10
  const PLUGIN_TITLE = 'Mollie Payments for WooCommerce';
11
+ const PLUGIN_VERSION = '6.4.0';
12
 
13
  const DB_VERSION = '1.0';
14
  const DB_VERSION_PARAM_NAME = 'mollie-db-version';
274
  self::mollieApplePayDirectHandling();
275
  self::gatewaySurchargeHandling();
276
 
277
+ add_action('wp_enqueue_scripts', [__CLASS__, 'enqueuePayPalButtonScripts']);
278
+ self::molliePayPalButtonHandling();
279
+
280
  self::initDb();
281
  self::schedulePendingPaymentOrdersExpirationCheck();
282
  self::registerFrontendScripts();
311
  '<strong>',
312
  '</strong>',
313
  '<a href="' . esc_url(
314
+ admin_url('admin.php?page=wc-settings&tab=mollie_settings')
315
  ) . '">',
316
  '</a>'
317
  );
601
  }
602
  }
603
 
604
+ /**
605
+ * Enqueues the ApplePay button scripts if enabled and in correct page
606
+ */
607
+ public static function enqueuePayPalButtonScripts()
608
+ {
609
+
610
+ if (mollieWooCommerceIsPayPalButtonEnabled('product') && is_product()) {
611
+ $product = wc_get_product(get_the_id());
612
+ if (!$product || $product->is_type('subscription')) {
613
+ return;
614
+ }
615
+ $productNeedShipping = mollieWooCommerceCheckIfNeedShipping($product);
616
+ if(!$productNeedShipping){
617
+ $dataToScripts = new Mollie_WC_PayPalButton_DataToPayPalScripts();
618
+ wp_enqueue_style('unabledButton');
619
+ wp_enqueue_script('mollie_paypalButton');
620
+ wp_localize_script(
621
+ 'mollie_paypalButton',
622
+ 'molliepaypalbutton',
623
+ $dataToScripts->paypalbuttonScriptData()
624
+ );
625
+ }
626
+ }
627
+ if (mollieWooCommerceIsPayPalButtonEnabled('cart') && is_cart()) {
628
+ $cart = WC()->cart;
629
+ foreach ($cart->get_cart_contents() as $product){
630
+ if($product['data']->is_type('subscription')){
631
+ return;
632
+ }
633
+ }
634
+ if(!$cart->needs_shipping()){
635
+ $dataToScripts = new Mollie_WC_PayPalButton_DataToPayPalScripts();
636
+ wp_enqueue_style('unabledButton');
637
+ wp_enqueue_script('mollie_paypalButtonCart');
638
+ wp_localize_script(
639
+ 'mollie_paypalButtonCart',
640
+ 'molliepaypalButtonCart',
641
+ $dataToScripts->paypalbuttonScriptData()
642
+ );
643
+ }
644
+ }
645
+ }
646
+
647
  /**
648
  * Bootstrap the ApplePay button logic if feature enabled
649
  */
661
  }
662
  }
663
 
664
+ /**
665
+ * Bootstrap the PayPal button logic if feature enabled
666
+ */
667
+ public static function molliePayPalButtonHandling()
668
+ {
669
+ $enabledInProduct = (mollieWooCommerceIsPayPalButtonEnabled('product'));
670
+ $enabledInCart = (mollieWooCommerceIsPayPalButtonEnabled('cart'));
671
+ $shouldBuildIt = $enabledInProduct || $enabledInCart;
672
+
673
+ if ($shouldBuildIt) {
674
+ $ajaxRequests = new Mollie_WC_PayPalButton_AjaxRequests();
675
+ $payPalHandler = new Mollie_WC_Helper_PayPalButtonHandler($ajaxRequests);
676
+ $payPalHandler->bootstrap($enabledInProduct, $enabledInCart);
677
+ }
678
+ }
679
 
680
  /**
681
  * @param Refund $refund
768
  filemtime(Mollie_WC_Plugin::getPluginPath('/public/js/applepayDirect.min.js')),
769
  true
770
  );
771
+ wp_register_script(
772
+ 'mollie_paypalButton',
773
+ Mollie_WC_Plugin::getPluginUrl('/public/js/paypalButton.min.js'),
774
+ ['underscore', 'jquery'],
775
+ filemtime(Mollie_WC_Plugin::getPluginPath('/public/js/paypalButton.min.js')),
776
+ true
777
+ );
778
+ wp_register_script(
779
+ 'mollie_paypalButtonCart',
780
+ Mollie_WC_Plugin::getPluginUrl('/public/js/paypalButtonCart.min.js'),
781
+ ['underscore', 'jquery'],
782
+ filemtime(Mollie_WC_Plugin::getPluginPath('/public/js/paypalButtonCart.min.js')),
783
+ true
784
+ );
785
  wp_register_script(
786
  'mollie_applepaydirectCart',
787
  Mollie_WC_Plugin::getPluginUrl('/public/js/applepayDirectCart.min.js'),