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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec2de3863ee37303126a6f3b58f9e0e0e0081f983fcc7436eeef937b8429115d
4
- data.tar.gz: 976987d8fb51788da045850771b4b7c76ee9dbe2b6d7c781dc4e9874e1dde8cf
3
+ metadata.gz: 27dfab5d8540a4e61595f227cf290eb29fb2d34d9bc181cba014f7781a3140ac
4
+ data.tar.gz: bfe8c845f4500f04ae08b7fafd9d3d5a974a93100ffefccc6143e9573d697e5b
5
5
  SHA512:
6
- metadata.gz: 3d92e73fd62a729f1a0bc9d94798f181f266958cf6bd03cf05ed753650edf7cf00d12b054d0aa219bd361c57be979f116a0b605c48d9fcb857776a39c4450bde
7
- data.tar.gz: 82ed3baaf020fbaded7337706681b204bff951827f13180ccb8d91a13c5df1bed0d08ddcda4b44858bcade41ecf9ea7c6cdfd60575cef110d148255532d8e44d
6
+ metadata.gz: de7027b9c4c4db16885d0aad7d6c0725e4c5164fd9bda65bd1a82994cff6c90ec42158d1b19d353eaf882913392b79fb1882866d2f9633c97247cbdc214bf4b2
7
+ data.tar.gz: ca75b25562d13a7f04087df81749b74e141e1c129dcc40d903725c63ed4244521873b127849a0e3c2f28f081e59c58f9150143df33b56c5b682ccddc11e1fde6
@@ -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
@@ -3,4 +3,4 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
4
  gemspec
5
5
 
6
- gem 'workarea'
6
+ gem 'workarea', github: 'workarea-commerce/workarea', branch: 'v3.5-stable'
@@ -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 ($scope) {
60
- var $buttonContainer = $('#paypal-button-container', $scope);
59
+ init = function($scope) {
60
+ WORKAREA.paypal.ready(function() {
61
+ var $buttonContainer = $('#paypal-button-container', $scope);
61
62
 
62
- if (window.paypal === undefined) { return; }
63
- if (_.isEmpty($buttonContainer)) { return; }
63
+ if (_.isEmpty($buttonContainer)) { return; }
64
64
 
65
- setup($buttonContainer);
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
- var $placeholder = $('[data-paypal-hosted-fields]', $scope);
84
+ WORKAREA.paypal.ready(function () {
85
+ var $placeholder = $('[data-paypal-hosted-fields]', $scope);
85
86
 
86
- if (_.isEmpty($placeholder)) { return; }
87
- if (window.paypal === undefined) { return; }
88
- if (!paypal.HostedFields.isEligible()) { return; }
87
+ if (_.isEmpty($placeholder)) { return; }
88
+ if (!paypal.HostedFields.isEligible()) { return; }
89
89
 
90
- setup($placeholder, $scope);
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: 'Workarea_SP_PCP', # Do not change this
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.payment_recieved')
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'
@@ -10,7 +10,7 @@ Workarea.configure do |config|
10
10
  #
11
11
  config.paypal_environment =
12
12
  if Rails.env.production?
13
- 'Paypal::LiveEnvironment'
13
+ 'PayPal::LiveEnvironment'
14
14
  else
15
15
  'PayPal::SandboxEnvironment'
16
16
  end
@@ -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
- payment_recieved: Thank You! We have received your information back from PayPal.
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
@@ -1,5 +1,7 @@
1
1
  Workarea::Storefront::Engine.routes.draw do
2
- post 'paypal' => 'paypal#create'
3
- put 'paypal/:id/approved' => 'paypal#update', as: :paypal_approved
4
- post 'paypal/event' => 'paypal#event', as: :paypal_event
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"] = 'Workarea_SP_PCP'
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
- currency: amount.currency.iso_code
93
+ currency_code: amount.currency.iso_code
94
94
  }
95
95
  )
96
96
  end
@@ -1,5 +1,5 @@
1
1
  module Workarea
2
2
  module Paypal
3
- VERSION = '3.0.1'.freeze
3
+ VERSION = '3.0.6'.freeze
4
4
  end
5
5
  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="Workarea_SP_PCP"')
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
- - Workarea_SP_PCP
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
- - Workarea_SP_PCP
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.1
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-03-17 00:00:00.000000000 Z
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.6
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