spree-paypal_platform 5.1.1 → 5.1.3

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: 963337c6ac7e3f41915fa04edad216c40f021ae69957c16c60a6d503596b9d5f
4
- data.tar.gz: fab2c096c3f02d758cf1e90d1019e06184601fb74d9176ea0b52e8ce3a6f52ed
3
+ metadata.gz: 3b451e198e6215856080bd410bfdcec699ad02835c638a02d7a33ee933f21f27
4
+ data.tar.gz: 183989e5effcb3cc16461b8f7e0401a284d630d546e6304aa8d65730f3bce7be
5
5
  SHA512:
6
- metadata.gz: b003f28202908c38acf93ab895835bae013d893da184c451df9e2b3ca98ee70d8c8c8dcf4f7497abe1dc62cf00760414a607a036282d4af9675111ac8b73ba40
7
- data.tar.gz: 605032f390401d9aaf2de1a33d54a6555ddb6b56c274c594836889a36eeb4bcd21d9299a4342398b7b012b53f812806bf73ac7710b24916a8b8d9de4dc82973c
6
+ metadata.gz: 6a6c113d998c9538d07ebd9a6b483a37f1c26fa3502257dfa2855c94990ab307d8889a32f132cea4e29a0064812b9cbff221ae665ae0c06c9f101454cb5605b0
7
+ data.tar.gz: 2dd052e117e6aff4facf62c72f63a0f00bedb7f0b7a466db880d49b48efba99bc058d9c3f1022a4cdbd71f552d73117edb0dd4ef7bfe9e1a14a53361d1ff6759
data/CHANGELOG.md CHANGED
@@ -1,51 +1,25 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project are documented in this file.
3
+ ## 5.1.3
4
4
 
5
- ## 5.1.1
6
-
7
- One migration: create `spree_paypal_platform_orders`. Removed the leftover
8
- checkout-table / STI rewrite / rename migrations from 5.1.0.
9
-
10
- ## 5.1.0
11
-
12
- Full internal rename to `Spree::PaypalPlatform`.
5
+ Remove the unused `apple_pay_domain` preference. Domain registration is
6
+ in the PayPal dashboard, not this field.
13
7
 
14
- - Require path is `spree/paypal_platform`. There is no `spree/paypal_checkout`
15
- require and no `Spree::PaypalCheckout` constant.
16
- - Engine name, table prefix, payment-session STI, admin partials, and
17
- `method_type` are all `spree_paypal_platform`.
18
- - Migration renames `spree_paypal_checkout_orders` →
19
- `spree_paypal_platform_orders` and rewrites remaining STI type strings.
20
- - Install generator: `bin/rails g spree:paypal_platform:install`.
8
+ ## 5.1.2
21
9
 
22
- ## 5.0.1
10
+ - Completing a session GETs the PayPal order first and skips capture when
11
+ it is already `COMPLETED` (Apple Pay `confirmOrder`).
12
+ - `CreateSource` accepts an empty `payment_source.paypal` hash from the
13
+ create-order echo so checkout can finish after PayPal has taken payment.
23
14
 
24
- Published name is **`spree-paypal_platform`**. RubyGems rejected
25
- `spree-paypal_platform` as too similar to the official
26
- `spree_paypal_platform`. Require path and constants are unchanged
27
- (`spree/paypal_platform` → `Spree::PaypalPlatform`).
28
-
29
- ## 5.0.0
30
-
31
- First Aypex release. Intended published name `spree-paypal_platform` was
32
- never accepted by RubyGems; see 5.0.1.
33
-
34
- ### Audit follow-up
15
+ ## 5.1.1
35
16
 
36
- - Do not log PayPal request bodies; client logging is WARN without bodies/headers.
37
- - Webhook verify now checks HTTP status and is specced for signed and unsigned paths.
38
- - `#authorize` raises `NotImplementedError`.
39
- - `#void` / `#credit` / `#cancel` specs restored; `CaptureOrder` no longer uses the `money` gem.
40
- - Unique index on `spree_paypal_platform_orders.paypal_id`.
41
- - Payment sources share `#display_payment_info`; OAuth/token HTTP responses must be 2xx.
17
+ First release.
42
18
 
