@automattic/newspack-blocks 2.6.2 → 3.0.0-alpha.1
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.
- package/.cache/babel/135eb7c6e583be53418b26a29fcc4d81.json.gz +0 -0
- package/.cache/babel/2bec24377bb9890c2268bcd4c8f3953c.json.gz +0 -0
- package/.cache/babel/9ba57ee86df44178ceb255eaf0e770e3.json.gz +0 -0
- package/.cache/babel/a804bf1963e56137e59e37a567cb5e2e.json.gz +0 -0
- package/.cache/babel/b94e6dc0852876a37bd23ec88c5b2583.json.gz +0 -0
- package/.cache/babel/c04d2af94bb0f10f408a15534301cc86.json.gz +0 -0
- package/.cache/babel/c8d4b9ae4be3002e8507d71f1136ebc6.json.gz +0 -0
- package/.cache/babel/d21f5515648ce2a2349b0ee5cc787fce.json.gz +0 -0
- package/.cache/babel/d3eee0c40fc44bc734dee21a645a4f7d.json.gz +0 -0
- package/.cache/babel/d661309b03e38954105e706a32ef09f6.json.gz +0 -0
- package/.cache/babel/e2dd36051554e75a2bf087b85c11e43d.json.gz +0 -0
- package/.hooks/pre-push +2 -2
- package/CHANGELOG.md +21 -0
- package/composer.lock +38 -36
- package/dist/donate/view.asset.php +1 -1
- package/dist/donate/view.css +1 -1
- package/dist/donate/view.rtl.css +1 -1
- package/dist/editor.asset.php +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.js +11 -11
- package/dist/editor.rtl.css +1 -1
- package/dist/frequencyBased.asset.php +1 -1
- package/dist/frequencyBased.css +1 -1
- package/dist/frequencyBased.rtl.css +1 -1
- package/dist/modalCheckout.asset.php +1 -1
- package/dist/modalCheckout.css +1 -1
- package/dist/modalCheckout.rtl.css +1 -1
- package/dist/tiersBased.asset.php +1 -1
- package/dist/tiersBased.css +1 -1
- package/dist/tiersBased.js +1 -1
- package/dist/tiersBased.rtl.css +1 -1
- package/includes/class-modal-checkout.php +11 -14
- package/includes/class-newspack-blocks.php +87 -43
- package/languages/newspack-blocks-de_DE.po +0 -40
- package/languages/newspack-blocks-es_ES.po +0 -40
- package/languages/newspack-blocks-fr_BE.po +0 -40
- package/languages/newspack-blocks-pt_PT.po +0 -40
- package/languages/newspack-blocks.pot +0 -38
- package/newspack-blocks.php +2 -14
- package/package.json +7 -8
- package/src/blocks/checkout-button/edit.js +5 -1
- package/src/blocks/donate/block.json +0 -12
- package/src/blocks/donate/edit/FrequencyBasedLayout.tsx +61 -106
- package/src/blocks/donate/edit/TierBasedLayout.tsx +7 -26
- package/src/blocks/donate/edit/components/index.tsx +0 -1
- package/src/blocks/donate/edit/index.tsx +157 -152
- package/src/blocks/donate/frequency-based/style.scss +5 -0
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-base.php +33 -147
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-frequency-based.php +21 -10
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-tiers-based.php +3 -50
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer.php +1 -14
- package/src/blocks/donate/styles/editor.scss +6 -28
- package/src/blocks/donate/styles/style-variations.scss +17 -8
- package/src/blocks/donate/styles/view.scss +9 -0
- package/src/blocks/donate/tiers-based/style.scss +0 -11
- package/src/blocks/donate/tiers-based/utils.test.js +38 -0
- package/src/blocks/donate/tiers-based/utils.ts +1 -2
- package/src/blocks/donate/tiers-based/view.ts +0 -33
- package/src/blocks/donate/types.ts +0 -16
- package/src/blocks/donate/utils.ts +31 -0
- package/src/blocks/homepage-articles/block.json +18 -0
- package/src/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php +1 -1
- package/src/blocks/homepage-articles/edit.js +3 -0
- package/src/blocks/homepage-articles/utils.ts +4 -0
- package/src/blocks/homepage-articles/view.php +4 -4
- package/src/components/query-controls.js +41 -8
- package/src/modal-checkout/checkout.scss +4 -5
- package/src/types/index.d.ts +4 -3
- package/vendor/autoload.php +1 -1
- package/vendor/composer/autoload_real.php +4 -4
- package/vendor/composer/autoload_static.php +2 -2
- package/vendor/composer/installed.php +2 -2
- package/webpack.config.js +0 -1
- package/.cache/babel/18dda1142078f066419138e7284f03bf.json.gz +0 -0
- package/.cache/babel/1f43960564787ebde7c6d44957cddf0e.json.gz +0 -0
- package/.cache/babel/225618337c609eed2be110274ff82be1.json.gz +0 -0
- package/.cache/babel/29d960d2fc51492a4bea1f4f165810fb.json.gz +0 -0
- package/.cache/babel/2f22325668b5763f8f2c9557833af36f.json.gz +0 -0
- package/.cache/babel/39bcc541624feefe54d1493493ae1ce8.json.gz +0 -0
- package/.cache/babel/4d450b37d365154f05b17cbf6a009255.json.gz +0 -0
- package/.cache/babel/87e2dc4a961b25b0de8d1a8ac88eea13.json.gz +0 -0
- package/.cache/babel/91884d41523f3790da70ea305ee187f2.json.gz +0 -0
- package/.cache/babel/b1ac90699e641ff99e1449b5d7b686e5.json.gz +0 -0
- package/.cache/babel/c5a441fdf7d90d45d2cbeb89967c61fe.json.gz +0 -0
- package/.cache/babel/c7cfb8590e887722a3e715c72ee99bac.json.gz +0 -0
- package/.cache/babel/e1d8932bb19afa36f476f107dbc6ca39.json.gz +0 -0
- package/.cache/babel/f60f8c23ec2b4448cb2815d79207d8c0.json.gz +0 -0
- package/dist/donateStreamlined.asset.php +0 -1
- package/dist/donateStreamlined.css +0 -1
- package/dist/donateStreamlined.js +0 -1
- package/dist/donateStreamlined.rtl.css +0 -1
- package/src/blocks/donate/class-wp-rest-newspack-donate-controller.php +0 -206
- package/src/blocks/donate/edit/components/AdditionalFields.tsx +0 -282
- package/src/blocks/donate/streamlined/index.test.js +0 -132
- package/src/blocks/donate/streamlined/index.ts +0 -356
- package/src/blocks/donate/streamlined/style.scss +0 -306
- package/src/blocks/donate/streamlined/utils.test.js +0 -18
- package/src/blocks/donate/streamlined/utils.ts +0 -217
- package/src/blocks/donate/tiers-based/view.test.js +0 -209
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
5
5
|
import { Component } from '@wordpress/element';
|
|
6
6
|
import { Button, QueryControls as BasicQueryControls, ToggleControl } from '@wordpress/components';
|
|
7
7
|
import apiFetch from '@wordpress/api-fetch';
|
|
@@ -233,20 +233,22 @@ class QueryControls extends Component {
|
|
|
233
233
|
onTagExclusionsChange,
|
|
234
234
|
categoryExclusions,
|
|
235
235
|
onCategoryExclusionsChange,
|
|
236
|
+
customTaxonomyExclusions,
|
|
237
|
+
onCustomTaxonomyExclusionsChange,
|
|
236
238
|
enableSpecific,
|
|
237
239
|
} = this.props;
|
|
238
240
|
const { showAdvancedFilters } = this.state;
|
|
239
241
|
|
|
240
242
|
const registeredCustomTaxonomies = window.newspack_blocks_data?.custom_taxonomies;
|
|
241
243
|
|
|
242
|
-
const customTaxonomiesPrepareChange = ( taxSlug, value ) => {
|
|
243
|
-
let newValue =
|
|
244
|
+
const customTaxonomiesPrepareChange = ( taxArr, taxHandler, taxSlug, value ) => {
|
|
245
|
+
let newValue = taxArr.filter( tax => tax.slug !== taxSlug );
|
|
244
246
|
newValue = [ ...newValue, { slug: taxSlug, terms: value } ];
|
|
245
|
-
|
|
247
|
+
taxHandler( newValue );
|
|
246
248
|
};
|
|
247
249
|
|
|
248
|
-
const getTermsOfCustomTaxonomy = taxSlug => {
|
|
249
|
-
const tax =
|
|
250
|
+
const getTermsOfCustomTaxonomy = ( taxArr, taxSlug ) => {
|
|
251
|
+
const tax = taxArr.find( taxObj => taxObj.slug === taxSlug );
|
|
250
252
|
return tax ? tax.terms : [];
|
|
251
253
|
};
|
|
252
254
|
|
|
@@ -312,9 +314,14 @@ class QueryControls extends Component {
|
|
|
312
314
|
registeredCustomTaxonomies.map( tax => (
|
|
313
315
|
<AutocompleteTokenField
|
|
314
316
|
key={ `${ customTaxonomies[ tax.slug ] }-selector` }
|
|
315
|
-
tokens={ getTermsOfCustomTaxonomy( tax.slug ) }
|
|
317
|
+
tokens={ getTermsOfCustomTaxonomy( customTaxonomies, tax.slug ) }
|
|
316
318
|
onChange={ value => {
|
|
317
|
-
customTaxonomiesPrepareChange(
|
|
319
|
+
customTaxonomiesPrepareChange(
|
|
320
|
+
customTaxonomies,
|
|
321
|
+
onCustomTaxonomiesChange,
|
|
322
|
+
tax.slug,
|
|
323
|
+
value
|
|
324
|
+
);
|
|
318
325
|
} }
|
|
319
326
|
fetchSuggestions={ search =>
|
|
320
327
|
this.fetchCustomTaxonomiesSuggestions( tax.slug, search )
|
|
@@ -355,6 +362,31 @@ class QueryControls extends Component {
|
|
|
355
362
|
label={ __( 'Excluded Categories', 'newspack-blocks' ) }
|
|
356
363
|
/>
|
|
357
364
|
) }
|
|
365
|
+
{ registeredCustomTaxonomies &&
|
|
366
|
+
onCustomTaxonomyExclusionsChange &&
|
|
367
|
+
registeredCustomTaxonomies.map( ( { label, slug } ) => (
|
|
368
|
+
<AutocompleteTokenField
|
|
369
|
+
fetchSavedInfo={ termIds => this.fetchSavedCustomTaxonomies( slug, termIds ) }
|
|
370
|
+
fetchSuggestions={ search =>
|
|
371
|
+
this.fetchCustomTaxonomiesSuggestions( slug, search )
|
|
372
|
+
}
|
|
373
|
+
key={ `${ slug }-exclusions-selector` }
|
|
374
|
+
label={ sprintf(
|
|
375
|
+
// translators: %s is the custom taxonomy label.
|
|
376
|
+
__( 'Excluded %s', 'newspack-blocks' ),
|
|
377
|
+
label
|
|
378
|
+
) }
|
|
379
|
+
onChange={ value =>
|
|
380
|
+
customTaxonomiesPrepareChange(
|
|
381
|
+
customTaxonomyExclusions,
|
|
382
|
+
onCustomTaxonomyExclusionsChange,
|
|
383
|
+
slug,
|
|
384
|
+
value
|
|
385
|
+
)
|
|
386
|
+
}
|
|
387
|
+
tokens={ getTermsOfCustomTaxonomy( customTaxonomyExclusions, slug ) }
|
|
388
|
+
/>
|
|
389
|
+
) ) }
|
|
358
390
|
</>
|
|
359
391
|
) }
|
|
360
392
|
</>
|
|
@@ -372,6 +404,7 @@ QueryControls.defaultProps = {
|
|
|
372
404
|
tags: [],
|
|
373
405
|
customTaxonomies: [],
|
|
374
406
|
tagExclusions: [],
|
|
407
|
+
customTaxonomyExclusions: [],
|
|
375
408
|
};
|
|
376
409
|
|
|
377
410
|
export default QueryControls;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@use '../shared/sass/colors';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/* stylelint-disable-next-line */
|
|
4
|
+
#newspack_modal_checkout {
|
|
4
5
|
padding: 32px;
|
|
5
6
|
font-size: 1rem;
|
|
6
7
|
.order-details-summary {
|
|
@@ -81,9 +82,6 @@
|
|
|
81
82
|
|
|
82
83
|
form {
|
|
83
84
|
margin: 0;
|
|
84
|
-
#wc-stripe-payment-request-button-separator {
|
|
85
|
-
margin: 0;
|
|
86
|
-
}
|
|
87
85
|
.woocommerce-terms-and-conditions-wrapper {
|
|
88
86
|
margin: 16px 0;
|
|
89
87
|
}
|
|
@@ -97,7 +95,8 @@
|
|
|
97
95
|
.select2-container .select2-selection--single {
|
|
98
96
|
margin: 0;
|
|
99
97
|
}
|
|
100
|
-
|
|
98
|
+
/* stylelint-disable-next-line */
|
|
99
|
+
#payment button#place_order {
|
|
101
100
|
margin-bottom: 0;
|
|
102
101
|
}
|
|
103
102
|
.checkout-billing button[type='submit'],
|
package/src/types/index.d.ts
CHANGED
|
@@ -5,10 +5,11 @@ declare global {
|
|
|
5
5
|
};
|
|
6
6
|
newspack_blocks_data: {
|
|
7
7
|
assets_path: string;
|
|
8
|
-
is_rendering_stripe_payment_form?: boolean;
|
|
9
8
|
supports_recaptcha: boolean;
|
|
10
9
|
has_recaptcha: boolean;
|
|
11
10
|
recaptcha_url: string;
|
|
11
|
+
can_use_name_your_price: boolean;
|
|
12
|
+
tier_amounts_template: string;
|
|
12
13
|
};
|
|
13
14
|
grecaptcha: any;
|
|
14
15
|
newspackReaderActivation: {
|
|
@@ -44,7 +45,7 @@ declare global {
|
|
|
44
45
|
clientId: string;
|
|
45
46
|
attributes: {
|
|
46
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
-
[
|
|
48
|
+
[key: string]: any;
|
|
48
49
|
};
|
|
49
50
|
innerBlocks: Block[];
|
|
50
51
|
};
|
|
@@ -54,4 +55,4 @@ declare global {
|
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
export {};
|
|
58
|
+
export { };
|
package/vendor/autoload.php
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// autoload_real.php @generated by Composer
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class ComposerAutoloaderInit3018daa20360511dc456dc226a16ecfd
|
|
6
6
|
{
|
|
7
7
|
private static $loader;
|
|
8
8
|
|
|
@@ -22,12 +22,12 @@ class ComposerAutoloaderInit887d5082acd72cb471bf61a6ad16f980
|
|
|
22
22
|
return self::$loader;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
spl_autoload_register(array('
|
|
25
|
+
spl_autoload_register(array('ComposerAutoloaderInit3018daa20360511dc456dc226a16ecfd', 'loadClassLoader'), true, true);
|
|
26
26
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
|
27
|
-
spl_autoload_unregister(array('
|
|
27
|
+
spl_autoload_unregister(array('ComposerAutoloaderInit3018daa20360511dc456dc226a16ecfd', 'loadClassLoader'));
|
|
28
28
|
|
|
29
29
|
require __DIR__ . '/autoload_static.php';
|
|
30
|
-
call_user_func(\Composer\Autoload\
|
|
30
|
+
call_user_func(\Composer\Autoload\ComposerStaticInit3018daa20360511dc456dc226a16ecfd::getInitializer($loader));
|
|
31
31
|
|
|
32
32
|
$loader->register(true);
|
|
33
33
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
namespace Composer\Autoload;
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class ComposerStaticInit3018daa20360511dc456dc226a16ecfd
|
|
8
8
|
{
|
|
9
9
|
public static $classMap = array (
|
|
10
10
|
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
|
@@ -13,7 +13,7 @@ class ComposerStaticInit887d5082acd72cb471bf61a6ad16f980
|
|
|
13
13
|
public static function getInitializer(ClassLoader $loader)
|
|
14
14
|
{
|
|
15
15
|
return \Closure::bind(function () use ($loader) {
|
|
16
|
-
$loader->classMap =
|
|
16
|
+
$loader->classMap = ComposerStaticInit3018daa20360511dc456dc226a16ecfd::$classMap;
|
|
17
17
|
|
|
18
18
|
}, null, ClassLoader::class);
|
|
19
19
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
'name' => 'automattic/newspack-blocks',
|
|
4
4
|
'pretty_version' => 'dev-trunk',
|
|
5
5
|
'version' => 'dev-trunk',
|
|
6
|
-
'reference' => '
|
|
6
|
+
'reference' => 'd6c5d388e88881e4af66a900ed3070994342740d',
|
|
7
7
|
'type' => 'wordpress-plugin',
|
|
8
8
|
'install_path' => __DIR__ . '/../../',
|
|
9
9
|
'aliases' => array(),
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
'automattic/newspack-blocks' => array(
|
|
14
14
|
'pretty_version' => 'dev-trunk',
|
|
15
15
|
'version' => 'dev-trunk',
|
|
16
|
-
'reference' => '
|
|
16
|
+
'reference' => 'd6c5d388e88881e4af66a900ed3070994342740d',
|
|
17
17
|
'type' => 'wordpress-plugin',
|
|
18
18
|
'install_path' => __DIR__ . '/../../',
|
|
19
19
|
'aliases' => array(),
|
package/webpack.config.js
CHANGED
|
@@ -59,7 +59,6 @@ const webpackConfig = getBaseWebpackConfig(
|
|
|
59
59
|
block_styles: blockStylesScript,
|
|
60
60
|
modal: path.join( __dirname, 'src/modal-checkout/modal.js' ),
|
|
61
61
|
modalCheckout: path.join( __dirname, 'src/modal-checkout' ),
|
|
62
|
-
donateStreamlined: path.join( __dirname, 'src/blocks/donate/streamlined' ),
|
|
63
62
|
frequencyBased: path.join( __dirname, 'src/blocks/donate/frequency-based' ),
|
|
64
63
|
tiersBased: path.join( __dirname, 'src/blocks/donate/tiers-based' ),
|
|
65
64
|
...viewBlocksScripts,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<?php return array('dependencies' => array('wp-i18n', 'wp-polyfill'), 'version' => '48123c750d4b2094421f3b12a9ced4e3');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@-webkit-keyframes loader{0%{background-position:0 50%}50%{background-position:100% 50%}to{background-position:0 50%}}@keyframes loader{0%{background-position:0 50%}50%{background-position:100% 50%}to{background-position:0 50%}}.wp-block-newspack-blocks-donate .stripe-payment{position:relative}.wp-block-newspack-blocks-donate .stripe-payment,.wp-block-newspack-blocks-donate .stripe-payment--transition,.wp-block-newspack-blocks-donate .stripe-payment:after{transition:all .3s ease-out}.wp-block-newspack-blocks-donate .stripe-payment:after{content:"";opacity:0;pointer-events:none;position:absolute;top:0;left:0;width:100%;height:100%;background:linear-gradient(318deg,#d5d5d5,#fff);background-size:400% 400%;-webkit-animation:loader 3s ease infinite;animation:loader 3s ease infinite;border-radius:5px}.wp-block-newspack-blocks-donate .stripe-payment__card{padding:.34rem .66rem;min-height:32px}.wp-block-newspack-blocks-donate .stripe-payment__card,.wp-block-newspack-blocks-donate .stripe-payment input[type=email],.wp-block-newspack-blocks-donate .stripe-payment input[type=text]{border:1px solid #ccc;border-radius:3px}.wp-block-newspack-blocks-donate .stripe-payment .submit-button,.wp-block-newspack-blocks-donate .stripe-payment__checkbox,.wp-block-newspack-blocks-donate .stripe-payment button,.wp-block-newspack-blocks-donate .stripe-payment input[type=email],.wp-block-newspack-blocks-donate .stripe-payment input[type=text]{font-size:.7em}.wp-block-newspack-blocks-donate .stripe-payment__messages,.wp-block-newspack-blocks-donate .stripe-payment input[type=email],.wp-block-newspack-blocks-donate .stripe-payment input[type=text]{width:100%}.wp-block-newspack-blocks-donate .stripe-payment input[type=email],.wp-block-newspack-blocks-donate .stripe-payment input[type=text]{border-radius:3px;font-family:sans-serif}@media only screen and (min-width:782px){.wp-block-newspack-blocks-donate .stripe-payment input[type=email],.wp-block-newspack-blocks-donate .stripe-payment input[type=text]{font-size:14px;line-height:1.2}}.wp-block-newspack-blocks-donate .stripe-payment--invisible>*{opacity:0}.wp-block-newspack-blocks-donate .stripe-payment--invisible:after{opacity:1}.wp-block-newspack-blocks-donate .stripe-payment--hidden{display:none}.wp-block-newspack-blocks-donate .stripe-payment__checkbox{align-items:center;display:inline-flex;cursor:pointer}.wp-block-newspack-blocks-donate .stripe-payment__checkbox input{height:1em;width:1em;margin-right:.5em}.wp-block-newspack-blocks-donate .stripe-payment__messages{margin-bottom:10px}.wp-block-newspack-blocks-donate .stripe-payment__messages>div{border:solid #dfdfdf;border-width:0 0 0 4px;font-size:.8em;margin-top:.76rem;padding:.38rem .76rem}.wp-block-newspack-blocks-donate .stripe-payment__messages>div:empty{border:0;margin:0;padding:0}.wp-block-newspack-blocks-donate .stripe-payment__messages>div.type-error{background-color:rgba(204,24,24,.075);border-color:#cc1818}.wp-block-newspack-blocks-donate .stripe-payment__messages>div.type-success{background-color:rgba(74,184,102,.075);border-color:#4ab866;margin:1.12rem}.wp-block-newspack-blocks-donate .stripe-payment--disabled button,.wp-block-newspack-blocks-donate .stripe-payment--disabled input{pointer-events:none;opacity:.4}.wp-block-newspack-blocks-donate .stripe-payment__element{margin-bottom:.4rem}.wp-block-newspack-blocks-donate .stripe-payment__row{margin-bottom:.5rem}.wp-block-newspack-blocks-donate .stripe-payment__row--small{margin-bottom:5px;line-height:1.2}.wp-block-newspack-blocks-donate .stripe-payment__row--flex{display:flex;align-items:flex-end;justify-content:space-between;flex-wrap:wrap}@media only screen and (min-width:782px){.wp-block-newspack-blocks-donate .stripe-payment__row--flex{flex-wrap:nowrap}}.wp-block-newspack-blocks-donate .stripe-payment__row--flex input{margin-bottom:.5rem}@media only screen and (min-width:782px){.wp-block-newspack-blocks-donate .stripe-payment__row--flex input{margin-bottom:0;width:50%}.wp-block-newspack-blocks-donate .stripe-payment__row--flex input+input{margin-left:.5rem}}.wp-block-newspack-blocks-donate .stripe-payment__row--additional-fields{display:flex;flex-wrap:wrap;margin-left:-.25rem;margin-right:-.25rem}.wp-block-newspack-blocks-donate .stripe-payment__row--additional-fields>input{margin-bottom:.5rem;margin-left:.25rem;margin-right:.25rem}.wp-block-newspack-blocks-donate .stripe-payment__info{color:#767676;font-size:.7em;font-style:italic;padding-left:1.5em;display:none}@media only screen and (min-width:600px){.wp-block-newspack-blocks-donate .stripe-payment__info{display:block}}.wp-block-newspack-blocks-donate .stripe-payment__footer{align-items:flex-end;margin-bottom:1.32rem;margin-left:-10px;margin-right:-10px}.wp-block-newspack-blocks-donate .stripe-payment__footer>*{padding-left:10px;padding-right:10px}.wp-block-newspack-blocks-donate .stripe-payment__methods{display:flex;flex-wrap:wrap;width:100%}@media only screen and (min-width:600px){.wp-block-newspack-blocks-donate .stripe-payment__methods{width:auto}}.wp-block-newspack-blocks-donate .stripe-payment__methods .submit-button,.wp-block-newspack-blocks-donate .stripe-payment__methods button{margin-left:0;margin-right:0;margin-bottom:0;height:46px}.wp-block-newspack-blocks-donate .stripe-payment__methods>*{width:100%}.wp-block-newspack-blocks-donate .stripe-payment__methods>:not(:last-child){margin-bottom:10px}@media only screen and (min-width:600px){.wp-block-newspack-blocks-donate .stripe-payment__methods>*{width:auto}}.wp-block-newspack-blocks-donate .stripe-payment__request-button{min-width:190px}@media only screen and (min-width:600px){.wp-block-newspack-blocks-donate .stripe-payment__request-button{margin-right:1em}}.wp-block-newspack-blocks-donate .stripe-payment__request-button--invisible{opacity:0}.wp-block-newspack-blocks-donate__stripe{margin:.38rem .76rem .76rem}@media only screen and (min-width:782px){.wp-block-newspack-blocks-donate__stripe{margin-left:1.5rem;margin-right:1.5rem}}.wp-block-newspack-blocks-donate__stripe--editor input:first-child{margin-top:0}#stripe-fees-amount{padding-left:3px}.wpbnbd.is-style-alternate .wp-block-newspack-blocks-donate__stripe{margin:1.12rem 1.12rem 0}.wpbnbd.is-style-alternate .stripe-payment__row{margin-bottom:.56rem}.wpbnbd.is-style-alternate .stripe-payment__footer{margin:0 0 1.12rem}.wpbnbd.is-style-alternate .stripe-payment__footer>*{padding:0}.wpbnbd.is-style-alternate .stripe-payment__footer .submit-button,.wpbnbd.is-style-alternate .stripe-payment__footer button{border-top-left-radius:5px;border-top-right-radius:5px;margin:0;width:auto}.wpbnbd.is-style-minimal .wp-block-newspack-blocks-donate__stripe{margin:0;text-align:left}.wpbnbd.is-style-minimal .stripe-payment__row{margin-bottom:.56rem}.wpbnbd.is-style-minimal .stripe-payment__inputs{margin-bottom:1.12rem}.wpbnbd.is-style-minimal .stripe-payment__footer{margin:0 0 1.12rem}.wpbnbd.is-style-minimal .stripe-payment__footer>*{padding:0}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{var e={7597:(e,t)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}var n,o="https://js.stripe.com/v3",a=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,i="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",u=null,c=function(e){return null!==u||(u=new Promise((function(t,r){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(i),window.Stripe)t(window.Stripe);else try{var n=function(){for(var e=document.querySelectorAll('script[src^="'.concat(o,'"]')),t=0;t<e.length;t++){var r=e[t];if(a.test(r.src))return r}return null}();n&&e?console.warn(i):n||(n=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",r=document.createElement("script");r.src="".concat(o).concat(t);var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return n.appendChild(r),r}(e)),n.addEventListener("load",(function(){window.Stripe?t(window.Stripe):r(new Error("Stripe.js not available"))})),n.addEventListener("error",(function(){r(new Error("Failed to load Stripe.js"))}))}catch(u){return void r(u)}else t(null)}))),u},s=function(e,t,r){if(null===e)return null;var n=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"2.2.0",startTime:t})}(n,r),n},l=function(e){var t="invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(e),"\n");if(null===e||"object"!==r(e))throw new Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw new Error(t)},f=!1,p=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];f=!0;var o=Date.now();return c(n).then((function(e){return s(e,t,o)}))};p.setLoadParameters=function(e){if(f&&n){var t=l(e);if(Object.keys(t).reduce((function(t,r){var o;return t&&e[r]===(null===(o=n)||void 0===o?void 0:o[r])}),!0))return}if(f)throw new Error("You cannot change load parameters after calling loadStripe");n=l(e)},t.loadStripe=p},7894:(e,t,r)=>{e.exports=r(7597)},5666:e=>{var t=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(R){s=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof h?t:h,i=Object.create(a.prototype),u=new P(n||[]);return o(i,"_invoke",{value:E(e,r,u)}),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(R){return{type:"throw",arg:R}}}e.wrap=l;var p="suspendedStart",d="executing",m="completed",y={};function h(){}function v(){}function b(){}var w={};s(w,i,(function(){return this}));var g=Object.getPrototypeOf,x=g&&g(g(q([])));x&&x!==r&&n.call(x,i)&&(w=x);var _=b.prototype=h.prototype=Object.create(w);function k(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(o,a,i,u){var c=f(e[o],e,a);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function E(e,r,n){var o=p;return function(a,i){if(o===d)throw new Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var u=n.delegate;if(u){var c=j(u,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=f(e,r,n);if("normal"===s.type){if(o=n.done?m:"suspendedYield",s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function j(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,j(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=f(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function q(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(typeof e+" is not iterable")}return v.prototype=b,o(_,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:v,configurable:!0}),v.displayName=s(b,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,c,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},k(S.prototype),s(S.prototype,u,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new S(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},k(_),s(_,c,"Generator"),s(_,i,(function(){return this})),s(_,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=q,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),L(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:q(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}(e.exports);try{regeneratorRuntime=t}catch(r){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function a(e,t,r,n,o,a,i){try{var u=e[a](i),c=u.value}catch(s){return void r(s)}u.done?t(c):Promise.resolve(c).then(n,o)}function i(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function u(e){a(i,n,o,u,c,"next",e)}function c(e){a(i,n,o,u,c,"throw",e)}u(void 0)}))}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function c(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}function s(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}r.r(n),r.d(n,{processStreamlinedElements:()=>S});const l=window.wp.i18n;var f=r(7894);r(5666);function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],_n=!0,i=!1;try{for(r=r.call(e);!(_n=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);_n=!0);}catch(u){i=!0,o=u}finally{try{_n||null==r.return||r.return()}finally{if(i)throw o}}return a}}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var __=l.__,d=function(e,t){var r,n={};r=e.email,/\S+@\S+/.test(r)||(n.email=__("Email address is invalid.","newspack-blocks"));var o=t.minimumDonation;return o&&parseFloat(e.amount)<o&&(n.amount=(0,l.sprintf)(__("Amount must be at least %d.","newspack-blocks"),o)),0===e.full_name.length&&(n.amount=__("Full name should be provided.","newspack-blocks")),n},m=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"error";t.innerHTML="",e.forEach((function(e){if(e){var n=document.createElement("div");n.classList.add("type-".concat(r)),n.innerHTML=e,t.appendChild(n)}})),"success"===r&&t.parentElement&&t.parentElement.replaceWith(t)},y=function(e){var t=e.closest("[data-streamlined-config]"),r=null==t?void 0:t.getAttribute("data-streamlined-config");if(!r)return{};var n=p(JSON.parse(r),12),o=n[0],a=n[1],i=n[2],u=n[3],c=n[4],s=n[5],l=n[6],f=n[7],d=n[8],m=n[9],y=n[10],h=n[11];return{currency:o.toLowerCase(),currencySymbol:a,siteName:i,isCurrencyZeroDecimal:u,countryCode:c,frequencies:s,feeMultiplier:parseFloat(l),feeStatic:parseFloat(f),stripePublishableKey:d,paymentRequestType:m,captchaSiteKey:y,minimumDonation:parseFloat(h)}},h=function(e){var t=Object.fromEntries(new FormData(e)),r="donation_value_".concat(t.donation_frequency);return t.amount=t[r],"other"===t.amount&&(t.amount=t["".concat(r,"_other")]),t.amount||(t.amount=t["".concat(r,"_untiered")]),t.cid&&"string"==typeof t.cid&&0===t.cid.indexOf("CLIENT_ID")&&(t.cid=document.cookie.split("; ").reduce((function(e,t){var r=t.split("=");return e[r[0]]=r[1],e}),{})["newspack-cid"]),t},v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{convertToSubunit:!1},r=t.convertToSubunit,n=y(e),o=h(e),a=o.amount,i=void 0===a?"0":a,u=o.agree_to_pay_fees,c=function(e){return r?e*(n.isCurrencyZeroDecimal?1:100):e},s=0;return u&&(s=c(w(e)||0)),c(parseFloat(i))+s},b=function(e){var t=y(e),r=h(e).donation_frequency,n=t.frequencies[r];return{label:"".concat(t.siteName," (").concat(n,")"),amount:v(e,{convertToSubunit:!0})}},w=function(e){var t=y(e),r=t.feeMultiplier,n=t.feeStatic;if(void 0===r||void 0===n||isNaN(r)||isNaN(n))return 0;var o=h(e).amount;return function(e,t,r){return parseFloat(((e+r)/(100-t)*100-e).toFixed(2))}(parseFloat(o),r,n)},g=function(){var e=i(regeneratorRuntime.mark((function e(t,r){var n,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=o.length>2&&void 0!==o[2]?o[2]:"POST",e.abrupt("return",fetch("/wp-json/newspack-blocks/v1".concat(t),{method:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then(function(){var e=i(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:if(r=e.sent,!t.ok){e.next=5;break}return e.abrupt("return",r);case 5:return e.abrupt("return",{error:r});case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:case"end":return e.stop()}}),e)})));return function(_x,t){return e.apply(this,arguments)}}(),x=function(e,t){var r=(0,l.sprintf)(__("Your payment has been processed. Thank you for your contribution! You will receive a confirmation email at %s.","newspack-blocks"),e);m([r],t,"success")},_=l.__,k=function(e){return s(e.querySelectorAll("input[data-is-additional-field]")).map((function(e){return{name:e.name,value:e.value}}))},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document;return s(e.querySelectorAll(".stripe-payment")).forEach(function(){var e=i(regeneratorRuntime.mark((function e(t){var r,n,a,u,c,s,l,p,S,E,j,O,L,P,q,R,T,F;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=!1,s=t.closest("form"),l=t.querySelector(".stripe-payment__messages"),s&&l){e.next=5;break}return e.abrupt("return");case 5:p=t.closest(".wpbnbd"),S="newspackPaymentFlowComplete-".concat((null==p?void 0:p.id)||""),E=y(s),j=function(){return t.classList.add("stripe-payment--disabled")},(O=function(){return t.classList.remove("stripe-payment--disabled")})(),L=function(){if(!c){var e=t.querySelector(".stripe-payment__inputs.stripe-payment--hidden");e&&(e.classList.remove("stripe-payment--hidden"),c=!0)}},P=function(){var e=i(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){var n=window.grecaptcha;if(!n)return e("");null!=n&&n.ready&&t||r(_("Error loading the reCaptcha library.","newspack-blocks")),n.ready(i(regeneratorRuntime.mark((function o(){var a;return regeneratorRuntime.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,o.next=3,n.execute(t,{action:"submit"});case 3:return a=o.sent,o.abrupt("return",e(a));case 7:o.prev=7,o.t0=o.catch(0),r(o.t0);case 10:case"end":return o.stop()}}),o,null,[[0,7]])}))))})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),q=function(){var e=i(regeneratorRuntime.mark((function e(t){var n,a,i,u,c,f,p,d,y,b,w,j,L,q,R,T=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=T.length>1&&void 0!==T[1]?T[1]:void 0,u=T.length>2&&void 0!==T[2]?T[2]:{},r){e.next=4;break}return e.abrupt("return");case 4:if(!(c=null==E?void 0:E.captchaSiteKey)){e.next=17;break}return e.prev=6,e.next=9,P(c);case 9:f=e.sent,e.next=17;break;case 12:return e.prev=12,e.t0=e.catch(6),p=e.t0 instanceof Error?e.t0.message:_("Error processing captcha request.","newspack-blocks"),m([p],l),e.abrupt("return",{error:!0});case 17:return d=h(s),y=k(s),b=o({captchaToken:f,stripe_tokenization_method:i?null===(n=i.card)||void 0===n?void 0:n.tokenization_method:"card",stripe_source_id:t.id,amount:v(s),email:d.email,full_name:d.full_name,frequency:d.donation_frequency,newsletter_opt_in:Boolean(d.newsletter_opt_in),newspack_popup_id:d.newspack_popup_id,_wp_http_referer:d._wp_http_referer,clientId:d.cid,additional_fields:y},u),e.next=22,g("/donate",b);case 22:if(w=e.sent,200===(null===(a=w.data)||void 0===a?void 0:a.status)||!w.message){e.next=26;break}return m([w.message],l),e.abrupt("return",{error:!0});case 26:if(!w.error){e.next=29;break}return m([w.error],l),e.abrupt("return",{error:!0});case 29:if(j=function(e){return m([e],l),O(),window.dispatchEvent(new Event(S)),{error:!0}},!w.client_secret){e.next=53;break}return e.next=33,r.confirmCardPayment(w.client_secret);case 33:if(!(L=e.sent).error){e.next=38;break}return e.abrupt("return",j(L.error.message));case 38:if("succeeded"!==L.paymentIntent.status){e.next=42;break}x(b.email,l),e.next=53;break;case 42:if("requires_action"!==L.paymentIntent.status){e.next=52;break}return e.next=45,r.confirmCardPayment(w.client_secret);case 45:if(q=e.sent,!(R=q.error)){e.next=49;break}return e.abrupt("return",j(R.message));case 49:x(b.email,l),e.next=53;break;case 52:return e.abrupt("return",j(_("Something went wrong with the payment. Please try again later.","newspack-blocks")));case 53:return"success"===w.status&&x(b.email,l),window.dispatchEvent(new Event(S)),e.abrupt("return",{});case 56:case"end":return e.stop()}}),e,null,[[6,12]])})));return function(t){return e.apply(this,arguments)}}(),R=function(){var e=i(regeneratorRuntime.mark((function e(){var o,c,l,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,f.loadStripe)(E.stripePublishableKey);case 2:if(r=e.sent){e.next=5;break}return e.abrupt("return");case 5:if(o=t.querySelector(".stripe-payment__card")){e.next=8;break}return e.abrupt("return");case 8:return c=r.elements(),(n=c.create("card")).mount(o),a=r.paymentRequest({country:E.countryCode,currency:E.currency,total:b(s),requestPayerName:!0,requestPayerEmail:!0}),e.next=14,a.canMakePayment();case 14:if(!e.sent){e.next=28;break}if(a.on("source",function(){var e=i(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,q(t.source,u,{email:t.payerEmail,full_name:t.payerName});case 2:r=e.sent,t.complete(null!=r&&r.error?"fail":"success");case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),a.on("token",function(){var e=i(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u=t.token;case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),s.addEventListener("change",(function(){a.update({total:b(s)})})),l=c.create("paymentRequestButton",{paymentRequest:a,style:{paymentRequestButton:{type:E.paymentRequestType,height:"46px"}}}),p=t.querySelector(".stripe-payment__request-button")){e.next=23;break}return e.abrupt("return");case 23:l.mount(p),p.classList.remove("stripe-payment--hidden"),setTimeout((function(){p.classList.remove("stripe-payment__request-button--invisible")}),0),e.next=29;break;case 28:L();case 29:t.classList.remove("stripe-payment--invisible");case 30:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),new IntersectionObserver((function(e){e[0].isIntersecting&&R()})).observe(t),(T=t.querySelector('button[type="submit"]'))&&(T.onclick=function(e){c||(e.preventDefault(),L())}),(F=function(){var e=t.querySelector("#stripe-fees-amount");if(e){var r=Object.fromEntries(new FormData(s)),n=w(s);if(0===n){var o=t.querySelector("#stripe-fees-amount-container");o&&(o.style.display="none")}"string"==typeof r.donation_frequency&&(e.innerHTML="(".concat(E.currencySymbol).concat(n.toFixed(2)," ").concat(E.frequencies[r.donation_frequency].toLowerCase(),")"))}})(),s.addEventListener("change",F),s.addEventListener("submit",function(){var e=i(regeneratorRuntime.mark((function e(t){var o,a,i,u,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r){e.next=2;break}return e.abrupt("return");case 2:if(t.preventDefault(),j(),m([_("Processing payment…","newspack-blocks")],l,"info"),a=h(s),!((i=Object.values(d(a,E))).length>0)){e.next=11;break}return m(i,l),O(),e.abrupt("return");case 11:return u=function(e){e.message&&i.push(e.message),m(i,l),O()},e.next=14,r.createSource(n,{type:"card",owner:{name:a.full_name,email:a.email}});case 14:if(!(c=e.sent).error){e.next=18;break}return u(c.error),e.abrupt("return");case 18:return e.next=20,q(c.source);case 20:null!==(o=window.newspackReaderActivation)&&void 0!==o&&o.refreshAuthentication&&window.newspackReaderActivation.refreshAuthentication();case 21:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());case 23:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}())};S()})();var o=window;for(var a in n)o[a]=n[a];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@-webkit-keyframes loader{0%{background-position:100% 50%}50%{background-position:0 50%}to{background-position:100% 50%}}@keyframes loader{0%{background-position:100% 50%}50%{background-position:0 50%}to{background-position:100% 50%}}.wp-block-newspack-blocks-donate .stripe-payment{position:relative}.wp-block-newspack-blocks-donate .stripe-payment,.wp-block-newspack-blocks-donate .stripe-payment--transition,.wp-block-newspack-blocks-donate .stripe-payment:after{transition:all .3s ease-out}.wp-block-newspack-blocks-donate .stripe-payment:after{content:"";opacity:0;pointer-events:none;position:absolute;top:0;right:0;width:100%;height:100%;background:linear-gradient(-318deg,#d5d5d5,#fff);background-size:400% 400%;-webkit-animation:loader 3s ease infinite;animation:loader 3s ease infinite;border-radius:5px}.wp-block-newspack-blocks-donate .stripe-payment__card{padding:.34rem .66rem;min-height:32px}.wp-block-newspack-blocks-donate .stripe-payment__card,.wp-block-newspack-blocks-donate .stripe-payment input[type=email],.wp-block-newspack-blocks-donate .stripe-payment input[type=text]{border:1px solid #ccc;border-radius:3px}.wp-block-newspack-blocks-donate .stripe-payment .submit-button,.wp-block-newspack-blocks-donate .stripe-payment__checkbox,.wp-block-newspack-blocks-donate .stripe-payment button,.wp-block-newspack-blocks-donate .stripe-payment input[type=email],.wp-block-newspack-blocks-donate .stripe-payment input[type=text]{font-size:.7em}.wp-block-newspack-blocks-donate .stripe-payment__messages,.wp-block-newspack-blocks-donate .stripe-payment input[type=email],.wp-block-newspack-blocks-donate .stripe-payment input[type=text]{width:100%}.wp-block-newspack-blocks-donate .stripe-payment input[type=email],.wp-block-newspack-blocks-donate .stripe-payment input[type=text]{border-radius:3px;font-family:sans-serif}@media only screen and (min-width:782px){.wp-block-newspack-blocks-donate .stripe-payment input[type=email],.wp-block-newspack-blocks-donate .stripe-payment input[type=text]{font-size:14px;line-height:1.2}}.wp-block-newspack-blocks-donate .stripe-payment--invisible>*{opacity:0}.wp-block-newspack-blocks-donate .stripe-payment--invisible:after{opacity:1}.wp-block-newspack-blocks-donate .stripe-payment--hidden{display:none}.wp-block-newspack-blocks-donate .stripe-payment__checkbox{align-items:center;display:inline-flex;cursor:pointer}.wp-block-newspack-blocks-donate .stripe-payment__checkbox input{height:1em;width:1em;margin-left:.5em}.wp-block-newspack-blocks-donate .stripe-payment__messages{margin-bottom:10px}.wp-block-newspack-blocks-donate .stripe-payment__messages>div{border:solid #dfdfdf;border-width:0 4px 0 0;font-size:.8em;margin-top:.76rem;padding:.38rem .76rem}.wp-block-newspack-blocks-donate .stripe-payment__messages>div:empty{border:0;margin:0;padding:0}.wp-block-newspack-blocks-donate .stripe-payment__messages>div.type-error{background-color:rgba(204,24,24,.075);border-color:#cc1818}.wp-block-newspack-blocks-donate .stripe-payment__messages>div.type-success{background-color:rgba(74,184,102,.075);border-color:#4ab866;margin:1.12rem}.wp-block-newspack-blocks-donate .stripe-payment--disabled button,.wp-block-newspack-blocks-donate .stripe-payment--disabled input{pointer-events:none;opacity:.4}.wp-block-newspack-blocks-donate .stripe-payment__element{margin-bottom:.4rem}.wp-block-newspack-blocks-donate .stripe-payment__row{margin-bottom:.5rem}.wp-block-newspack-blocks-donate .stripe-payment__row--small{margin-bottom:5px;line-height:1.2}.wp-block-newspack-blocks-donate .stripe-payment__row--flex{display:flex;align-items:flex-end;justify-content:space-between;flex-wrap:wrap}@media only screen and (min-width:782px){.wp-block-newspack-blocks-donate .stripe-payment__row--flex{flex-wrap:nowrap}}.wp-block-newspack-blocks-donate .stripe-payment__row--flex input{margin-bottom:.5rem}@media only screen and (min-width:782px){.wp-block-newspack-blocks-donate .stripe-payment__row--flex input{margin-bottom:0;width:50%}.wp-block-newspack-blocks-donate .stripe-payment__row--flex input+input{margin-right:.5rem}}.wp-block-newspack-blocks-donate .stripe-payment__row--additional-fields{display:flex;flex-wrap:wrap;margin-right:-.25rem;margin-left:-.25rem}.wp-block-newspack-blocks-donate .stripe-payment__row--additional-fields>input{margin-bottom:.5rem;margin-right:.25rem;margin-left:.25rem}.wp-block-newspack-blocks-donate .stripe-payment__info{color:#767676;font-size:.7em;font-style:italic;padding-right:1.5em;display:none}@media only screen and (min-width:600px){.wp-block-newspack-blocks-donate .stripe-payment__info{display:block}}.wp-block-newspack-blocks-donate .stripe-payment__footer{align-items:flex-end;margin-bottom:1.32rem;margin-right:-10px;margin-left:-10px}.wp-block-newspack-blocks-donate .stripe-payment__footer>*{padding-right:10px;padding-left:10px}.wp-block-newspack-blocks-donate .stripe-payment__methods{display:flex;flex-wrap:wrap;width:100%}@media only screen and (min-width:600px){.wp-block-newspack-blocks-donate .stripe-payment__methods{width:auto}}.wp-block-newspack-blocks-donate .stripe-payment__methods .submit-button,.wp-block-newspack-blocks-donate .stripe-payment__methods button{margin-right:0;margin-left:0;margin-bottom:0;height:46px}.wp-block-newspack-blocks-donate .stripe-payment__methods>*{width:100%}.wp-block-newspack-blocks-donate .stripe-payment__methods>:not(:last-child){margin-bottom:10px}@media only screen and (min-width:600px){.wp-block-newspack-blocks-donate .stripe-payment__methods>*{width:auto}}.wp-block-newspack-blocks-donate .stripe-payment__request-button{min-width:190px}@media only screen and (min-width:600px){.wp-block-newspack-blocks-donate .stripe-payment__request-button{margin-left:1em}}.wp-block-newspack-blocks-donate .stripe-payment__request-button--invisible{opacity:0}.wp-block-newspack-blocks-donate__stripe{margin:.38rem .76rem .76rem}@media only screen and (min-width:782px){.wp-block-newspack-blocks-donate__stripe{margin-right:1.5rem;margin-left:1.5rem}}.wp-block-newspack-blocks-donate__stripe--editor input:first-child{margin-top:0}#stripe-fees-amount{padding-right:3px}.wpbnbd.is-style-alternate .wp-block-newspack-blocks-donate__stripe{margin:1.12rem 1.12rem 0}.wpbnbd.is-style-alternate .stripe-payment__row{margin-bottom:.56rem}.wpbnbd.is-style-alternate .stripe-payment__footer{margin:0 0 1.12rem}.wpbnbd.is-style-alternate .stripe-payment__footer>*{padding:0}.wpbnbd.is-style-alternate .stripe-payment__footer .submit-button,.wpbnbd.is-style-alternate .stripe-payment__footer button{border-top-right-radius:5px;border-top-left-radius:5px;margin:0;width:auto}.wpbnbd.is-style-minimal .wp-block-newspack-blocks-donate__stripe{margin:0;text-align:right}.wpbnbd.is-style-minimal .stripe-payment__row{margin-bottom:.56rem}.wpbnbd.is-style-minimal .stripe-payment__inputs{margin-bottom:1.12rem}.wpbnbd.is-style-minimal .stripe-payment__footer{margin:0 0 1.12rem}.wpbnbd.is-style-minimal .stripe-payment__footer>*{padding:0}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
<?php // phpcs:disable Squiz.Commenting.FileComment.Missing
|
|
2
|
-
/**
|
|
3
|
-
* WP_REST_Newspack_Donate_Controller file.
|
|
4
|
-
*
|
|
5
|
-
* @package WordPress
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Class WP_REST_Newspack_Donate_Controller.
|
|
12
|
-
*/
|
|
13
|
-
class WP_REST_Newspack_Donate_Controller extends WP_REST_Controller {
|
|
14
|
-
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
|
|
15
|
-
|
|
16
|
-
private static $current_user_id = 0; // phpcs:ignore Squiz.Commenting.VariableComment.Missing
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Constructs the controller.
|
|
20
|
-
*
|
|
21
|
-
* @access public
|
|
22
|
-
*/
|
|
23
|
-
public function __construct() {
|
|
24
|
-
$this->namespace = 'newspack-blocks/v1';
|
|
25
|
-
$this->rest_base = 'donate';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Registers the necessary REST API routes.
|
|
30
|
-
*
|
|
31
|
-
* @access public
|
|
32
|
-
*/
|
|
33
|
-
public function register_routes() {
|
|
34
|
-
self::$current_user_id = \get_current_user_id();
|
|
35
|
-
|
|
36
|
-
\register_rest_route(
|
|
37
|
-
$this->namespace,
|
|
38
|
-
'/' . $this->rest_base,
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
'methods' => \WP_REST_Server::EDITABLE,
|
|
42
|
-
'callback' => [ $this, 'api_process_donation' ],
|
|
43
|
-
'args' => [
|
|
44
|
-
'captchaToken' => [
|
|
45
|
-
'sanitize_callback' => 'sanitize_text_field',
|
|
46
|
-
'required' => false,
|
|
47
|
-
],
|
|
48
|
-
'stripe_tokenization_method' => [
|
|
49
|
-
'sanitize_callback' => 'sanitize_text_field',
|
|
50
|
-
],
|
|
51
|
-
'stripe_source_id' => [
|
|
52
|
-
'sanitize_callback' => 'sanitize_text_field',
|
|
53
|
-
'required' => true,
|
|
54
|
-
],
|
|
55
|
-
'amount' => [
|
|
56
|
-
'sanitize_callback' => function ( $amount ) {
|
|
57
|
-
return (float) abs( $amount );
|
|
58
|
-
},
|
|
59
|
-
'required' => true,
|
|
60
|
-
],
|
|
61
|
-
'frequency' => [
|
|
62
|
-
'sanitize_callback' => 'sanitize_text_field',
|
|
63
|
-
'required' => true,
|
|
64
|
-
],
|
|
65
|
-
'email' => [
|
|
66
|
-
'sanitize_callback' => 'sanitize_text_field',
|
|
67
|
-
'required' => true,
|
|
68
|
-
],
|
|
69
|
-
'full_name' => [
|
|
70
|
-
'sanitize_callback' => 'sanitize_text_field',
|
|
71
|
-
'required' => true,
|
|
72
|
-
],
|
|
73
|
-
'clientId' => [
|
|
74
|
-
'sanitize_callback' => 'sanitize_text_field',
|
|
75
|
-
],
|
|
76
|
-
'newsletter_opt_in' => [
|
|
77
|
-
'sanitize_callback' => 'rest_sanitize_boolean',
|
|
78
|
-
],
|
|
79
|
-
'agree_to_pay_fees' => [
|
|
80
|
-
'sanitize_callback' => 'rest_sanitize_boolean',
|
|
81
|
-
],
|
|
82
|
-
'origin' => [
|
|
83
|
-
'sanitize_callback' => 'sanitize_text_field',
|
|
84
|
-
],
|
|
85
|
-
'additional_fields' => [
|
|
86
|
-
'type' => 'array',
|
|
87
|
-
'items' => [
|
|
88
|
-
'type' => 'object',
|
|
89
|
-
'properties' => [
|
|
90
|
-
'name' => [
|
|
91
|
-
'type' => 'string',
|
|
92
|
-
'sanitize_callback' => 'sanitize_text_field',
|
|
93
|
-
],
|
|
94
|
-
'value' => [
|
|
95
|
-
'type' => 'string',
|
|
96
|
-
'sanitize_callback' => 'sanitize_text_field',
|
|
97
|
-
],
|
|
98
|
-
],
|
|
99
|
-
],
|
|
100
|
-
],
|
|
101
|
-
],
|
|
102
|
-
'permission_callback' => '__return_true',
|
|
103
|
-
],
|
|
104
|
-
]
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Handle a donation.
|
|
110
|
-
*
|
|
111
|
-
* @param WP_REST_Request $request Request object.
|
|
112
|
-
* @return WP_REST_Response
|
|
113
|
-
*/
|
|
114
|
-
public function api_process_donation( $request ) {
|
|
115
|
-
if ( method_exists( '\Newspack\Recaptcha', 'can_use_captcha' ) && \Newspack\Recaptcha::can_use_captcha() ) {
|
|
116
|
-
$captcha_token = $request->get_param( 'captchaToken' );
|
|
117
|
-
$captcha_result = \Newspack\Recaptcha::verify_captcha( $captcha_token );
|
|
118
|
-
if ( \is_wp_error( $captcha_result ) ) {
|
|
119
|
-
return \rest_ensure_response(
|
|
120
|
-
[
|
|
121
|
-
'error' => \esc_html( $captcha_result->get_error_message() ),
|
|
122
|
-
]
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
$referer = $request->get_param( '_wp_http_referer' );
|
|
128
|
-
if ( ! $referer ) {
|
|
129
|
-
$referer = \wp_get_referer();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
$payment_metadata = [
|
|
133
|
-
'referer' => $referer,
|
|
134
|
-
];
|
|
135
|
-
|
|
136
|
-
if ( class_exists( 'Newspack\NRH' ) && method_exists( 'Newspack\NRH', 'get_nrh_config' ) ) {
|
|
137
|
-
$nrh_config = \Newspack\NRH::get_nrh_config();
|
|
138
|
-
if ( isset( $nrh_config['nrh_salesforce_campaign_id'] ) ) {
|
|
139
|
-
$payment_metadata['sf_campaign_id'] = $nrh_config['nrh_salesforce_campaign_id'];
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if ( ! empty( $request->get_param( 'newspack_popup_id' ) ) ) {
|
|
144
|
-
$payment_metadata['newspack_popup_id'] = $request->get_param( 'newspack_popup_id' );
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
$frequency = $request->get_param( 'frequency' );
|
|
148
|
-
$full_name = $request->get_param( 'full_name' );
|
|
149
|
-
$origin = $request->get_param( 'origin' );
|
|
150
|
-
|
|
151
|
-
$user_id = self::$current_user_id;
|
|
152
|
-
|
|
153
|
-
$client_metadata = [
|
|
154
|
-
'clientId' => $request->get_param( 'clientId' ),
|
|
155
|
-
'newsletterOptIn' => $request->get_param( 'newsletter_opt_in' ),
|
|
156
|
-
'current_page_url' => \wp_get_referer(),
|
|
157
|
-
'origin' => $origin,
|
|
158
|
-
];
|
|
159
|
-
|
|
160
|
-
if ( 0 === $user_id ) {
|
|
161
|
-
$email_address = $request->get_param( 'email' );
|
|
162
|
-
|
|
163
|
-
if ( class_exists( 'Newspack\WooCommerce_Connection' ) && method_exists( 'Newspack\WooCommerce_Connection', 'set_up_membership' ) ) {
|
|
164
|
-
// Handle woocommerce-memberships integration, if there's no user logged in.
|
|
165
|
-
$user_id = \Newspack\WooCommerce_Connection::set_up_membership(
|
|
166
|
-
$email_address,
|
|
167
|
-
$full_name,
|
|
168
|
-
$frequency,
|
|
169
|
-
$client_metadata
|
|
170
|
-
);
|
|
171
|
-
if ( \is_wp_error( $user_id ) ) {
|
|
172
|
-
return [ 'error' => \esc_html( $user_id->get_error_message() ) ];
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
} else {
|
|
176
|
-
$email_address = \get_userdata( $user_id )->user_email;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
$client_metadata['userId'] = $user_id;
|
|
180
|
-
$additional_fields = $request->get_param( 'additional_fields' );
|
|
181
|
-
if ( ! empty( $additional_fields ) ) {
|
|
182
|
-
$additional_fields_object = [];
|
|
183
|
-
foreach ( $additional_fields as $field ) {
|
|
184
|
-
$additional_fields_object[ $field['name'] ] = $field['value'];
|
|
185
|
-
$client_metadata[ $field['name'] ] = $field['value'];
|
|
186
|
-
}
|
|
187
|
-
// Save all as a single field, so these fields can be retrieved by other integrations.
|
|
188
|
-
$client_metadata['_additional_fields'] = wp_json_encode( $additional_fields_object );
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
$response = \Newspack\Stripe_Connection::handle_donation(
|
|
192
|
-
[
|
|
193
|
-
'frequency' => $frequency,
|
|
194
|
-
'tokenization_method' => $request->get_param( 'stripe_tokenization_method' ),
|
|
195
|
-
'source_id' => $request->get_param( 'stripe_source_id' ),
|
|
196
|
-
'email_address' => $email_address,
|
|
197
|
-
'full_name' => $full_name,
|
|
198
|
-
'amount' => $request->get_param( 'amount' ),
|
|
199
|
-
'client_metadata' => $client_metadata,
|
|
200
|
-
'payment_metadata' => $payment_metadata,
|
|
201
|
-
]
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
return \rest_ensure_response( $response );
|
|
205
|
-
}
|
|
206
|
-
}
|