spree-paypal_platform 5.1.3 → 5.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b451e198e6215856080bd410bfdcec699ad02835c638a02d7a33ee933f21f27
4
- data.tar.gz: 183989e5effcb3cc16461b8f7e0401a284d630d546e6304aa8d65730f3bce7be
3
+ metadata.gz: 10754110031d42b6574e51b4eef1c1cb1adcc5a0d09b7c203d8620eae06acae8
4
+ data.tar.gz: e7d3ea6129314c8cf7d2083370a8997bdd09aa655cfd826d96145378a60865ae
5
5
  SHA512:
6
- metadata.gz: 6a6c113d998c9538d07ebd9a6b483a37f1c26fa3502257dfa2855c94990ab307d8889a32f132cea4e29a0064812b9cbff221ae665ae0c06c9f101454cb5605b0
7
- data.tar.gz: 2dd052e117e6aff4facf62c72f63a0f00bedb7f0b7a466db880d49b48efba99bc058d9c3f1022a4cdbd71f552d73117edb0dd4ef7bfe9e1a14a53361d1ff6759
6
+ metadata.gz: 0e97ad651a97eba76344f666a171ad211583608a8ce307ca80fd507f5452e6a07ca2e81f04af9f4fce14594a5c507d1e95facce00eb0d334d7ea34c5b499ba2c
7
+ data.tar.gz: 001c8dec98b5eed5f48c20cc398b453daeaca65829b81d49bb7aa40cc33b3b6ab06beeadf2c77b6ab2dd71612216f9f877dde3d8ed3723edec956fd3d5b4a2d9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.1.4
4
+
5
+ - `enable_card_fields` preference (checkbox, default on).
6
+ - Storefront sees `enable_apple_pay` and `enable_card_fields` on the payment
7
+ method (`public_preferences`) and on the payment session `external_data`.
8
+ - Client token is not requested when Card Fields are disabled.
9
+
3
10
  ## 5.1.3
4
11
 
5
12
  Remove the unused `apple_pay_domain` preference. Domain registration is
data/README.md CHANGED
@@ -48,7 +48,8 @@ Then add a **PayPal** payment method in admin and set:
48
48
  | `client_id` / `client_secret` | REST app credentials from the PayPal Developer Dashboard |
49
49
  | `webhook_secret` | PayPal webhook ID (used as the verify-webhook `webhook_id`) |
50
50
  | `test_mode` | Sandbox vs live |
51
- | `enable_apple_pay` | Advertise Apple Pay to headless storefronts (default on) |
51
+ | `enable_apple_pay` | Offer Apple Pay on the storefront (default on) |
52
+ | `enable_card_fields` | Offer Card Fields on the storefront (default on) |
52
53
 
53
54
  Webhook URL is the standard Spree v3 payments webhook:
54
55
 
@@ -47,8 +47,13 @@ module Spree
47
47
 
48
48
  session_data = paypal_response.data.as_json
49
49
 
50
- client_token = generate_client_token
51
- session_data['client_token'] = client_token if client_token.present?
50
+ session_data['enable_apple_pay'] = apple_pay_enabled?
51
+ session_data['enable_card_fields'] = card_fields_enabled?
52
+
53
+ if card_fields_enabled?
54
+ client_token = generate_client_token
55
+ session_data['client_token'] = client_token if client_token.present?
56
+ end
52
57
 
53
58
  payment_session_class.create!(
54
59
  order: order,
@@ -23,6 +23,7 @@ module Spree
23
23
  preference :webhook_secret, :string
24
24
  preference :test_mode, :boolean, default: true
25
25
  preference :enable_apple_pay, :boolean, default: true
26
+ preference :enable_card_fields, :boolean, default: true
26
27
 
27
28
  validates :preferred_client_id, :preferred_client_secret, presence: true
28
29
 
@@ -105,6 +106,15 @@ module Spree
105
106
  preferred_enable_apple_pay
106
107
  end
107
108
 
109
+ ##
110
+ # Whether the storefront should offer Card Fields for this method.
111
+ #
112
+ # @return [TrueClass, FalseClass]
113
+ #
114
+ def card_fields_enabled?
115
+ preferred_enable_card_fields
116
+ end
117
+
108
118
  ##
109
119
  # @return [String, NilClass]
110
120
  #
@@ -279,6 +289,12 @@ module Spree
279
289
  end
280
290
  end
281
291
 
292
+ protected
293
+
294
+ def public_preference_keys
295
+ %i[enable_apple_pay enable_card_fields]
296
+ end
297
+
282
298
  private
283
299
 
284
300
  def find_order(order_id)
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Api
5
+ module V3
6
+ ##
7
+ # Exposes non-secret payment-method preferences to the storefront.
8
+ #
9
+ module PaymentMethodSerializerDecorator
10
+ def self.prepended(base)
11
+ base.attribute :public_preferences, &:public_preferences
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ Spree::Api::V3::PaymentMethodSerializer.prepend(
19
+ Spree::Api::V3::PaymentMethodSerializerDecorator
20
+ )
@@ -11,6 +11,7 @@
11
11
  <strong>Apple Pay</strong> is a funding source of this same PayPal method, not a second payment method.
12
12
  Register every storefront domain that will show the Apple Pay button in the
13
13
  <%= external_link_to 'PayPal Apple Pay domain registration', 'https://developer.paypal.com/docs/checkout/apm/apple-pay/', class: 'alert-link' %>
14
- dashboard. The button only renders in Safari over HTTPS.
14
+ dashboard. Use the checkboxes below to offer Card Fields and Apple Pay
15
+ on the storefront. The Apple Pay button only renders in Safari over HTTPS.
15
16
  </p>
16
17
  </div>
@@ -9,7 +9,8 @@ FactoryBot.define do
9
9
  client_id: ENV.fetch('PAYPAL_CLIENT_ID', 'client_id_test'),
10
10
  client_secret: ENV.fetch('PAYPAL_CLIENT_SECRET', 'client_secret_test'),
11
11
  test_mode: true,
12
- enable_apple_pay: true
12
+ enable_apple_pay: true,
13
+ enable_card_fields: true
13
14
  }
14
15
  end
15
16
  end
@@ -3,6 +3,6 @@
3
3
  module Spree
4
4
  module PaypalPlatform
5
5
  # Major version tracks Spree's major version: 5.x supports Spree 5.x.
6
- VERSION = '5.1.3'
6
+ VERSION = '5.1.4'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree-paypal_platform
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.3
4
+ version: 5.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aypex
@@ -131,6 +131,7 @@ files:
131
131
  - app/models/spree/paypal_platform/payment_sources/paypal.rb
132
132
  - app/models/spree/paypal_platform/store_decorator.rb
133
133
  - app/presenters/spree/paypal_platform/order_presenter.rb
134
+ - app/serializers/spree/api/v3/payment_method_serializer_decorator.rb
134
135
  - app/services/spree/paypal_platform/capture_order.rb
135
136
  - app/services/spree/paypal_platform/create_payment.rb
136
137
  - app/services/spree/paypal_platform/create_source.rb