workarea-paypal 3.0.0 → 3.0.5

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: 159d0b080b0fb36119cdf1c15e0ca07936e938237fd012ed67ddf8f6121dbb53
4
- data.tar.gz: 7d8812db2e69fc22092bfcca4aa61d30a7578f2d7b5852bbc2f321d47a28f734
3
+ metadata.gz: 92bdac05441fd966fa90acc4cb18badd013d583b0cc69b98a36a79144e5e5fac
4
+ data.tar.gz: 519be45e1b7a3e27167df514ae49fe1ac32eaf5250156c9ed88b6c15e7c1bf7d
5
5
  SHA512:
6
- metadata.gz: 834c524e29ee8e810f6e9ee3dace1ab105e8665c19315a1a3664f14e88118bb1bb0705af5729fbbc11b4ba439bdf7e4f9c8d19dfe9a840938cef9f84255dfc0f
7
- data.tar.gz: b0ffa2b76120f84ecccf2973cc2dee52e3001a2a5403a5f4c249b82cc222a01f8e391ad420557840737730429ed5ce36a2c867736413ad38a9efefe3277bb65a
6
+ metadata.gz: a6d388830f585b699138e407415190f6d8d21489d22666010d2a1a3e3c2499320c0b26b9b3c1cfb7082e0e23ea53cd11d49eba8662852e34deaefb1b7624d731
7
+ data.tar.gz: ff569d2f2291693dfbb839c84b678ccb662b8f69286c3194233550ccc7731e2b13f854d42184e635ec1a2303e5c31352f307a2a518ed5b78f706666afa099840
@@ -1,3 +1,88 @@
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
+
35
+ Workarea Paypal 3.0.4 (2020-06-17)
36
+ --------------------------------------------------------------------------------
37
+
38
+ * Scope routes to include locale
39
+
40
+
41
+ Ben Crouse
42
+
43
+ * Corrected minor typo
44
+
45
+
46
+ JurgenHahn
47
+
48
+
49
+
50
+ Workarea Paypal 3.0.3 (2020-05-26)
51
+ --------------------------------------------------------------------------------
52
+
53
+ * Update Paypal BN
54
+
55
+
56
+ Ben Crouse
57
+
58
+
59
+
60
+ Workarea Paypal 3.0.2 (2020-05-14)
61
+ --------------------------------------------------------------------------------
62
+
63
+ * Fix wrong protocol when using SSL
64
+
65
+ Fixes #11
66
+
67
+ Ben Crouse
68
+
69
+ * Fix field name on #refund
70
+
71
+
72
+ Alejandro Babio
73
+
74
+
75
+
76
+ Workarea Paypal 3.0.1 (2020-03-17)
77
+ --------------------------------------------------------------------------------
78
+
79
+ * Add upgrade guide
80
+
81
+ PAYPAL-6
82
+ Matt Duffy
83
+
84
+
85
+
1
86
  Workarea Paypal 3.0.0 (2020-03-03)
2
87
  --------------------------------------------------------------------------------
3
88
 
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'
data/README.md CHANGED
@@ -3,7 +3,12 @@ Workarea PayPal
3
3
 
4
4
  A Workarea Commerce plugin that adds support for PayPal payments. This plugin adds a new tender type in checkout, which allows users to pay for their items with PayPal.
5
5
 
