@automattic/newspack-blocks 4.18.0 → 4.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ msgid ""
2
2
  msgstr ""
3
3
  "Project-Id-Version: Newspack Blocks 1.0.0-alpha.25\n"
4
4
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/project\n"
5
- "POT-Creation-Date: 2025-11-13T18:38:30+00:00\n"
5
+ "POT-Creation-Date: 2025-11-24T20:10:24+00:00\n"
6
6
  "PO-Revision-Date: 2024-08-30 08:46-0700\n"
7
7
  "Last-Translator: \n"
8
8
  "Language-Team: \n"
@@ -67,169 +67,169 @@ msgstr ""
67
67
  msgid "Or"
68
68
  msgstr ""
69
69
 
70
- #: includes/class-modal-checkout.php:977
70
+ #: includes/class-modal-checkout.php:979 includes/class-modal-checkout.php:983
71
71
  msgid "Processing payment..."
72
72
  msgstr ""
73
73
 
74
- #: includes/class-modal-checkout.php:981
74
+ #: includes/class-modal-checkout.php:987
75
75
  msgid "Verifying details..."
76
76
  msgstr ""
77
77
 
78
- #: includes/class-modal-checkout.php:985
78
+ #: includes/class-modal-checkout.php:991
79
79
  msgid "Finalizing transaction..."
80
80
  msgstr ""
81
81
 
82
- #: includes/class-modal-checkout.php:1041
82
+ #: includes/class-modal-checkout.php:1047
83
83
  msgid ""
84
84
  "We're sorry, there was an unexpected error. Please try again in a few "
85
85
  "minutes."
86
86
  msgstr ""
87
87
 
88
- #: includes/class-modal-checkout.php:1053
88
+ #: includes/class-modal-checkout.php:1059
89
89
  msgid "Go back"
90
90
  msgstr ""
91
91
 
92
- #: includes/class-modal-checkout.php:1143
92
+ #: includes/class-modal-checkout.php:1149
93
93
  msgid "Password mismatch"
94
94
  msgstr ""
95
95
 
96
- #: includes/class-modal-checkout.php:1144
96
+ #: includes/class-modal-checkout.php:1150
97
97
  msgid "Password strength: Very weak"
98
98
  msgstr ""
99
99
 
100
- #: includes/class-modal-checkout.php:1145
100
+ #: includes/class-modal-checkout.php:1151
101
101
  msgid "Password strength: Weak"
102
102
  msgstr ""
103
103
 
104
- #: includes/class-modal-checkout.php:1146
104
+ #: includes/class-modal-checkout.php:1152
105
105
  msgid "Password strength: Medium"
106
106
  msgstr ""
107
107
 
108
- #: includes/class-modal-checkout.php:1147
108
+ #: includes/class-modal-checkout.php:1153
109
109
  msgid "Password strength: Strong"
110
110
  msgstr ""
111
111
 
112
- #: includes/class-modal-checkout.php:1328
112
+ #: includes/class-modal-checkout.php:1334
113
113
  msgid "Please enter someone else' email address to receive this gift."
114
114
  msgstr ""
115
115
 
116
- #: includes/class-modal-checkout.php:1329
116
+ #: includes/class-modal-checkout.php:1335
117
117
  msgid "Please enter a valid email address to receive this gift."
118
118
  msgstr ""
119
119
 
120
- #: includes/class-modal-checkout.php:1418
120
+ #: includes/class-modal-checkout.php:1424
121
121
  msgid "Close window"
122
122
  msgstr ""
123
123
 
124
124
  #. translators: %s: Site name.
125
- #: includes/class-modal-checkout.php:1505
125
+ #: includes/class-modal-checkout.php:1511
126
126
  #, php-format
127
127
  msgid ""
128
128
  "You're already a subscriber! You can only have one active subscription at a "
129
129
  "time. Thank you for supporting %s."
130
130
  msgstr ""
131
131
 
132
- #: includes/class-modal-checkout.php:1516
132
+ #: includes/class-modal-checkout.php:1522
133
133
  msgid ""
134
134
  "You're already a subscriber! You can only have one subscription at a time. "
135
135
  "If you wish to renew an expired subscription, please sign in and visit the "
136
136
  "subscriptions page on your account."
