spree-paypal_platform 5.1.1 → 5.1.2

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: 8a5221aa76bed440ec3e3c43943dd19d5230363f0af8a2b019de30451b6b5a17
4
+ data.tar.gz: 211d91d6bdbfaa92915b5c83902e41da2945a07701fc4165be9fc33951ce85d4
5
5
  SHA512:
6
- metadata.gz: b003f28202908c38acf93ab895835bae013d893da184c451df9e2b3ca98ee70d8c8c8dcf4f7497abe1dc62cf00760414a607a036282d4af9675111ac8b73ba40
7
- data.tar.gz: 605032f390401d9aaf2de1a33d54a6555ddb6b56c274c594836889a36eeb4bcd21d9299a4342398b7b012b53f812806bf73ac7710b24916a8b8d9de4dc82973c
6
+ metadata.gz: 7a3000e8e2ba28578737283bdff1c0c12aee5bb13504d3491cea317e690da1accd91dfa49ff965683dbdaec7397ab6b56a5b898d3495c0d14e505f5a2cb83a52
7
+ data.tar.gz: 94bb3f74f6bcbde9703a52e9d483d01991c1c0a07b9b4af1ee9879ce06dd374ebd9ef7d90a9c6b6a942da4b97b497be348c7fdd27c87cf4da4b5aaec1eee4c0b
data/CHANGELOG.md CHANGED
@@ -1,51 +1,20 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project are documented in this file.
3
+ ## 5.1.2
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`.
13
-
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`.
5
+ - Completing a session GETs the PayPal order first and skips capture when
6
+ it is already `COMPLETED` (Apple Pay `confirmOrder`).
7
+ - `CreateSource` accepts an empty `payment_source.paypal` hash from the
8
+ create-order echo so checkout can finish after PayPal has taken payment.
21
9
 
22
- ## 5.0.1
23
-
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
10
+ ## 5.1.1
35
11
 
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.
12
+ First release.
42
13
 
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`.
14
+ - `Spree::PaypalPlatform::Gateway` for Spree 5.6+
15
+ - PayPal wallet, Apple Pay, and Card Fields on one payment method
16
+ - Store API v3 payment sessions
17
+ - `SET_PROVIDED_ADDRESS` so the storefront owns shipping
18
+ - VAT-safe amount breakdown (`additional_tax_total` only)
19
+ - Official `paypal-server-sdk` `~> 2.3`
20
+ - One migration: create `spree_paypal_platform_orders`
@@ -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
 
@@ -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,
@@ -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.2'
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aypex