spree-paypal_platform 5.1.0 → 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 +4 -4
- data/CHANGELOG.md +14 -40
- data/README.md +0 -20
- data/app/models/spree/paypal_platform/gateway/payment_sessions.rb +9 -5
- data/app/services/spree/paypal_platform/create_source.rb +4 -3
- data/db/migrate/{20250528095719_create_spree_paypal_checkout_orders.rb → 20250528095719_create_spree_paypal_platform_orders.rb} +4 -3
- data/lib/spree/paypal_platform/version.rb +1 -1
- data/lib/spree/paypal_platform.rb +1 -11
- metadata +2 -5
- data/db/migrate/20260817120000_rewrite_spree_paypal_checkout_sti_types.rb +0 -33
- data/db/migrate/20260817130000_add_unique_index_on_paypal_checkout_order_paypal_id.rb +0 -7
- data/db/migrate/20260817140000_rename_paypal_checkout_orders_to_paypal_platform.rb +0 -48
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a5221aa76bed440ec3e3c43943dd19d5230363f0af8a2b019de30451b6b5a17
|
|
4
|
+
data.tar.gz: 211d91d6bdbfaa92915b5c83902e41da2945a07701fc4165be9fc33951ce85d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a3000e8e2ba28578737283bdff1c0c12aee5bb13504d3491cea317e690da1accd91dfa49ff965683dbdaec7397ab6b56a5b898d3495c0d14e505f5a2cb83a52
|
|
7
|
+
data.tar.gz: 94bb3f74f6bcbde9703a52e9d483d01991c1c0a07b9b4af1ee9879ce06dd374ebd9ef7d90a9c6b6a942da4b97b497be348c7fdd27c87cf4da4b5aaec1eee4c0b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,46 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 5.1.2
|
|
4
4
|
|
|
5
|
-
|
|
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.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
## 5.1.1
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
require and no `Spree::PaypalCheckout` constant.
|
|
11
|
-
- Engine name, table prefix, payment-session STI, admin partials, and
|
|
12
|
-
`method_type` are all `spree_paypal_platform`.
|
|
13
|
-
- Migration renames `spree_paypal_checkout_orders` →
|
|
14
|
-
`spree_paypal_platform_orders` and rewrites remaining STI type strings.
|
|
15
|
-
- Install generator: `bin/rails g spree:paypal_platform:install`.
|
|
12
|
+
First release.
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## 5.0.0
|
|
25
|
-
|
|
26
|
-
First Aypex release. Intended published name `spree-paypal_platform` was
|
|
27
|
-
never accepted by RubyGems; see 5.0.1.
|
|
28
|
-
|
|
29
|
-
### Audit follow-up
|
|
30
|
-
|
|
31
|
-
- Do not log PayPal request bodies; client logging is WARN without bodies/headers.
|
|
32
|
-
- Webhook verify now checks HTTP status and is specced for signed and unsigned paths.
|
|
33
|
-
- `#authorize` raises `NotImplementedError`.
|
|
34
|
-
- `#void` / `#credit` / `#cancel` specs restored; `CaptureOrder` no longer uses the `money` gem.
|
|
35
|
-
- Unique index on `spree_paypal_platform_orders.paypal_id`.
|
|
36
|
-
- Payment sources share `#display_payment_info`; OAuth/token HTTP responses must be 2xx.
|
|
37
|
-
|
|
38
|
-
- Port of the `aypex-io/spree_paypal_platform` `tongkat-fitness` fork into
|
|
39
|
-
`Spree::PaypalPlatform`, published as `spree-paypal_platform`.
|
|
40
|
-
- Store API v3 payment sessions only. No `/api/v2/storefront/paypal_orders`.
|
|
41
|
-
- Official `paypal-server-sdk` `~> 2.3`.
|
|
42
|
-
- Apple Pay and Card Fields recorded as payment sources on the same gateway.
|
|
43
|
-
- Keeps the VAT `AMOUNT_MISMATCH` guard (additional tax only) and
|
|
44
|
-
`SET_PROVIDED_ADDRESS` storefront-owned shipping.
|
|
45
|
-
- STI alias + rewrite migration for hosts coming from
|
|
46
|
-
`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`
|
data/README.md
CHANGED
|
@@ -70,26 +70,6 @@ https://<store>/api/v3/webhooks/payments/<prefixed-payment-method-id>
|
|
|
70
70
|
`Spree::PaypalPlatform::PaymentSources::ApplePay`.
|
|
71
71
|
4. Safari + HTTPS only.
|
|
72
72
|
|
|
73
|
-
## Coming from `spree_paypal_checkout`
|
|
74
|
-
|
|
75
|
-
Existing `spree_payment_methods.type` rows may still store
|
|
76
|
-
`SpreePaypalCheckout::Gateway` or `Spree::PaypalCheckout::Gateway`. The
|
|
77
|
-
install generator copies a rewrite migration that updates those STI strings
|
|
78
|
-
to `Spree::PaypalPlatform::Gateway` and renames
|
|
79
|
-
`spree_paypal_checkout_orders` → `spree_paypal_platform_orders`.
|
|
80
|
-
|
|
81
|
-
```ruby
|
|
82
|
-
# before
|
|
83
|
-
gem 'spree_paypal_checkout', github: 'aypex-io/spree_paypal_checkout', branch: 'tongkat-fitness'
|
|
84
|
-
|
|
85
|
-
# after
|
|
86
|
-
gem 'spree-paypal_platform'
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Storefront `resolveGatewayId` should map `paypal_platform` /
|
|
90
|
-
`Spree::PaypalPlatform::Gateway`. Keep the old `paypal_checkout` /
|
|
91
|
-
`SpreePaypalCheckout::Gateway` keys until the STI rewrite has run.
|
|
92
|
-
|
|
93
73
|
## Developing
|
|
94
74
|
|
|
95
75
|
```bash
|
|
@@ -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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
|
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:
|
|
50
|
+
gateway_payment_profile_id: profile_id
|
|
50
51
|
)
|
|
51
52
|
source.update!(
|
|
52
53
|
user: user,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
class
|
|
3
|
+
class CreateSpreePaypalPlatformOrders < ActiveRecord::Migration[7.2]
|
|
4
4
|
def change
|
|
5
|
-
create_table :
|
|
5
|
+
create_table :spree_paypal_platform_orders do |t|
|
|
6
6
|
t.references :order, null: false
|
|
7
7
|
t.references :payment_method, null: false
|
|
8
8
|
t.string :paypal_id, null: false
|
|
@@ -17,6 +17,7 @@ class CreateSpreePaypalCheckoutOrders < ActiveRecord::Migration[7.2]
|
|
|
17
17
|
t.timestamps
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
add_index :
|
|
20
|
+
add_index :spree_paypal_platform_orders, %i[order_id paypal_id], unique: true
|
|
21
|
+
add_index :spree_paypal_platform_orders, :paypal_id, unique: true
|
|
21
22
|
end
|
|
22
23
|
end
|
|
@@ -23,20 +23,10 @@ module Spree
|
|
|
23
23
|
##
|
|
24
24
|
# STI type names that count as this gem's gateway.
|
|
25
25
|
#
|
|
26
|
-
# Includes historical strings from the official `spree_paypal_checkout`
|
|
27
|
-
# gem and the short-lived `Spree::PaypalCheckout` name so existing
|
|
28
|
-
# payment-method rows keep matching before the rewrite migration runs.
|
|
29
|
-
#
|
|
30
26
|
# @return [Array<String>]
|
|
31
27
|
#
|
|
32
28
|
def self.gateway_type_names
|
|
33
|
-
(
|
|
34
|
-
[
|
|
35
|
-
Gateway.name,
|
|
36
|
-
'Spree::PaypalCheckout::Gateway',
|
|
37
|
-
'SpreePaypalCheckout::Gateway'
|
|
38
|
-
] + Gateway.descendants.map(&:name)
|
|
39
|
-
).uniq
|
|
29
|
+
([Gateway.name] + Gateway.descendants.map(&:name)).uniq
|
|
40
30
|
end
|
|
41
31
|
end
|
|
42
32
|
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.
|
|
4
|
+
version: 5.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aypex
|
|
@@ -139,10 +139,7 @@ files:
|
|
|
139
139
|
- app/views/spree/admin/payments/source_forms/_spree_paypal_platform.html.erb
|
|
140
140
|
- app/views/spree/payment_sources/_paypal_platform.html.erb
|
|
141
141
|
- config/initializers/spree.rb
|
|
142
|
-
- db/migrate/
|
|
143
|
-
- db/migrate/20260817120000_rewrite_spree_paypal_checkout_sti_types.rb
|
|
144
|
-
- db/migrate/20260817130000_add_unique_index_on_paypal_checkout_order_paypal_id.rb
|
|
145
|
-
- db/migrate/20260817140000_rename_paypal_checkout_orders_to_paypal_platform.rb
|
|
142
|
+
- db/migrate/20250528095719_create_spree_paypal_platform_orders.rb
|
|
146
143
|
- lib/generators/spree/paypal_platform/install/install_generator.rb
|
|
147
144
|
- lib/spree-paypal_platform.rb
|
|
148
145
|
- lib/spree/paypal_platform.rb
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class RewriteSpreePaypalCheckoutStiTypes < ActiveRecord::Migration[7.2]
|
|
4
|
-
# Hosts coming from the official / forked `spree_paypal_platform` gem store
|
|
5
|
-
# `SpreePaypalCheckout::Gateway` (and `…::PaymentSources::Paypal`) in STI
|
|
6
|
-
# type columns. The new gem aliases those constants, so checkout keeps
|
|
7
|
-
# working before this migration runs; rewriting the strings makes the
|
|
8
|
-
# alias optional for the next deploy.
|
|
9
|
-
LEGACY_TO_CURRENT = {
|
|
10
|
-
'SpreePaypalCheckout::Gateway' => 'Spree::PaypalPlatform::Gateway',
|
|
11
|
-
'SpreePaypalCheckout::PaymentSources::Paypal' => 'Spree::PaypalPlatform::PaymentSources::Paypal',
|
|
12
|
-
'SpreePaypalCheckout::Order' => 'Spree::PaypalPlatform::Order'
|
|
13
|
-
}.freeze
|
|
14
|
-
|
|
15
|
-
def up
|
|
16
|
-
rewrite_column(:spree_payment_methods, :type)
|
|
17
|
-
rewrite_column(:spree_payment_sources, :type) if column_exists?(:spree_payment_sources, :type)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def down
|
|
21
|
-
rewrite_column(:spree_payment_methods, :type, LEGACY_TO_CURRENT.invert)
|
|
22
|
-
rewrite_column(:spree_payment_sources, :type, LEGACY_TO_CURRENT.invert) if column_exists?(:spree_payment_sources, :type)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def rewrite_column(table, column, mapping = LEGACY_TO_CURRENT)
|
|
28
|
-
mapping.each do |from, to|
|
|
29
|
-
reversible_update = "UPDATE #{table} SET #{column} = #{quote(to)} WHERE #{column} = #{quote(from)}"
|
|
30
|
-
execute reversible_update
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class RenamePaypalCheckoutOrdersToPaypalPlatform < ActiveRecord::Migration[7.2]
|
|
4
|
-
LEGACY_TO_CURRENT = {
|
|
5
|
-
'SpreePaypalCheckout::Gateway' => 'Spree::PaypalPlatform::Gateway',
|
|
6
|
-
'SpreePaypalCheckout::PaymentSources::Paypal' => 'Spree::PaypalPlatform::PaymentSources::Paypal',
|
|
7
|
-
'SpreePaypalCheckout::Order' => 'Spree::PaypalPlatform::Order',
|
|
8
|
-
'Spree::PaypalCheckout::Gateway' => 'Spree::PaypalPlatform::Gateway',
|
|
9
|
-
'Spree::PaypalCheckout::PaymentSources::Paypal' => 'Spree::PaypalPlatform::PaymentSources::Paypal',
|
|
10
|
-
'Spree::PaypalCheckout::PaymentSources::ApplePay' => 'Spree::PaypalPlatform::PaymentSources::ApplePay',
|
|
11
|
-
'Spree::PaypalCheckout::PaymentSources::Card' => 'Spree::PaypalPlatform::PaymentSources::Card',
|
|
12
|
-
'Spree::PaypalCheckout::Order' => 'Spree::PaypalPlatform::Order'
|
|
13
|
-
}.freeze
|
|
14
|
-
|
|
15
|
-
def up
|
|
16
|
-
if table_exists?(:spree_paypal_checkout_orders) && !table_exists?(:spree_paypal_platform_orders)
|
|
17
|
-
rename_table :spree_paypal_checkout_orders, :spree_paypal_platform_orders
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
rewrite_column(:spree_payment_methods, :type)
|
|
21
|
-
rewrite_column(:spree_payment_sources, :type) if column_exists?(:spree_payment_sources, :type)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def down
|
|
25
|
-
if table_exists?(:spree_paypal_platform_orders) && !table_exists?(:spree_paypal_checkout_orders)
|
|
26
|
-
rename_table :spree_paypal_platform_orders, :spree_paypal_checkout_orders
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
rewrite_column(:spree_payment_methods, :type, invert_mapping)
|
|
30
|
-
rewrite_column(:spree_payment_sources, :type, invert_mapping) if column_exists?(:spree_payment_sources, :type)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
def invert_mapping
|
|
36
|
-
{
|
|
37
|
-
'Spree::PaypalPlatform::Gateway' => 'SpreePaypalCheckout::Gateway',
|
|
38
|
-
'Spree::PaypalPlatform::PaymentSources::Paypal' => 'SpreePaypalCheckout::PaymentSources::Paypal',
|
|
39
|
-
'Spree::PaypalPlatform::Order' => 'SpreePaypalCheckout::Order'
|
|
40
|
-
}
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def rewrite_column(table, column, mapping = LEGACY_TO_CURRENT)
|
|
44
|
-
mapping.each do |from, to|
|
|
45
|
-
execute "UPDATE #{table} SET #{column} = #{quote(to)} WHERE #{column} = #{quote(from)}"
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|