137
137
  msgstr ""
138
138
 
139
- #: includes/class-modal-checkout.php:1554
140
- msgid "Could not complete this transaction. Please contact us for assistance."
141
- msgstr ""
142
-
143
139
  #. translators: 1: Checkout button confirmation text. 2: Order total.
144
140
  #. translators: 1 is the name of the item. 2 is the price of the item.
145
- #: includes/class-modal-checkout.php:1640
146
- #: includes/modal-checkout/class-checkout-data.php:67
141
+ #: includes/class-modal-checkout.php:1646
142
+ #: includes/modal-checkout/class-checkout-data.php:68
147
143
  #, php-format
148
144
  msgid "%1$s: %2$s"
149
145
  msgstr ""
150
146
 
151
- #: includes/class-modal-checkout.php:1999
147
+ #: includes/class-modal-checkout.php:2005
152
148
  msgid "Billing details"
153
149
  msgstr ""
154
150
 
155
- #: includes/class-modal-checkout.php:2000
151
+ #: includes/class-modal-checkout.php:2006
156
152
  msgid "Shipping details"
157
153
  msgstr ""
158
154
 
159
- #: includes/class-modal-checkout.php:2001
155
+ #: includes/class-modal-checkout.php:2007
160
156
  msgid "Gift recipient"
161
157
  msgstr ""
162
158
 
163
- #: includes/class-modal-checkout.php:2002
164
- #: includes/class-modal-checkout.php:2003
165
- #: includes/class-modal-checkout.php:2004
159
+ #: includes/class-modal-checkout.php:2008
160
+ #: includes/class-modal-checkout.php:2009
161
+ #: includes/class-modal-checkout.php:2010
166
162
  msgid "Complete your transaction"
167
163
  msgstr ""
168
164
 
169
- #: includes/class-modal-checkout.php:2005
165
+ #: includes/class-modal-checkout.php:2011
170
166
  msgctxt "Login modal title when logged out user attempts to checkout."
171
167
  msgid "Sign in to complete transaction"
172
168
  msgstr ""
173
169
 
174
- #: includes/class-modal-checkout.php:2010
170
+ #: includes/class-modal-checkout.php:2016
175
171
  msgctxt "Login modal title when unregistered user attempts to checkout"
176
172
  msgid "Register to complete transaction"
177
173
  msgstr ""
178
174
 
179
- #: includes/class-modal-checkout.php:2015
175
+ #: includes/class-modal-checkout.php:2021
180
176
  msgid "Continue browsing"
181
177
  msgstr ""
182
178
 
183
- #: includes/class-modal-checkout.php:2016
179
+ #: includes/class-modal-checkout.php:2022
184
180
  msgid "This donation is a gift"
185
181
  msgstr ""
186
182
 
187
- #: includes/class-modal-checkout.php:2021
183
+ #: includes/class-modal-checkout.php:2027
188
184
  msgid "This purchase is a gift"
189
185
  msgstr ""
190
186
 
191
- #: includes/class-modal-checkout.php:2023
187
+ #: includes/class-modal-checkout.php:2029
192
188
  msgid "Complete transaction"
193
189
  msgstr ""
194
190
 
195
- #: includes/class-modal-checkout.php:2024
191
+ #: includes/class-modal-checkout.php:2030
196
192
  msgid "Purchase"
197
193
  msgstr ""
198
194
 
199
- #: includes/class-modal-checkout.php:2025
195
+ #: includes/class-modal-checkout.php:2031
200
196
  msgid "Edit billing information"
201
197
  msgstr ""
202
198
 
203
- #: includes/class-modal-checkout.php:2026 dist/editor.js:29
199
+ #: includes/class-modal-checkout.php:2032 dist/editor.js:29
204
200
  #: src/blocks/checkout-button/edit.js:192
205
201
  msgid "Cancel"
206
202
  msgstr ""
207
203
 
208
- #: includes/class-modal-checkout.php:2027
204
+ #: includes/class-modal-checkout.php:2033
209
205
  msgid "Transaction successful"
210
206
  msgstr ""
211
207
 
212
- #: includes/class-modal-checkout.php:2028
208
+ #: includes/class-modal-checkout.php:2034
213
209
  msgid ""