43
- - Port of the `aypex-io/spree_paypal_platform` `tongkat-fitness` fork into
44
- `Spree::PaypalPlatform`, published as `spree-paypal_platform`.
45
- - Store API v3 payment sessions only. No `/api/v2/storefront/paypal_orders`.
46
- - Official `paypal-server-sdk` `~> 2.3`.
47
- - Apple Pay and Card Fields recorded as payment sources on the same gateway.
48
- - Keeps the VAT `AMOUNT_MISMATCH` guard (additional tax only) and
49
- `SET_PROVIDED_ADDRESS` storefront-owned shipping.
50
- - STI alias + rewrite migration for hosts coming from
51
- `SpreePaypalCheckout::Gateway`.
19
+ - `Spree::PaypalPlatform::Gateway` for Spree 5.6+
20
+ - PayPal wallet, Apple Pay, and Card Fields on one payment method
21
+ - Store API v3 payment sessions
22
+ - `SET_PROVIDED_ADDRESS` so the storefront owns shipping
23
+ - VAT-safe amount breakdown (`additional_tax_total` only)
24
+ - Official `paypal-server-sdk` `~> 2.3`
25
+ - One migration: create `spree_paypal_platform_orders`
data/README.md CHANGED
@@ -49,7 +49,6 @@ Then add a **PayPal** payment method in admin and set:
49
49
  | `webhook_secret` | PayPal webhook ID (used as the verify-webhook `webhook_id`) |
50
50
  | `test_mode` | Sandbox vs live |
51
51
  | `enable_apple_pay` | Advertise Apple Pay to headless storefronts (default on) |
52
- | `apple_pay_domain` | Domain registered with PayPal for Apple Pay |
53
52
 
54
53
  Webhook URL is the standard Spree v3 payments webhook:
55
54
 
@@ -89,11 +89,15 @@ module Spree
89
89
  #
90
90
  def complete_payment_session(payment_session:, **_unused)
91
91
  paypal_order_id = payment_session.external_id
92
-
93
- response = client.orders.capture_order({
94
- 'id' => paypal_order_id,
95
- 'prefer' => 'return=representation'
96
- })
92
+ lookup = { 'id' => paypal_order_id, 'prefer' => 'return=representation' }
93
+
94
+ fetched = client.orders.get_order(lookup)
95
+ response =
96
+ if fetched.data.status == 'COMPLETED'
97
+ fetched
98
+ else
99
+ client.orders.capture_order(lookup)
100
+ end
97
101
 
98
102
  payment_session.update!(external_data: response.data.as_json)
99
103
 
@@ -23,7 +23,6 @@ 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 :apple_pay_domain, :string
27
26
 
28
27
  validates :preferred_client_id, :preferred_client_secret, presence: true
29
28
 
@@ -27,7 +27,7 @@ module Spree
27
27
  # @raise [ArgumentError] when the payload has no known wallet key
28
28
  #
29
29
  def call
30
- if paypal_payment_source[:paypal].present?
30
+ if paypal_payment_source.key?(:paypal)
31
31
  create_paypal_source
32
32
  elsif paypal_payment_source[:apple_pay].present?
33
33
  create_apple_pay_source
@@ -43,10 +43,11 @@ module Spree
43
43
  attr_reader :gateway, :user, :paypal_payment_source, :order
44
44
 
45
45
  def create_paypal_source
46
- wallet = paypal_payment_source[:paypal]
46
+ wallet = paypal_payment_source[:paypal] || {}
47
+ profile_id = wallet[:account_id].presence || "paypal-#{order&.number || 'guest'}"
47
48
  source = PaymentSources::Paypal.find_or_initialize_by(
48
49
  payment_method: gateway,
49
- gateway_payment_profile_id: wallet[:account_id]
50
+ gateway_payment_profile_id: profile_id
50
51
  )
51
52
  source.update!(
52
53
  user: user,
@@ -11,6 +11,6 @@
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, then set <em>Apple pay domain</em> below. The button only renders in Safari over HTTPS.
14
+ dashboard. The button only renders in Safari over HTTPS.
15
15
  </p>
16
16
  </div>
@@ -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.1'
6
+ VERSION = '5.1.3'
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.1
4
+ version: 5.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aypex