6
- As of v3.0, this plugin utilizes the [PayPal Commerce Platform](https://www.paypal.com/us/webapps/mpp/commerce-platform). By default this integrates PayPal's [Smart Payment Buttons](https://developer.paypal.com/docs/commerce-platform/payment/checkout/) into your Workarea Application to allow customer's to use any payment method supported in their area to complete checkout on your storefront.
6
+ As of v3.0, this plugin utilizes the [PayPal Commerce Platform](https://www.paypal.com/us/webapps/mpp/commerce-platform). By default this integrates PayPal's [Smart Payment Buttons](https://developer.paypal.com/docs/commerce-platform/payment/checkout/) into your Workarea Application to allow customers to use any payment method supported in their area to complete checkout on your storefront.
7
+
8
+ Upgrading to v3.0.0
9
+ --------------------------------------------------------------------------------
10
+
11
+ See the [upgrade guide](UPGRADE.md) for information on upgrading from v2.x of this plugin.
7
12
 
8
13
  Getting Started
9
14
  --------------------------------------------------------------------------------
@@ -63,7 +68,7 @@ Then, add a PayPal section:
63
68
 
64
69
  ```yaml
65
70
  paypal:
66
- client_Id: YOUR_CLIENT_ID
71
+ client_id: YOUR_CLIENT_ID
67
72
  client_secret: YOUR_CLIENT_SECRET
68
73
  ```
69
74
 
@@ -0,0 +1,46 @@
1
+ Upgrading This Gem from v2.x to v3.0.0
2
+ ================================================================================
3
+
4
+ As of this gem's v3.0 version, this plugin utilizes the [PayPal Commerce Platform](https://www.paypal.com/us/webapps/mpp/commerce-platform). By default this integrates PayPal's [Smart Payment Buttons](https://developer.paypal.com/docs/commerce-platform/payment/checkout/) into your Workarea Application to allow customers to use any payment method supported in their area to complete checkout on your storefront.
5
+
6
+ Upgrading will require approximately the following steps:
7
+
8
+ 1. New PayPal Account Setup (see [README](https://github.com/workarea-commerce/workarea-paypal#account-setup))
9
+ * Create a new [PayPal business account](https://www.paypal.com/signin/client?flow=provisionUser) to generate sandbox credentials.
10
+ * Add credentials to your application.
11
+
12
+
13
+ 2. Update your application Gemfile
14
+
15
+ `gem 'workarea-paypal', '~> 3.0.0'`
16
+
17
+ 3. Rework any customizations your application made around PayPal. Information around what change is provided below to give you an idea of areas you might need to address.
18
+
19
+ 4. Test locally and/or staging to ensure your application is communicating with PayPal.
20
+
21
+ 5. Generate a live REST API app within PayPal to get production credentials.
22
+
23
+ 6. Add production credentials and deploy.
24
+
25
+ Plugin Changes
26
+ ---------------
27
+
28
+ This represents a completely new integration that will require any customizations your application has made to PayPal behavior to be updated to be compatible with v3 of this plugin. As with any change, you should follow the setup steps for the plugin and test extensively to ensure everything is working properly before deploying to production.
29
+
30
+ This upgrade will require a new PayPal merchant account and updating credentials for both your sandbox and live environments. Contact Workarea Support or PayPal directly with any questions regarding transitioning your application.
31
+
32
+ ### Storefront Changes
33
+
34
+ Previous versions of this plugin rendered a static PayPal button on the top and bottom of the cart page, and provided a text-based payment option on the payment step of checkout.
35
+
36
+ The PayPal Commerce Platform integration is more dynamic. The cart page and the step both render a single instance of the [Smart Payment Buttons](https://developer.paypal.com/docs/commerce-platform/payment/checkout/). This generates a dynamic set of PayPal payment options that can vary based on device, customer location, and more. You will need to take this change into consideration and update your views to accommodate the visual change.
37
+
38
+ These buttons are rendered within an iframe controlled by PayPal. This iframe can change height for certain payment options, so its container should be flexible to account for that potential behavior. There is set of configuration options you can pass to the `paypal.Buttons` javascript method to customize how these buttons are rendered. Workarea provides a javascript configuration object, `WORKAREA.config.paypalButtons` to modify options passed. See the [PayPal documentation](https://developer.paypal.com/docs/checkout/integration-features/customize-button/) for valid options.
39
+
40
+ Smart Payment Buttons are entirely javascript-based. Part of this behavior eliminates a full redirect away from your site to PayPal, in favor of a separate window that allows the customer to interact with PayPal, and the PayPal javascript SDK to communicate back to your application without leaving the page.
41
+
42
+ ### Payment Processing Changes
43
+
44
+ Previously, this plugin relied on the ActiveMerchant PayPal implementation to process payments with PayPal. As of v3, this is no longer the case, and instead utilizes PayPal's own [Checkout Ruby SDK](https://github.com/paypal/Checkout-Ruby-SDK). This provides the environment and client logic to securely communicate with PayPal.
45
+
46
+ With this new gateway, PayPal payments are captured immediately at the time a customer places an order. This is a change from the authorization behavior of the old API that allowed for captures at a later time. You will want to make sure your OMS and other payment related behaviors work with this change. If you need to continue doing authorizations when an order is placed, contact PayPal or Workarea Support to discuss options. As of this writing, the PayPal Commerce Platform has some features that do not yet support authorizations.
@@ -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'
@@ -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.0'.freeze
3
+ VERSION = '3.0.5'.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.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-03-03 00:00:00.000000000 Z
11
+ date: 2020-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea
@@ -72,9 +72,11 @@ files:
72
72
  - LICENSE
73
73
  - README.md
74
74
  - Rakefile
75
+ - UPGRADE.md
75
76
  - app/assets/images/workarea/admin/payment_icons/paypal.svg
76
77
  - app/assets/images/workarea/storefront/payment_icons/paypal.svg
77
78
  - app/assets/javascripts/workarea/storefront/paypal/config.js.erb
79
+ - app/assets/javascripts/workarea/storefront/paypal/modules/paypal.js
78
80
  - app/assets/javascripts/workarea/storefront/paypal/modules/paypal_buttons.js
79
81
  - app/assets/javascripts/workarea/storefront/paypal/modules/paypal_hosted_fields.js
80
82
  - app/assets/javascripts/workarea/storefront/paypal/modules/update_checkout_submit_text.js
@@ -172,8 +174,8 @@ files:
172
174
  - test/factories/workarea/capture_denied_webhook.json
173
175
  - test/factories/workarea/paypal.rb
174
176
  - test/helpers/workarea/storefront/paypal_helper_test.rb
175
- - test/integration/workarea/storefront/papyal_place_order_integration_test.rb
176
177
  - test/integration/workarea/storefront/paypal_integration_test.rb
178
+ - test/integration/workarea/storefront/paypal_place_order_integration_test.rb
177
179
  - test/lib/workarea/paypal/gateway_test.rb
178
180
  - test/models/workarea/payment/authorize/paypal_test.rb
179
181
  - test/models/workarea/payment/capture/paypal_test.rb
@@ -217,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
219
  - !ruby/object:Gem::Version
218
220
  version: '0'
219
221
  requirements: []
220
- rubygems_version: 3.0.6
222
+ rubygems_version: 3.0.3
221
223
  signing_key:
222
224
  specification_version: 4
223
225
  summary: PayPal integration for the Workarea Commerce Platform