214
210
  "Your contribution directly funds our work. If you're moved to do so, you can "
215
211
  "opt to pay more than the standard rate."
216
212
  msgstr ""
217
213
 
218
- #: includes/class-modal-checkout.php:2029
214
+ #: includes/class-modal-checkout.php:2035
219
215
  msgid "Thank you for your generosity! We couldn't do this without you!"
220
216
  msgstr ""
221
217
 
222
- #: includes/class-modal-checkout.php:2030
218
+ #: includes/class-modal-checkout.php:2036
223
219
  msgid "Increase your support"
224
220
  msgstr ""
225
221
 
226
- #: includes/class-modal-checkout.php:2031
222
+ #: includes/class-modal-checkout.php:2037
227
223
  #: src/modal-checkout/templates/form-coupon.php:20
228
224
  msgid "Apply"
229
225
  msgstr ""
230
226
 
227
+ #: includes/class-modal-checkout.php:2038
228
+ msgid "We ran into a problem processing this request. Please try again."
229
+ msgstr ""
230
+
231
231
  #. Translators: %s is the site name.
232
- #: includes/class-modal-checkout.php:2168
232
+ #: includes/class-modal-checkout.php:2175
233
233
  #, php-format
234
234
  msgid ""
235
235
  "Thank you for supporting %s. Your transaction was completed successfully."
@@ -308,7 +308,7 @@ msgstr ""
308
308
  msgid " per "
309
309
  msgstr ""
310
310
 
311
- #: includes/modal-checkout/class-checkout-data.php:301 dist/editor.js:35
311
+ #: includes/modal-checkout/class-checkout-data.php:310 dist/editor.js:35
312
312
  #: src/blocks/donate/index.js:31
313
313
  msgid "Donate"
314
314
  msgstr "Doação"
@@ -2,14 +2,14 @@
2
2
  # This file is distributed under the same license as the Newspack Blocks plugin.
3
3
  msgid ""
4
4
  msgstr ""
5
- "Project-Id-Version: Newspack Blocks 4.17.4\n"
5
+ "Project-Id-Version: Newspack Blocks 4.18.0\n"
6
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/project\n"
7
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
9
  "MIME-Version: 1.0\n"
10
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "POT-Creation-Date: 2025-11-13T18:38:30+00:00\n"
12
+ "POT-Creation-Date: 2025-11-24T20:10:24+00:00\n"
13
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
14
  "X-Generator: WP-CLI 2.12.0\n"
15
15
  "X-Domain: newspack-blocks\n"
@@ -68,161 +68,162 @@ msgstr ""
68
68
  msgid "Or"
69
69
  msgstr ""
70
70
 
71
- #: includes/class-modal-checkout.php:977
71
+ #: includes/class-modal-checkout.php:979
72
+ #: includes/class-modal-checkout.php:983
72
73
  msgid "Processing payment..."
73
74
  msgstr ""
74
75
 
75
- #: includes/class-modal-checkout.php:981
76
+ #: includes/class-modal-checkout.php:987
76
77
  msgid "Verifying details..."
77
78
  msgstr ""
78
79
 
79
- #: includes/class-modal-checkout.php:985
80
+ #: includes/class-modal-checkout.php:991
80
81
  msgid "Finalizing transaction..."
81
82
  msgstr ""
82
83
 
83
- #: includes/class-modal-checkout.php:1041
84
+ #: includes/class-modal-checkout.php:1047
84
85
  msgid "We're sorry, there was an unexpected error. Please try again in a few minutes."
85
86
  msgstr ""
86
87
 
87
- #: includes/class-modal-checkout.php:1053
88
+ #: includes/class-modal-checkout.php:1059
88
89
  msgid "Go back"
89
90
  msgstr ""
90
91
 
91
- #: includes/class-modal-checkout.php:1143
92
+ #: includes/class-modal-checkout.php:1149
92
93
  msgid "Password mismatch"
93
94
  msgstr ""
94
95
 
95
- #: includes/class-modal-checkout.php:1144
96
+ #: includes/class-modal-checkout.php:1150
96
97
  msgid "Password strength: Very weak"
97
98
  msgstr ""
98
99
 
99
- #: includes/class-modal-checkout.php:1145
100
+ #: includes/class-modal-checkout.php:1151
100
101
  msgid "Password strength: Weak"
