workarea-paypal 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/Gemfile +1 -1
- data/app/assets/javascripts/workarea/storefront/paypal/modules/paypal.js +63 -0
- data/app/assets/javascripts/workarea/storefront/paypal/modules/paypal_buttons.js +6 -5
- data/app/assets/javascripts/workarea/storefront/paypal/modules/paypal_hosted_fields.js +6 -5
- data/app/helpers/workarea/storefront/paypal_helper.rb +1 -0
- data/config/initializers/append_points.rb +1 -0
- data/lib/workarea/paypal/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92bdac05441fd966fa90acc4cb18badd013d583b0cc69b98a36a79144e5e5fac
|
4
|
+
data.tar.gz: 519be45e1b7a3e27167df514ae49fe1ac32eaf5250156c9ed88b6c15e7c1bf7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6d388830f585b699138e407415190f6d8d21489d22666010d2a1a3e3c2499320c0b26b9b3c1cfb7082e0e23ea53cd11d49eba8662852e34deaefb1b7624d731
|
7
|
+
data.tar.gz: ff569d2f2291693dfbb839c84b678ccb662b8f69286c3194233550ccc7731e2b13f854d42184e635ec1a2303e5c31352f307a2a518ed5b78f706666afa099840
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
Workarea Paypal 3.0.5 (2020-08-14)
|
2
|
+
--------------------------------------------------------------------------------
|
3
|
+
|
4
|
+
* Address Race Condition When Using PayPal's SDK
|
5
|
+
|
6
|
+
It's possible that our modules that use the PayPal SDK will be
|
7
|
+
initialized prior to `window.paypal` being available on the page, now
|
8
|
+
that the JS is loaded in asynchronously, causing unnecessary loss in
|
9
|
+
functionality. Additionally, there doesn't seem to be a way to bind to
|
10
|
+
any kind of event given off by the SDK on `window` that would allow us
|
11
|
+
to know whether the SDK is truly loaded or not. To address this, when
|
12
|
+
the `window.paypal` object is not available yet, and there's a
|
13
|
+
`<script>` tag on the page loading the PayPal SDK (indicating that we
|
14
|
+
are indeed expecting the SDK to be there), the PayPal modules will
|
15
|
+
re-try initializing every 5 seconds until `window.paypal` is available.
|
16
|
+
|
17
|
+
PAYPAL-7
|
18
|
+
|
19
|
+
Tom Scott
|
20
|
+
|
21
|
+
* Load JavaScript From PayPal Asynchronously
|
22
|
+
|
23
|
+
Using the `async` attribute in the `<script>` tag that loads PayPal's
|
24
|
+
JavaScript code, Workarea can now prevent it blocking the page in case
|
25
|
+
of a failure, and improve load time performance to boot.
|
26
|
+
|
27
|
+
PAYPAL-7
|
28
|
+
|
29
|
+
Fixes #10
|
30
|
+
|
31
|
+
Tom Scott
|
32
|
+
|
33
|
+
|
34
|
+
|
1
35
|
Workarea Paypal 3.0.4 (2020-06-17)
|
2
36
|
--------------------------------------------------------------------------------
|
3
37
|
|
data/Gemfile
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Reliably ensure that the PayPal SDK is either loaded or will
|
4
|
+
* be loading.
|
5
|
+
*
|
6
|
+
* @namespace WORKAREA.paypal
|
7
|
+
*/
|
8
|
+
WORKAREA.registerModule('paypal', (function () {
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
var handlers = [],
|
12
|
+
attempts = 0,
|
13
|
+
paypalLoaded = null,
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Define a function that will be called when the paypal SDK has
|
17
|
+
* loaded.
|
18
|
+
*
|
19
|
+
* @method
|
20
|
+
* @name ready
|
21
|
+
* @param function handler - A function to be called when PayPal
|
22
|
+
* is available.
|
23
|
+
* @memberof WORKAREA.paypal
|
24
|
+
*/
|
25
|
+
ready = function(handler) {
|
26
|
+
if (paypalLoaded) {
|
27
|
+
handler();
|
28
|
+
} else {
|
29
|
+
handlers.push(handler);
|
30
|
+
}
|
31
|
+
},
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Continuously check for whether the Paypal SDK has loaded
|
35
|
+
* every 5 seconds, and call function handlers defined in
|
36
|
+
* `ready()` when the `window.paypal` object is available. This
|
37
|
+
* will only occur if the `<script>` tag containing the PayPal
|
38
|
+
* SDK is detected to be on the page.
|
39
|
+
*
|
40
|
+
* @method
|
41
|
+
* @name init
|
42
|
+
* @memberof WORKAREA.paypal
|
43
|
+
*/
|
44
|
+
init = function() {
|
45
|
+
var $sdk = $('script[data-partner-attribution-id]'),
|
46
|
+
paypalExpectedToLoad = !_.isEmpty($sdk);
|
47
|
+
|
48
|
+
attempts += 1;
|
49
|
+
paypalLoaded = window.paypal !== undefined;
|
50
|
+
|
51
|
+
if (!paypalLoaded && paypalExpectedToLoad && attempts <= 20) {
|
52
|
+
window.setTimeout(init, 2000);
|
53
|
+
} else if (paypalLoaded) {
|
54
|
+
_.each(handlers, function(handler) { handler(); });
|
55
|
+
handlers = [];
|
56
|
+
}
|
57
|
+
};
|
58
|
+
|
59
|
+
return {
|
60
|
+
ready: ready,
|
61
|
+
init: init
|
62
|
+
};
|
63
|
+
}()));
|
@@ -56,13 +56,14 @@ WORKAREA.registerModule('paypalButtons', (function () {
|
|
56
56
|
* @name init
|
57
57
|
* @memberof WORKAREA.paypalButtons
|
58
58
|
*/
|
59
|
-
init = function
|
60
|
-
|
59
|
+
init = function($scope) {
|
60
|
+
WORKAREA.paypal.ready(function() {
|
61
|
+
var $buttonContainer = $('#paypal-button-container', $scope);
|
61
62
|
|
62
|
-
|
63
|
-
if (_.isEmpty($buttonContainer)) { return; }
|
63
|
+
if (_.isEmpty($buttonContainer)) { return; }
|
64
64
|
|
65
|
-
|
65
|
+
setup($buttonContainer);
|
66
|
+
});
|
66
67
|
};
|
67
68
|
|
68
69
|
return {
|
@@ -81,13 +81,14 @@ WORKAREA.registerModule('paypalHostedFields', (function () {
|
|
81
81
|
* @memberof WORKAREA.paypalHostedFields
|
82
82
|
*/
|
83
83
|
init = function ($scope) {
|
84
|
-
|
84
|
+
WORKAREA.paypal.ready(function () {
|
85
|
+
var $placeholder = $('[data-paypal-hosted-fields]', $scope);
|
85
86
|
|
86
|
-
|
87
|
-
|
88
|
-
if (!paypal.HostedFields.isEligible()) { return; }
|
87
|
+
if (_.isEmpty($placeholder)) { return; }
|
88
|
+
if (!paypal.HostedFields.isEligible()) { return; }
|
89
89
|
|
90
|
-
|
90
|
+
setup($placeholder, $scope);
|
91
|
+
});
|
91
92
|
};
|
92
93
|
|
93
94
|
return {
|
@@ -25,6 +25,7 @@ Workarea::Plugin.append_javascripts(
|
|
25
25
|
|
26
26
|
Workarea::Plugin.append_javascripts(
|
27
27
|
'storefront.modules',
|
28
|
+
'workarea/storefront/paypal/modules/paypal',
|
28
29
|
'workarea/storefront/paypal/modules/update_checkout_submit_text',
|
29
30
|
'workarea/storefront/paypal/modules/paypal_buttons',
|
30
31
|
'workarea/storefront/paypal/modules/paypal_hosted_fields'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workarea-paypal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bcrouse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: workarea
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- app/assets/images/workarea/admin/payment_icons/paypal.svg
|
77
77
|
- app/assets/images/workarea/storefront/payment_icons/paypal.svg
|
78
78
|
- app/assets/javascripts/workarea/storefront/paypal/config.js.erb
|
79
|
+
- app/assets/javascripts/workarea/storefront/paypal/modules/paypal.js
|
79
80
|
- app/assets/javascripts/workarea/storefront/paypal/modules/paypal_buttons.js
|
80
81
|
- app/assets/javascripts/workarea/storefront/paypal/modules/paypal_hosted_fields.js
|
81
82
|
- app/assets/javascripts/workarea/storefront/paypal/modules/update_checkout_submit_text.js
|