workarea-paypal 3.0.1 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +91 -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 +2 -1
- data/app/views/workarea/storefront/checkouts/_paypal_payment.html.haml +1 -1
- data/config/initializers/append_points.rb +1 -0
- data/config/initializers/workarea.rb +1 -1
- data/config/locales/en.yml +1 -1
- data/config/routes.rb +5 -3
- data/lib/tasks/workarea/create_webhooks.rake +2 -1
- data/lib/workarea/paypal/gateway.rb +2 -2
- data/lib/workarea/paypal/version.rb +1 -1
- data/test/helpers/workarea/storefront/paypal_helper_test.rb +1 -1
- data/test/vcr_cassettes/paypal_create_order.yml +1 -1
- data/test/vcr_cassettes/paypal_gateway_create_order.yml +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27dfab5d8540a4e61595f227cf290eb29fb2d34d9bc181cba014f7781a3140ac
|
4
|
+
data.tar.gz: bfe8c845f4500f04ae08b7fafd9d3d5a974a93100ffefccc6143e9573d697e5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de7027b9c4c4db16885d0aad7d6c0725e4c5164fd9bda65bd1a82994cff6c90ec42158d1b19d353eaf882913392b79fb1882866d2f9633c97247cbdc214bf4b2
|
7
|
+
data.tar.gz: ca75b25562d13a7f04087df81749b74e141e1c129dcc40d903725c63ed4244521873b127849a0e3c2f28f081e59c58f9150143df33b56c5b682ccddc11e1fde6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,94 @@
|
|
1
|
+
Workarea Paypal 3.0.6 (2020-08-18)
|
2
|
+
--------------------------------------------------------------------------------
|
3
|
+
|
4
|
+
* Fix Typo in PayPal Environment
|
5
|
+
|
6
|
+
The `Workarea.config.paypal_environment` setting is constantized in
|
7
|
+
order to load the correct class for that environment. A missing case
|
8
|
+
caused the constantization to error out in the gateway and cause 500
|
9
|
+
errors on production.
|
10
|
+
|
11
|
+
PAYPAL-9
|
12
|
+
|
13
|
+
Tom Scott
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
Workarea Paypal 3.0.5 (2020-08-14)
|
18
|
+
--------------------------------------------------------------------------------
|
19
|
+
|
20
|
+
* Address Race Condition When Using PayPal's SDK
|
21
|
+
|
22
|
+
It's possible that our modules that use the PayPal SDK will be
|
23
|
+
initialized prior to `window.paypal` being available on the page, now
|
24
|
+
that the JS is loaded in asynchronously, causing unnecessary loss in
|
25
|
+
functionality. Additionally, there doesn't seem to be a way to bind to
|
26
|
+
any kind of event given off by the SDK on `window` that would allow us
|
27
|
+
to know whether the SDK is truly loaded or not. To address this, when
|
28
|
+
the `window.paypal` object is not available yet, and there's a
|
29
|
+
`<script>` tag on the page loading the PayPal SDK (indicating that we
|
30
|
+
are indeed expecting the SDK to be there), the PayPal modules will
|
31
|
+
re-try initializing every 5 seconds until `window.paypal` is available.
|
32
|
+
|
33
|
+
PAYPAL-7
|
34
|
+
|
35
|
+
Tom Scott
|
36
|
+
|
37
|
+
* Load JavaScript From PayPal Asynchronously
|
38
|
+
|
39
|
+
Using the `async` attribute in the `<script>` tag that loads PayPal's
|
40
|
+
JavaScript code, Workarea can now prevent it blocking the page in case
|
41
|
+
of a failure, and improve load time performance to boot.
|
42
|
+
|
43
|
+
PAYPAL-7
|
44
|
+
|
45
|
+
Fixes #10
|
46
|
+
|
47
|
+
Tom Scott
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
Workarea Paypal 3.0.4 (2020-06-17)
|
52
|
+
--------------------------------------------------------------------------------
|
53
|
+
|
54
|
+
* Scope routes to include locale
|
55
|
+
|
56
|
+
|
57
|
+
Ben Crouse
|
58
|
+
|
59
|
+
* Corrected minor typo
|
60
|
+
|
61
|
+
|
62
|
+
JurgenHahn
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
Workarea Paypal 3.0.3 (2020-05-26)
|
67
|
+
--------------------------------------------------------------------------------
|
68
|
+
|
69
|
+
* Update Paypal BN
|
70
|
+
|
71
|
+
|
72
|
+
Ben Crouse
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
Workarea Paypal 3.0.2 (2020-05-14)
|
77
|
+
--------------------------------------------------------------------------------
|
78
|
+
|
79
|
+
* Fix wrong protocol when using SSL
|
80
|
+
|
81
|
+
Fixes #11
|
82
|
+
|
83
|
+
Ben Crouse
|
84
|
+
|
85
|
+
* Fix field name on #refund
|
86
|
+
|
87
|
+
|
88
|
+
Alejandro Babio
|
89
|
+
|
90
|
+
|
91
|
+
|
1
92
|
Workarea Paypal 3.0.1 (2020-03-17)
|
2
93
|
--------------------------------------------------------------------------------
|
3
94
|
|
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 {
|
@@ -27,8 +27,9 @@ module Workarea
|
|
27
27
|
|
28
28
|
javascript_include_tag(
|
29
29
|
"https://www.paypal.com/sdk/js?#{params.to_query}",
|
30
|
+
async: true,
|
30
31
|
data: {
|
31
|
-
partner_attribution_id: '
|
32
|
+
partner_attribution_id: 'Workarea_SP', # Do not change this
|
32
33
|
client_token: @paypal_client_token
|
33
34
|
}.merge(data)
|
34
35
|
)
|
@@ -11,7 +11,7 @@
|
|
11
11
|
%span.button-property__text= t('workarea.storefront.paypal.paypal')
|
12
12
|
%p.checkout-payment__primary-method-description
|
13
13
|
- if step.paypal? && step.payment.errors.none?
|
14
|
-
%span= t('workarea.storefront.paypal.
|
14
|
+
%span= t('workarea.storefront.paypal.payment_received')
|
15
15
|
- elsif step.paypal? && step.payment.errors.present?
|
16
16
|
%span= t('workarea.storefront.paypal.payment_failed')
|
17
17
|
- else
|
@@ -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'
|
data/config/locales/en.yml
CHANGED
@@ -23,7 +23,7 @@ en:
|
|
23
23
|
on_continue: Select a PayPal payment option.
|
24
24
|
paid_with_paypal: Paid with PayPal
|
25
25
|
payment_failed: Your submitted PayPal payment could not be completed. Select a new method and try again.
|
26
|
-
|
26
|
+
payment_received: Thank You! We have received your information back from PayPal.
|
27
27
|
Please confirm that the shipping address and shipping method are correct,
|
28
28
|
then click on 'Place Order'.
|
29
29
|
paypal: PayPal
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
Workarea::Storefront::Engine.routes.draw do
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
scope '(:locale)', constraints: Workarea::I18n.routes_constraint do
|
3
|
+
post 'paypal' => 'paypal#create'
|
4
|
+
put 'paypal/:id/approved' => 'paypal#update', as: :paypal_approved
|
5
|
+
post 'paypal/event' => 'paypal#event', as: :paypal_event
|
6
|
+
end
|
5
7
|
end
|
@@ -17,7 +17,8 @@ namespace :workarea do
|
|
17
17
|
puts 'Subscribing to PayPal webhook events...'
|
18
18
|
Workarea::Paypal.gateway.create_webhook(
|
19
19
|
url: Workarea::Storefront::Engine.routes.url_helpers.paypal_event_url(
|
20
|
-
host: Workarea.config.host
|
20
|
+
host: Workarea.config.host,
|
21
|
+
protocol: Rails.application.config.force_ssl ? 'https' : 'http'
|
21
22
|
),
|
22
23
|
event_types: Workarea.config.default_webhook_events
|
23
24
|
)
|
@@ -17,7 +17,7 @@ module Workarea
|
|
17
17
|
|
18
18
|
def send_request(request)
|
19
19
|
# Do not change this
|
20
|
-
request.headers["PayPal-Partner-Attribution-Id"] = '
|
20
|
+
request.headers["PayPal-Partner-Attribution-Id"] = 'Workarea_SP'
|
21
21
|
|
22
22
|
client.execute(request)
|
23
23
|
end
|
@@ -90,7 +90,7 @@ module Workarea
|
|
90
90
|
request.request_body(
|
91
91
|
amount: {
|
92
92
|
value: amount.to_s,
|
93
|
-
|
93
|
+
currency_code: amount.currency.iso_code
|
94
94
|
}
|
95
95
|
)
|
96
96
|
end
|
@@ -16,7 +16,7 @@ module Workarea
|
|
16
16
|
assert_includes(result, 'debug=true')
|
17
17
|
assert_includes(result, "client-id=#{Workarea::Paypal.gateway.client_id}")
|
18
18
|
assert_includes(result, 'components=buttons')
|
19
|
-
assert_includes(result, 'data-partner-attribution-id="
|
19
|
+
assert_includes(result, 'data-partner-attribution-id="Workarea_SP"')
|
20
20
|
refute_includes(result, 'hosted-fields')
|
21
21
|
refute_includes(result, 'data-client-token')
|
22
22
|
|
@@ -69,7 +69,7 @@ http_interactions:
|
|
69
69
|
Content-Type:
|
70
70
|
- application/json
|
71
71
|
Paypal-Partner-Attribution-Id:
|
72
|
-
-
|
72
|
+
- Workarea_SP
|
73
73
|
Authorization:
|
74
74
|
- Bearer A21AAH8JBaCq97a9fIWYVjR13RiayfAPxcb-o5l9hZ57HACn0JwaefBkRcSfh9rEwmZR6JozBLLU2MsRYTuFsZ91mOZR9jFMQ
|
75
75
|
Accept-Encoding:
|
@@ -64,7 +64,7 @@ http_interactions:
|
|
64
64
|
Content-Type:
|
65
65
|
- application/json
|
66
66
|
Paypal-Partner-Attribution-Id:
|
67
|
-
-
|
67
|
+
- Workarea_SP
|
68
68
|
Authorization:
|
69
69
|
- Bearer A21AAEQe49FiVXiExO3v7exrXi-z5BAM4wSeASef6xs6RrkPBHK5Kj9oW3RVniFGVumUb7r0t3JsrQ9YgIb1t2dc5Wir9JX2Q
|
70
70
|
Accept-Encoding:
|
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.6
|
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-18 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
|
@@ -218,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
219
|
- !ruby/object:Gem::Version
|
219
220
|
version: '0'
|
220
221
|
requirements: []
|
221
|
-
rubygems_version: 3.0.
|
222
|
+
rubygems_version: 3.0.3
|
222
223
|
signing_key:
|
223
224
|
specification_version: 4
|
224
225
|
summary: PayPal integration for the Workarea Commerce Platform
|