101
102
  msgstr ""
102
103
 
103
- #: includes/class-modal-checkout.php:1146
104
+ #: includes/class-modal-checkout.php:1152
104
105
  msgid "Password strength: Medium"
105
106
  msgstr ""
106
107
 
107
- #: includes/class-modal-checkout.php:1147
108
+ #: includes/class-modal-checkout.php:1153
108
109
  msgid "Password strength: Strong"
109
110
  msgstr ""
110
111
 
111
- #: includes/class-modal-checkout.php:1328
112
+ #: includes/class-modal-checkout.php:1334
112
113
  msgid "Please enter someone else' email address to receive this gift."
113
114
  msgstr ""
114
115
 
115
- #: includes/class-modal-checkout.php:1329
116
+ #: includes/class-modal-checkout.php:1335
116
117
  msgid "Please enter a valid email address to receive this gift."
117
118
  msgstr ""
118
119
 
119
- #: includes/class-modal-checkout.php:1418
120
+ #: includes/class-modal-checkout.php:1424
120
121
  msgid "Close window"
121
122
  msgstr ""
122
123
 
123
124
  #. translators: %s: Site name.
124
- #: includes/class-modal-checkout.php:1505
125
+ #: includes/class-modal-checkout.php:1511
125
126
  #, php-format
126
127
  msgid "You're already a subscriber! You can only have one active subscription at a time. Thank you for supporting %s."
127
128
  msgstr ""
128
129
 
129
- #: includes/class-modal-checkout.php:1516
130
+ #: includes/class-modal-checkout.php:1522
130
131
  msgid "You're already a subscriber! You can only have one subscription at a time. If you wish to renew an expired subscription, please sign in and visit the subscriptions page on your account."
131
132
  msgstr ""
132
133
 
133
- #: includes/class-modal-checkout.php:1554
134
- msgid "Could not complete this transaction. Please contact us for assistance."
135
- msgstr ""
136
-
137
134
  #. translators: 1: Checkout button confirmation text. 2: Order total.
138
135
  #. translators: 1 is the name of the item. 2 is the price of the item.
139
- #: includes/class-modal-checkout.php:1640
140
- #: includes/modal-checkout/class-checkout-data.php:67
136
+ #: includes/class-modal-checkout.php:1646
137
+ #: includes/modal-checkout/class-checkout-data.php:68
141
138
  #, php-format
142
139
  msgid "%1$s: %2$s"
143
140
  msgstr ""
144
141
 
145
- #: includes/class-modal-checkout.php:1999
142
+ #: includes/class-modal-checkout.php:2005
146
143
  msgid "Billing details"
147
144
  msgstr ""
148
145
 
149
- #: includes/class-modal-checkout.php:2000
146
+ #: includes/class-modal-checkout.php:2006
150
147
  msgid "Shipping details"
151
148
  msgstr ""
152
149
 
153
- #: includes/class-modal-checkout.php:2001
150
+ #: includes/class-modal-checkout.php:2007
154
151
  msgid "Gift recipient"
155
152
  msgstr ""
156
153
 
157
- #: includes/class-modal-checkout.php:2002
158
- #: includes/class-modal-checkout.php:2003
159
- #: includes/class-modal-checkout.php:2004
154
+ #: includes/class-modal-checkout.php:2008
155
+ #: includes/class-modal-checkout.php:2009
156
+ #: includes/class-modal-checkout.php:2010
160
157
  msgid "Complete your transaction"
161
158
  msgstr ""
162
159
 
163
- #: includes/class-modal-checkout.php:2005
160
+ #: includes/class-modal-checkout.php:2011
164
161
  msgctxt "Login modal title when logged out user attempts to checkout."
165
162
  msgid "Sign in to complete transaction"
166
163
  msgstr ""
167
164
 
168
- #: includes/class-modal-checkout.php:2010
165
+ #: includes/class-modal-checkout.php:2016
169
166
  msgctxt "Login modal title when unregistered user attempts to checkout"
170
167
  msgid "Register to complete transaction"
171
168
  msgstr ""
172
169
 
173
- #: includes/class-modal-checkout.php:2015
170
+ #: includes/class-modal-checkout.php:2021
174
171
  msgid "Continue browsing"
175
172
  msgstr ""
176
173
 
177
- #: includes/class-modal-checkout.php:2016
174
+ #: includes/class-modal-checkout.php:2022
178
175
  msgid "This donation is a gift"
179
176
  msgstr ""
180
177
 
181
- #: includes/class-modal-checkout.php:2021
178
+ #: includes/class-modal-checkout.php:2027
182
179
  msgid "This purchase is a gift"
183
180
  msgstr ""
184
181
 
185
- #: includes/class-modal-checkout.php:2023
182
+ #: includes/class-modal-checkout.php:2029
186
183
  msgid "Complete transaction"
187
184
  msgstr ""
188
185
 
189
- #: includes/class-modal-checkout.php:2024
186
+ #: includes/class-modal-checkout.php:2030
190
187
  msgid "Purchase"
191
188
  msgstr ""
192
189
 
193
- #: includes/class-modal-checkout.php:2025
190
+ #: includes/class-modal-checkout.php:2031
194
191
  msgid "Edit billing information"
195
192
  msgstr ""
196
193
 
197
- #: includes/class-modal-checkout.php:2026
194
+ #: includes/class-modal-checkout.php:2032
198
195
  #: dist/editor.js:29
199
196
  #: src/blocks/checkout-button/edit.js:192
200
197
  msgid "Cancel"
201
198
  msgstr ""
202
199
 
203
- #: includes/class-modal-checkout.php:2027
200
+ #: includes/class-modal-checkout.php:2033
204
201
  msgid "Transaction successful"
205
202
  msgstr ""
206
203
 
207
- #: includes/class-modal-checkout.php:2028
204
+ #: includes/class-modal-checkout.php:2034
208
205
  msgid "Your contribution directly funds our work. If you're moved to do so, you can opt to pay more than the standard rate."
209
206
  msgstr ""
210
207
 
211
- #: includes/class-modal-checkout.php:2029
208
+ #: includes/class-modal-checkout.php:2035
212
209
  msgid "Thank you for your generosity! We couldn't do this without you!"
213
210
  msgstr ""
214
211
 
215
- #: includes/class-modal-checkout.php:2030
212
+ #: includes/class-modal-checkout.php:2036
216
213
  msgid "Increase your support"
217
214
  msgstr ""
218
215
 
219
- #: includes/class-modal-checkout.php:2031
216
+ #: includes/class-modal-checkout.php:2037
220
217
  #: src/modal-checkout/templates/form-coupon.php:20
221
218
  msgid "Apply"
222
219
  msgstr ""
223
220
 
221
+ #: includes/class-modal-checkout.php:2038
222
+ msgid "We ran into a problem processing this request. Please try again."
223
+ msgstr ""
224
+
224
225
  #. Translators: %s is the site name.
225
- #: includes/class-modal-checkout.php:2168
226
+ #: includes/class-modal-checkout.php:2175
226
227
  #, php-format
227
228
  msgid "Thank you for supporting %s. Your transaction was completed successfully."
228
229
  msgstr ""
@@ -300,7 +301,7 @@ msgstr ""
300
301
  msgid " per "
301
302
  msgstr ""
302
303
 
303
- #: includes/modal-checkout/class-checkout-data.php:301
304
+ #: includes/modal-checkout/class-checkout-data.php:310
304
305
  #: dist/editor.js:35
305
306
  #: src/blocks/donate/index.js:31
306
307
  msgid "Donate"
@@ -7,7 +7,7 @@
7
7
  * Author URI: https://newspack.com/
8
8
  * Text Domain: newspack-blocks
9
9
  * Domain Path: /languages
10
- * Version: 4.18.0
10
+ * Version: 4.19.0
11
11
  *
12
12
  * @package Newspack_Blocks
13
13
  */
@@ -15,13 +15,14 @@
15
15
  define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
16
16
  define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
17
17
  define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
18
- define( 'NEWSPACK_BLOCKS__VERSION', '4.18.0' );
18
+ define( 'NEWSPACK_BLOCKS__VERSION', '4.19.0' );
19
19
 
20
20
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
21
21
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
22
22
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-patterns.php';
23
23
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-caching.php';
24
24
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/modal-checkout/class-checkout-data.php';
25
+ require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/modal-checkout/class-change-payment-gateway.php';
25
26
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-modal-checkout.php';
26
27
 
27
28
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/plugins/class-the-events-calendar.php';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/newspack-blocks",
3
- "version": "4.18.0",
3
+ "version": "4.19.0",
4
4
  "author": "Automattic",
5
5
  "description": "=== Newspack Blocks === Contributors: (this should be a list of wordpress.org userid's) Donate link: https://example.com/ Tags: comments, spam Requires at least: 4.5 Tested up to: 5.1.1 Stable tag: 0.1.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html",
6
6
  "repository": {
@@ -52,7 +52,7 @@
52
52
  "swiper": "12.0.3"
53
53
  },
54
54
  "devDependencies": {
55
- "@types/lodash": "^4.17.20",
55
+ "@types/lodash": "^4.17.21",
56
56
  "newspack-components": "^4.2.0",
57
57
  "newspack-scripts": "^5.8.0"
58
58
  },
@@ -1,6 +1,10 @@
1
1
  @use "newspack-colors" as np-colors;
2
2
  @use "../../shared/sass/placeholder";
3
3
 
4
+ .wp-block:has(> .wpnbpc) {
5
+ max-width: 100%;
6
+ }
7
+
4
8
  .wp-block-newspack-blocks-carousel {
5
9
  .swiper-wrapper {
6
10
  height: auto;
@@ -43,6 +47,7 @@
43
47
  margin-right: 1.5em;
44
48
  }
45
49
  }
50
+
46
51
  .editor-block-list__layout .editor-block-list__block .wpnbpc .entry-title a,
47
52
  .editor-block-list__layout .editor-block-list__block .wpnbpc .entry-meta .byline a {
48
53
  color: inherit;
@@ -6,6 +6,7 @@
6
6
  .wp-block-newspack-blocks-carousel {
7
7
  position: relative;
8
8
  margin-top: 0;
9
+ max-width: 100%;
9
10
 
10
11
  article {
11
12
  max-width: 100%;
@@ -8,7 +8,7 @@ import './checkout.scss';
8
8
  * Internal dependencies
9
9
  */
10
10
  import { manageCheckoutAttempt, manageCheckoutSuccess, manageLoaded, managePagination } from './analytics';
11
- import { domReady } from './utils';
11
+ import { domReady, onCheckoutPlaceOrderProcessing } from './utils';
12
12
 
13
13
  ( $ => {
14
14
  domReady( () => {
@@ -26,6 +26,7 @@ import { domReady } from './utils';
26
26
  const placeOrderStartEvent = new CustomEvent( 'checkout-place-order-start' );
27
27
  const placeOrderSuccessEvent = new CustomEvent( 'checkout-place-order-success' );
28
28
  const placeOrderErrorEvent = new CustomEvent( 'checkout-place-order-error' );
29
+ const placeOrderCriticalErrorEvent = new CustomEvent( 'checkout-place-order-critical-error' );
29
30
 
30
31
  function getEventHandlers( element, event ) {
31
32
  const events = $._data( element, 'events' );
@@ -121,16 +122,30 @@ import { domReady } from './utils';
121
122
  placedOrder = true;
122
123
  container.dispatchEvent( placeOrderStartEvent );
123
124
  } );
125
+ onCheckoutPlaceOrderProcessing( container, function () {
126
+ if ( ! placedOrder ) {
127
+ return;
128
+ }
129
+ // If the form stops processing before the `checkout_place_order_success` event is fired, dispatch an error event.
130
+ if ( ! $form.is( '.processing' ) ) {
131
+ placedOrder = false;
132
+ container.dispatchEvent( placeOrderErrorEvent );
133
+ }
134
+ } );
124
135
  $form.on( 'checkout_place_order_success', function () {
125
136
  placedOrder = false;
126
137
  container.dispatchEvent( placeOrderSuccessEvent );
127
138
  } );
128
139
 
129
- $( document.body ).on( 'checkout_error', function () {
140
+ $( document.body ).on( 'checkout_error', function ( event, errors ) {
130
141
  if ( ! placedOrder ) {
131
142
  return;
132
143
  }
133
144
  placedOrder = false;
145
+ if ( errors && errors.indexOf( newspackBlocksModalCheckout.labels.critical_error ) >= 0 ) {
146
+ container.dispatchEvent( placeOrderCriticalErrorEvent );
147
+ return;
148
+ }
134
149
  container.dispatchEvent( placeOrderErrorEvent );
135
150
  } );
136
151
  $form.on( 'update_checkout', function () {
@@ -18,6 +18,7 @@ import {
18
18
  onCheckoutCancel,
19
19
  onCheckoutPlaceOrderStart,
20
20
  onCheckoutPlaceOrderError,
21
+ onCheckoutPlaceOrderCriticalError,
21
22
  createHiddenInput,
22
23
  triggerFormSubmit,
23
24
  getCheckoutData,
@@ -39,6 +40,9 @@ let inCheckoutIntent = false;
39
40
  // Checkout title.
40
41
  let checkoutTitle = newspackBlocksModal.labels.checkout_modal_title;
41
42
 
43
+ // Last-submitted checkout form.
44
+ let activeCheckoutForm = null;
45
+
42
46
  // Close the modal.
43
47
  const closeModal = el => {
44
48
  if ( el.overlayId && window.newspackReaderActivation?.overlays ) {
@@ -129,13 +133,14 @@ domReady( () => {
129
133
  processingPaymentTimeouts = [];
130
134
  };
131
135
 
132
- const renderProcessingPaymentScreen = () => {
136
+ const renderProcessingPaymentScreen = event => {
133
137
  spinner.querySelectorAll( `.${ PROCESSING_PAYMENT_TEXT_CLASS }` ).forEach( node => node.remove() );
134
138
  spinner.style.display = 'flex';
135
139
  clearProcessingPaymentTimeouts();
136
140
  processingPaymentText.textContent = PROCESSING_PAYMENT_MESSAGES[ 0 ]?.text ?? '';
137
141
  PROCESSING_PAYMENT_MESSAGES.slice( 1 ).forEach( ( { text, delay } ) => {
138
142
  const timeoutId = setTimeout( () => {
143
+ event.target.dispatchEvent( new CustomEvent( 'checkout-place-order-processing' ) );
139
144
  processingPaymentText.textContent = text;
140
145
  }, delay );
141
146
  processingPaymentTimeouts.push( timeoutId );
@@ -164,6 +169,15 @@ domReady( () => {
164
169
  summaryTextNode.textContent = checkoutData.price_summary;
165
170
  }
166
171
 
172
+ // Display initial errors if any.
173
+ if ( modalCheckout.initialErrors ) {
174
+ const errorContainer = document.createElement( 'div' );
175
+ errorContainer.classList.add( 'woocommerce-error' );
176
+ errorContainer.textContent = modalCheckout.initialErrors;
177
+ container.prepend( errorContainer );
178
+ delete modalCheckout.initialErrors;
179
+ }
180
+
167
181
  // Revert modal title and width default value.
168
182
  setModalSize();
169
183
  setModalTitle( checkoutTitle );
@@ -192,6 +206,20 @@ domReady( () => {
192
206
 
193
207
  hideProcessingPaymentScreen();
194
208
  } );
209
+
210
+ // Resubmit modal checkout form if an unrecoverable error is encountered.
211
+ const refreshCheckout = form => {
212
+ if ( ! form ) {
213
+ return;
214
+ }
215
+ closeCheckout();
216
+ spinner.style.display = 'none';
217
+ modalCheckout.initialErrors = newspackBlocksModal.labels.critical_error;
218
+ form.requestSubmit( form.querySelector( 'button[type="submit"]' ) );
219
+ hideProcessingPaymentScreen();
220
+ };
221
+
222
+ onCheckoutPlaceOrderCriticalError( container, () => refreshCheckout( activeCheckoutForm ) );
195
223
  }
196
224
 
197
225
  iframeReady( iframe, handleIframeReady, () => {
@@ -468,6 +496,7 @@ domReady( () => {
468
496
  // Append product data info to the modal, so we can grab it for GA4 events outside of the iframe.
469
497
  document.getElementById( 'newspack_modal_checkout' ).setAttribute( 'data-checkout', JSON.stringify( checkoutData ) );
470
498
  }
499
+ activeCheckoutForm = form;
471
500
  };
472
501
 
473
502
  /**