spree-paypal_platform 5.0.1 → 5.1.0
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 +19 -7
- data/README.md +24 -37
- data/Rakefile +1 -1
- data/app/models/spree/payment_sessions/{paypal_checkout.rb → paypal_platform.rb} +2 -2
- data/app/models/spree/{paypal_checkout → paypal_platform}/base.rb +2 -2
- data/app/models/spree/{paypal_checkout → paypal_platform}/gateway/payment_sessions.rb +6 -6
- data/app/models/spree/{paypal_checkout → paypal_platform}/gateway.rb +5 -5
- data/app/models/spree/{paypal_checkout → paypal_platform}/order.rb +2 -2
- data/app/models/spree/{paypal_checkout → paypal_platform}/order_decorator.rb +4 -4
- data/app/models/spree/paypal_platform/payment_method_decorator.rb +29 -0
- data/app/models/spree/{paypal_checkout → paypal_platform}/payment_sources/apple_pay.rb +1 -1
- data/app/models/spree/{paypal_checkout → paypal_platform}/payment_sources/card.rb +1 -1
- data/app/models/spree/{paypal_checkout → paypal_platform}/payment_sources/paypal.rb +1 -1
- data/app/models/spree/paypal_platform/store_decorator.rb +19 -0
- data/app/presenters/spree/{paypal_checkout → paypal_platform}/order_presenter.rb +1 -1
- data/app/services/spree/{paypal_checkout → paypal_platform}/capture_order.rb +3 -3
- data/app/services/spree/{paypal_checkout → paypal_platform}/create_payment.rb +3 -3
- data/app/services/spree/{paypal_checkout → paypal_platform}/create_source.rb +2 -2
- data/config/initializers/spree.rb +1 -1
- data/db/migrate/20250528095719_create_spree_paypal_checkout_orders.rb +1 -1
- data/db/migrate/20260817120000_rewrite_spree_paypal_checkout_sti_types.rb +4 -4
- data/db/migrate/20260817140000_rename_paypal_checkout_orders_to_paypal_platform.rb +48 -0
- data/lib/generators/spree/{paypal_checkout → paypal_platform}/install/install_generator.rb +3 -3
- data/lib/spree/{paypal_checkout → paypal_platform}/engine.rb +3 -3
- data/lib/spree/{paypal_checkout → paypal_platform}/factories.rb +15 -15
- data/lib/spree/{paypal_checkout → paypal_platform}/version.rb +2 -2
- data/lib/spree/paypal_platform.rb +42 -0
- data/lib/spree-paypal_platform.rb +3 -4
- metadata +27 -28
- data/app/models/spree/paypal_checkout/payment_method_decorator.rb +0 -29
- data/app/models/spree/paypal_checkout/store_decorator.rb +0 -19
- data/lib/spree/paypal_checkout.rb +0 -45
- data/lib/spree-paypal_checkout.rb +0 -7
- /data/app/views/spree/admin/payment_methods/configuration_guides/{_spree_paypal_checkout.html.erb → _spree_paypal_platform.html.erb} +0 -0
- /data/app/views/spree/admin/payment_methods/descriptions/{_spree_paypal_checkout.html.erb → _spree_paypal_platform.html.erb} +0 -0
- /data/app/views/spree/admin/payments/source_forms/{_spree_paypal_checkout.html.erb → _spree_paypal_platform.html.erb} +0 -0
- /data/app/views/spree/payment_sources/{_paypal_checkout.html.erb → _paypal_platform.html.erb} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3002d47c7c53f6eb690a9dbd4717e47983e47083feac8a359369378c8435d24f
|
|
4
|
+
data.tar.gz: 5b4e7e078632cd6dc4e7e2796edc696bc543c4cfd7360b3a721064fc2114b62e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c8a5d07fa468eb3a275844b667ac07be8c8d5dd5878518ceb649fe0743a977a3b7b00335cb6cb885bc2d90c0d86695bbbdf3cee9eb34d0303fe2eddaeb9901e
|
|
7
|
+
data.tar.gz: a45636029c6e2888067299a8e9900f533ca6959eb79d005ca8e44187de359ca42af68d350ccbc39fa890bb285b179694479ca4812bbc795d9b3427fae6be68d8
|
data/CHANGELOG.md
CHANGED
|
@@ -2,16 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 5.1.0
|
|
6
|
+
|
|
7
|
+
Full internal rename to `Spree::PaypalPlatform`.
|
|
8
|
+
|
|
9
|
+
- Require path is `spree/paypal_platform`. There is no `spree/paypal_checkout`
|
|
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`.
|
|
16
|
+
|
|
5
17
|
## 5.0.1
|
|
6
18
|
|
|
7
19
|
Published name is **`spree-paypal_platform`**. RubyGems rejected
|
|
8
|
-
`spree-
|
|
9
|
-
`
|
|
10
|
-
(`spree/
|
|
20
|
+
`spree-paypal_platform` as too similar to the official
|
|
21
|
+
`spree_paypal_platform`. Require path and constants are unchanged
|
|
22
|
+
(`spree/paypal_platform` → `Spree::PaypalPlatform`).
|
|
11
23
|
|
|
12
24
|
## 5.0.0
|
|
13
25
|
|
|
14
|
-
First Aypex release. Intended published name `spree-
|
|
26
|
+
First Aypex release. Intended published name `spree-paypal_platform` was
|
|
15
27
|
never accepted by RubyGems; see 5.0.1.
|
|
16
28
|
|
|
17
29
|
### Audit follow-up
|
|
@@ -20,11 +32,11 @@ never accepted by RubyGems; see 5.0.1.
|
|
|
20
32
|
- Webhook verify now checks HTTP status and is specced for signed and unsigned paths.
|
|
21
33
|
- `#authorize` raises `NotImplementedError`.
|
|
22
34
|
- `#void` / `#credit` / `#cancel` specs restored; `CaptureOrder` no longer uses the `money` gem.
|
|
23
|
-
- Unique index on `
|
|
35
|
+
- Unique index on `spree_paypal_platform_orders.paypal_id`.
|
|
24
36
|
- Payment sources share `#display_payment_info`; OAuth/token HTTP responses must be 2xx.
|
|
25
37
|
|
|
26
|
-
- Port of the `aypex-io/
|
|
27
|
-
`Spree::
|
|
38
|
+
- Port of the `aypex-io/spree_paypal_platform` `tongkat-fitness` fork into
|
|
39
|
+
`Spree::PaypalPlatform`, published as `spree-paypal_platform`.
|
|
28
40
|
- Store API v3 payment sessions only. No `/api/v2/storefront/paypal_orders`.
|
|
29
41
|
- Official `paypal-server-sdk` `~> 2.3`.
|
|
30
42
|
- Apple Pay and Card Fields recorded as payment sources on the same gateway.
|
data/README.md
CHANGED
|
@@ -3,22 +3,19 @@
|
|
|
3
3
|
PayPal Checkout for Spree 5.6+, as a single payment method covering the PayPal
|
|
4
4
|
wallet, Apple Pay, and Card Fields.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
repo is `aypex-io/spree-paypal_platform`; `require "spree/paypal_checkout"`
|
|
10
|
-
and `Spree::PaypalCheckout` are unchanged.
|
|
6
|
+
Published gem: **`spree-paypal_platform`**
|
|
7
|
+
Require: **`spree/paypal_platform`**
|
|
8
|
+
Constant: **`Spree::PaypalPlatform`**
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
the same gateway.
|
|
10
|
+
This is not the official `spree_paypal_checkout` gem. It started from that
|
|
11
|
+
extension (VAT `AMOUNT_MISMATCH` guard, storefront-owned address) and adds
|
|
12
|
+
Apple Pay as a funding source of the same gateway.
|
|
15
13
|
|
|
16
14
|
## What it is
|
|
17
15
|
|
|
18
|
-
- One `Spree::
|
|
16
|
+
- One `Spree::PaypalPlatform::Gateway` payment method.
|
|
19
17
|
- Checkout goes through Spree's **Store API v3 payment sessions**
|
|
20
|
-
(`POST /api/v3/store/carts/:id/payment_sessions` → complete).
|
|
21
|
-
legacy `/api/v2/storefront/paypal_orders` controller.
|
|
18
|
+
(`POST /api/v3/store/carts/:id/payment_sessions` → complete).
|
|
22
19
|
- The storefront owns the address. The gem pins it with
|
|
23
20
|
`SET_PROVIDED_ADDRESS` so PayPal does not re-collect it.
|
|
24
21
|
- Amount breakdown sends **only `additional_tax_total`**. Sending full
|
|
@@ -27,9 +24,8 @@ the same gateway.
|
|
|
27
24
|
[`paypal-server-sdk`](https://github.com/paypal/PayPal-Ruby-Server-SDK) gem
|
|
28
25
|
(`~> 2.3`).
|
|
29
26
|
|
|
30
|
-
Apple Pay is
|
|
31
|
-
|
|
32
|
-
wallets (Venmo, Google Pay, …) should follow the same pattern.
|
|
27
|
+
Apple Pay is not a second payment method and not a Spree Integration. It is
|
|
28
|
+
a `payment_source.apple_pay` on the same Checkout order.
|
|
33
29
|
|
|
34
30
|
## Installation
|
|
35
31
|
|
|
@@ -39,7 +35,7 @@ gem 'spree-paypal_platform'
|
|
|
39
35
|
|
|
40
36
|
```bash
|
|
41
37
|
bundle install
|
|
42
|
-
bin/rails g spree:
|
|
38
|
+
bin/rails g spree:paypal_platform:install
|
|
43
39
|
```
|
|
44
40
|
|
|
45
41
|
The generator copies the migrations. Pass `--auto-run-migrations` to skip the
|
|
@@ -67,27 +63,20 @@ https://<store>/api/v3/webhooks/payments/<prefixed-payment-method-id>
|
|
|
67
63
|
2. Register every storefront domain (and subdomain) that will show the button
|
|
68
64
|
in the [PayPal Apple Pay domain
|
|
69
65
|
registration](https://developer.paypal.com/docs/checkout/apm/apple-pay/)
|
|
70
|
-
dashboard.
|
|
66
|
+
dashboard.
|
|
71
67
|
3. Headless storefronts load the PayPal JS SDK with `components=applepay`
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
`Spree::
|
|
75
|
-
4. Safari + HTTPS only.
|
|
76
|
-
for local testing.
|
|
77
|
-
|
|
78
|
-
This gem does not ship a Next.js / Stimulus Apple Pay button. The TKF
|
|
79
|
-
storefront already owns the wallet and Card Fields UI; Apple Pay belongs
|
|
80
|
-
there, next to `FUNDING.PAYPAL`.
|
|
68
|
+
and render Apple's `ApplePaySession`. The gem records
|
|
69
|
+
`payment_source.apple_pay` as
|
|
70
|
+
`Spree::PaypalPlatform::PaymentSources::ApplePay`.
|
|
71
|
+
4. Safari + HTTPS only.
|
|
81
72
|
|
|
82
73
|
## Coming from `spree_paypal_checkout`
|
|
83
74
|
|
|
84
|
-
Existing `spree_payment_methods.type` rows store
|
|
85
|
-
`SpreePaypalCheckout::Gateway
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
`
|
|
89
|
-
|
|
90
|
-
Replace the GitHub pin:
|
|
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`.
|
|
91
80
|
|
|
92
81
|
```ruby
|
|
93
82
|
# before
|
|
@@ -97,11 +86,9 @@ gem 'spree_paypal_checkout', github: 'aypex-io/spree_paypal_checkout', branch: '
|
|
|
97
86
|
gem 'spree-paypal_platform'
|
|
98
87
|
```
|
|
99
88
|
|
|
100
|
-
|
|
101
|
-
`
|
|
102
|
-
`SpreePaypalCheckout::Gateway`
|
|
103
|
-
keys, because the gateway's `api_type` becomes `paypal_checkout` either way
|
|
104
|
-
(`Spree::PaypalCheckout::Gateway` → `paypal_checkout`).
|
|
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.
|
|
105
92
|
|
|
106
93
|
## Developing
|
|
107
94
|
|
data/Rakefile
CHANGED
|
@@ -21,7 +21,7 @@ task :test_app do
|
|
|
21
21
|
# Must be the require path, not the gem name: spree_core's common:test_app
|
|
22
22
|
# does a literal `require ENV['LIB_NAME']` and constantizes
|
|
23
23
|
# "#{LIB_NAME.camelize}::Generators::InstallGenerator".
|
|
24
|
-
ENV['LIB_NAME'] = 'spree/
|
|
24
|
+
ENV['LIB_NAME'] = 'spree/paypal_platform'
|
|
25
25
|
ENV['DB'] ||= 'postgres'
|
|
26
26
|
Rake::Task['extension:test_app'].execute(install_storefront: true, install_admin: true)
|
|
27
27
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
class PaymentSessions::
|
|
4
|
+
class PaymentSessions::PaypalPlatform < PaymentSession
|
|
5
5
|
##
|
|
6
6
|
# @return [String]
|
|
7
7
|
#
|
|
@@ -84,7 +84,7 @@ module Spree
|
|
|
84
84
|
def create_payment_source!
|
|
85
85
|
return nil if paypal_payment_source.blank?
|
|
86
86
|
|
|
87
|
-
Spree::
|
|
87
|
+
Spree::PaypalPlatform::CreateSource.new(
|
|
88
88
|
paypal_payment_source: paypal_payment_source,
|
|
89
89
|
gateway: payment_method,
|
|
90
90
|
order: order
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
module
|
|
4
|
+
module PaypalPlatform
|
|
5
5
|
##
|
|
6
6
|
# Abstract ActiveRecord base for this gem's persisted models.
|
|
7
7
|
#
|
|
8
|
-
# Table names resolve through {Spree::
|
|
8
|
+
# Table names resolve through {Spree::PaypalPlatform.table_name_prefix}.
|
|
9
9
|
#
|
|
10
10
|
class Base < ::Spree.base_class
|
|
11
11
|
self.abstract_class = true
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require 'net/http'
|
|
4
4
|
|
|
5
5
|
module Spree
|
|
6
|
-
module
|
|
6
|
+
module PaypalPlatform
|
|
7
7
|
class Gateway < ::Spree::Gateway
|
|
8
8
|
##
|
|
9
9
|
# Payment-session lifecycle used by Spree 5 storefronts.
|
|
@@ -22,7 +22,7 @@ module Spree
|
|
|
22
22
|
# @return [Class]
|
|
23
23
|
#
|
|
24
24
|
def payment_session_class
|
|
25
|
-
Spree::PaymentSessions::
|
|
25
|
+
Spree::PaymentSessions::PaypalPlatform
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
##
|
|
@@ -34,7 +34,7 @@ module Spree
|
|
|
34
34
|
# @param order [Spree::Order]
|
|
35
35
|
# @param amount [Numeric, NilClass]
|
|
36
36
|
# @param external_data [Hash]
|
|
37
|
-
# @return [Spree::PaymentSessions::
|
|
37
|
+
# @return [Spree::PaymentSessions::PaypalPlatform, NilClass]
|
|
38
38
|
#
|
|
39
39
|
def create_payment_session(order:, amount: nil, **_unused)
|
|
40
40
|
total = amount.presence || order.total_minus_store_credits
|
|
@@ -64,7 +64,7 @@ module Spree
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
##
|
|
67
|
-
# @param payment_session [Spree::PaymentSessions::
|
|
67
|
+
# @param payment_session [Spree::PaymentSessions::PaypalPlatform]
|
|
68
68
|
# @param amount [Numeric, NilClass]
|
|
69
69
|
# @param external_data [Hash]
|
|
70
70
|
# @return [TrueClass, FalseClass, NilClass]
|
|
@@ -83,7 +83,7 @@ module Spree
|
|
|
83
83
|
#
|
|
84
84
|
# Does not complete the order — that is handled by Carts::Complete.
|
|
85
85
|
#
|
|
86
|
-
# @param payment_session [Spree::PaymentSessions::
|
|
86
|
+
# @param payment_session [Spree::PaymentSessions::PaypalPlatform]
|
|
87
87
|
# @param params [Hash]
|
|
88
88
|
# @return [void]
|
|
89
89
|
#
|
|
@@ -137,7 +137,7 @@ module Spree
|
|
|
137
137
|
paypal_order_id = extract_order_id_from_webhook(event_type, resource)
|
|
138
138
|
return nil unless paypal_order_id
|
|
139
139
|
|
|
140
|
-
payment_session = Spree::PaymentSessions::
|
|
140
|
+
payment_session = Spree::PaymentSessions::PaypalPlatform.find_by(
|
|
141
141
|
payment_method: self,
|
|
142
142
|
external_id: paypal_order_id
|
|
143
143
|
)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require 'net/http'
|
|
4
4
|
|
|
5
5
|
module Spree
|
|
6
|
-
module
|
|
6
|
+
module PaypalPlatform
|
|
7
7
|
##
|
|
8
8
|
# PayPal Checkout payment method.
|
|
9
9
|
#
|
|
@@ -63,7 +63,7 @@ module Spree
|
|
|
63
63
|
# @return [String]
|
|
64
64
|
#
|
|
65
65
|
def method_type
|
|
66
|
-
'
|
|
66
|
+
'spree_paypal_platform'
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
##
|
|
@@ -77,21 +77,21 @@ module Spree
|
|
|
77
77
|
# @return [String]
|
|
78
78
|
#
|
|
79
79
|
def description_partial_name
|
|
80
|
-
'
|
|
80
|
+
'spree_paypal_platform'
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
##
|
|
84
84
|
# @return [String]
|
|
85
85
|
#
|
|
86
86
|
def configuration_guide_partial_name
|
|
87
|
-
'
|
|
87
|
+
'spree_paypal_platform'
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
##
|
|
91
91
|
# @return [String]
|
|
92
92
|
#
|
|
93
93
|
def source_partial_name
|
|
94
|
-
'
|
|
94
|
+
'paypal_platform'
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
##
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
module
|
|
4
|
+
module PaypalPlatform
|
|
5
5
|
##
|
|
6
6
|
# A persisted PayPal Orders API response, used by the legacy
|
|
7
7
|
# `/api/v2/storefront/paypal_orders` flow.
|
|
@@ -45,7 +45,7 @@ module Spree
|
|
|
45
45
|
##
|
|
46
46
|
# Capture the PayPal order via the Orders API.
|
|
47
47
|
#
|
|
48
|
-
# @return [Spree::
|
|
48
|
+
# @return [Spree::PaypalPlatform::Order]
|
|
49
49
|
# @raise [AlreadyCapturedError] when already COMPLETED
|
|
50
50
|
#
|
|
51
51
|
def capture!
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
module
|
|
4
|
+
module PaypalPlatform
|
|
5
5
|
##
|
|
6
6
|
# Adds the legacy PayPal-order association onto {Spree::Order}.
|
|
7
7
|
#
|
|
@@ -12,8 +12,8 @@ module Spree
|
|
|
12
12
|
#
|
|
13
13
|
def self.prepended(base)
|
|
14
14
|
base.store_accessor :private_metadata, :paypal_id
|
|
15
|
-
base.has_many :
|
|
16
|
-
class_name: 'Spree::
|
|
15
|
+
base.has_many :paypal_platform_orders,
|
|
16
|
+
class_name: 'Spree::PaypalPlatform::Order',
|
|
17
17
|
dependent: :destroy,
|
|
18
18
|
foreign_key: :order_id
|
|
19
19
|
end
|
|
@@ -21,4 +21,4 @@ module Spree
|
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
Spree::Order.prepend(Spree::
|
|
24
|
+
Spree::Order.prepend(Spree::PaypalPlatform::OrderDecorator)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spree
|
|
4
|
+
module PaypalPlatform
|
|
5
|
+
##
|
|
6
|
+
# Adds a paypal_platform scope and predicate onto {Spree::PaymentMethod}.
|
|
7
|
+
#
|
|
8
|
+
module PaymentMethodDecorator
|
|
9
|
+
##
|
|
10
|
+
# @param base [Class]
|
|
11
|
+
# @return [void]
|
|
12
|
+
#
|
|
13
|
+
def self.prepended(base)
|
|
14
|
+
base.scope :paypal_platform, lambda {
|
|
15
|
+
where(type: Spree::PaypalPlatform.gateway_type_names)
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
##
|
|
20
|
+
# @return [TrueClass, FalseClass]
|
|
21
|
+
#
|
|
22
|
+
def paypal_platform?
|
|
23
|
+
Spree::PaypalPlatform.gateway_type_names.include?(type)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Spree::PaymentMethod.prepend(Spree::PaypalPlatform::PaymentMethodDecorator)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spree
|
|
4
|
+
module PaypalPlatform
|
|
5
|
+
##
|
|
6
|
+
# Looks up the store's active PayPal Checkout gateway.
|
|
7
|
+
#
|
|
8
|
+
module StoreDecorator
|
|
9
|
+
##
|
|
10
|
+
# @return [Spree::PaypalPlatform::Gateway, NilClass]
|
|
11
|
+
#
|
|
12
|
+
def paypal_platform_gateway
|
|
13
|
+
@paypal_platform_gateway ||= payment_methods.paypal_platform.active.last
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Spree::Store.prepend(Spree::PaypalPlatform::StoreDecorator)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
module
|
|
4
|
+
module PaypalPlatform
|
|
5
5
|
##
|
|
6
6
|
# Captures a legacy {Order} via the PayPal Orders API and completes
|
|
7
7
|
# the Spree checkout.
|
|
8
8
|
#
|
|
9
9
|
class CaptureOrder
|
|
10
10
|
##
|
|
11
|
-
# @param paypal_order [Spree::
|
|
11
|
+
# @param paypal_order [Spree::PaypalPlatform::Order]
|
|
12
12
|
#
|
|
13
13
|
def initialize(paypal_order:)
|
|
14
14
|
@paypal_order = paypal_order
|
|
@@ -20,7 +20,7 @@ module Spree
|
|
|
20
20
|
attr_reader :paypal_order, :order, :gateway, :amount
|
|
21
21
|
|
|
22
22
|
##
|
|
23
|
-
# @return [Spree::
|
|
23
|
+
# @return [Spree::PaypalPlatform::Order]
|
|
24
24
|
#
|
|
25
25
|
def call
|
|
26
26
|
return paypal_order if order.completed? || order.canceled?
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
module
|
|
4
|
+
module PaypalPlatform
|
|
5
5
|
##
|
|
6
6
|
# Creates the Spree::Payment for a captured legacy PayPal order.
|
|
7
7
|
#
|
|
8
8
|
class CreatePayment
|
|
9
9
|
##
|
|
10
|
-
# @param paypal_order [Spree::
|
|
10
|
+
# @param paypal_order [Spree::PaypalPlatform::Order]
|
|
11
11
|
# @param order [Spree::Order, NilClass]
|
|
12
|
-
# @param gateway [Spree::
|
|
12
|
+
# @param gateway [Spree::PaypalPlatform::Gateway, NilClass]
|
|
13
13
|
# @param amount [Numeric, NilClass]
|
|
14
14
|
#
|
|
15
15
|
def initialize(paypal_order:, order: nil, gateway: nil, amount: nil)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
module
|
|
4
|
+
module PaypalPlatform
|
|
5
5
|
##
|
|
6
6
|
# Builds a {PaymentSources} record from a PayPal Orders `payment_source`.
|
|
7
7
|
#
|
|
@@ -11,7 +11,7 @@ module Spree
|
|
|
11
11
|
class CreateSource
|
|
12
12
|
##
|
|
13
13
|
# @param paypal_payment_source [Hash]
|
|
14
|
-
# @param gateway [Spree::
|
|
14
|
+
# @param gateway [Spree::PaypalPlatform::Gateway]
|
|
15
15
|
# @param order [Spree::Order, NilClass]
|
|
16
16
|
# @param user [Spree::User, NilClass]
|
|
17
17
|
#
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
# config.spree.payment_methods in its own after_initialize, and a
|
|
5
5
|
# file-scope registration here would be silently clobbered.
|
|
6
6
|
Rails.application.config.after_initialize do
|
|
7
|
-
Rails.application.config.spree.payment_methods << Spree::
|
|
7
|
+
Rails.application.config.spree.payment_methods << Spree::PaypalPlatform::Gateway
|
|
8
8
|
end
|
|
@@ -17,6 +17,6 @@ class CreateSpreePaypalCheckoutOrders < ActiveRecord::Migration[7.2]
|
|
|
17
17
|
t.timestamps
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
add_index :spree_paypal_checkout_orders, [
|
|
20
|
+
add_index :spree_paypal_checkout_orders, %i[order_id paypal_id], unique: true
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class RewriteSpreePaypalCheckoutStiTypes < ActiveRecord::Migration[7.2]
|
|
4
|
-
# Hosts coming from the official / forked `
|
|
4
|
+
# Hosts coming from the official / forked `spree_paypal_platform` gem store
|
|
5
5
|
# `SpreePaypalCheckout::Gateway` (and `…::PaymentSources::Paypal`) in STI
|
|
6
6
|
# type columns. The new gem aliases those constants, so checkout keeps
|
|
7
7
|
# working before this migration runs; rewriting the strings makes the
|
|
8
8
|
# alias optional for the next deploy.
|
|
9
9
|
LEGACY_TO_CURRENT = {
|
|
10
|
-
'SpreePaypalCheckout::Gateway' => 'Spree::
|
|
11
|
-
'SpreePaypalCheckout::PaymentSources::Paypal' => 'Spree::
|
|
12
|
-
'SpreePaypalCheckout::Order' => 'Spree::
|
|
10
|
+
'SpreePaypalCheckout::Gateway' => 'Spree::PaypalPlatform::Gateway',
|
|
11
|
+
'SpreePaypalCheckout::PaymentSources::Paypal' => 'Spree::PaypalPlatform::PaymentSources::Paypal',
|
|
12
|
+
'SpreePaypalCheckout::Order' => 'Spree::PaypalPlatform::Order'
|
|
13
13
|
}.freeze
|
|
14
14
|
|
|
15
15
|
def up
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
module
|
|
4
|
+
module PaypalPlatform
|
|
5
5
|
module Generators
|
|
6
6
|
##
|
|
7
7
|
# Copies this gem's migrations into the host app and optionally runs them.
|
|
8
8
|
#
|
|
9
9
|
class InstallGenerator < Rails::Generators::Base
|
|
10
|
-
desc 'Copies Spree::
|
|
10
|
+
desc 'Copies Spree::PaypalPlatform migrations into the host application and runs them.'
|
|
11
11
|
|
|
12
12
|
class_option :auto_run_migrations,
|
|
13
13
|
type: :boolean,
|
|
@@ -15,7 +15,7 @@ module Spree
|
|
|
15
15
|
desc: 'Run the copied migrations immediately instead of asking'
|
|
16
16
|
|
|
17
17
|
def copy_migrations
|
|
18
|
-
rake '
|
|
18
|
+
rake 'spree_paypal_platform:install:migrations'
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def run_migrations
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
|
-
module
|
|
4
|
+
module PaypalPlatform
|
|
5
5
|
##
|
|
6
6
|
# Rails engine for the PayPal Checkout payment method.
|
|
7
7
|
#
|
|
@@ -10,7 +10,7 @@ module Spree
|
|
|
10
10
|
isolate_namespace Spree
|
|
11
11
|
|
|
12
12
|
# Decorators reopen existing constants, so Zeitwerk must not autoload them.
|
|
13
|
-
initializer '
|
|
13
|
+
initializer 'spree_paypal_platform.ignore_decorators_from_zeitwerk', before: :setup_main_autoloader do
|
|
14
14
|
Rails.autoloaders.main.ignore(
|
|
15
15
|
File.join(File.dirname(__FILE__), '../../../app/**/*_decorator*.rb')
|
|
16
16
|
)
|
|
@@ -18,7 +18,7 @@ module Spree
|
|
|
18
18
|
|
|
19
19
|
# engine_name generates route-helper prefixes and must be a valid Ruby
|
|
20
20
|
# identifier, so it cannot contain a dash.
|
|
21
|
-
engine_name '
|
|
21
|
+
engine_name 'spree_paypal_platform'
|
|
22
22
|
|
|
23
23
|
config.generators do |g|
|
|
24
24
|
g.test_framework :rspec
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
FactoryBot.define do
|
|
4
|
-
factory :
|
|
4
|
+
factory :paypal_platform_gateway, class: 'Spree::PaypalPlatform::Gateway' do
|
|
5
5
|
name { 'PayPal Checkout' }
|
|
6
6
|
association :store, factory: :store
|
|
7
7
|
preferences do
|
|
@@ -14,46 +14,46 @@ FactoryBot.define do
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
factory :
|
|
18
|
-
association :payment_method, factory: :
|
|
17
|
+
factory :paypal_platform_payment_source, class: 'Spree::PaypalPlatform::PaymentSources::Paypal' do
|
|
18
|
+
association :payment_method, factory: :paypal_platform_gateway
|
|
19
19
|
gateway_payment_profile_id { 'PAY-CUSTOMER-ID' }
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
factory :
|
|
23
|
-
association :payment_method, factory: :
|
|
22
|
+
factory :paypal_platform_apple_pay_source, class: 'Spree::PaypalPlatform::PaymentSources::ApplePay' do
|
|
23
|
+
association :payment_method, factory: :paypal_platform_gateway
|
|
24
24
|
gateway_payment_profile_id { 'APPLEPAY-TOKEN-1' }
|
|
25
25
|
card_brand { 'VISA' }
|
|
26
26
|
last_digits { '4242' }
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
factory :
|
|
29
|
+
factory :paypal_platform_payment_session, class: 'Spree::PaymentSessions::PaypalPlatform' do
|
|
30
30
|
association :order, factory: :order
|
|
31
|
-
association :payment_method, factory: :
|
|
31
|
+
association :payment_method, factory: :paypal_platform_gateway
|
|
32
32
|
amount { order.total }
|
|
33
33
|
currency { order.currency }
|
|
34
34
|
status { 'pending' }
|
|
35
35
|
external_id { "PAYPAL-ORDER-#{SecureRandom.hex(8).upcase}" }
|
|
36
36
|
external_data do
|
|
37
|
-
JSON.parse(File.read(Spree::
|
|
37
|
+
JSON.parse(File.read(Spree::PaypalPlatform::Engine.root.join('spec/fixtures/paypal_order.json')))
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
factory :
|
|
40
|
+
factory :completed_paypal_platform_payment_session do
|
|
41
41
|
status { 'completed' }
|
|
42
42
|
external_data do
|
|
43
|
-
JSON.parse(File.read(Spree::
|
|
43
|
+
JSON.parse(File.read(Spree::PaypalPlatform::Engine.root.join('spec/fixtures/captured_paypal_order.json')))
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
factory :
|
|
48
|
+
factory :paypal_platform_order, class: 'Spree::PaypalPlatform::Order' do
|
|
49
49
|
paypal_id { 'PAY-ORDER-ID' }
|
|
50
50
|
order { create(:order) }
|
|
51
|
-
payment_method { create(:
|
|
51
|
+
payment_method { create(:paypal_platform_gateway) }
|
|
52
52
|
amount { order.total }
|
|
53
|
-
data { JSON.parse(File.read(Spree::
|
|
53
|
+
data { JSON.parse(File.read(Spree::PaypalPlatform::Engine.root.join('spec/fixtures/paypal_order.json'))) }
|
|
54
54
|
|
|
55
|
-
factory :
|
|
56
|
-
data { JSON.parse(File.read(Spree::
|
|
55
|
+
factory :captured_paypal_platform_order do
|
|
56
|
+
data { JSON.parse(File.read(Spree::PaypalPlatform::Engine.root.join('spec/fixtures/captured_paypal_order.json'))) }
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spree_core'
|
|
4
|
+
require 'paypal_server_sdk'
|
|
5
|
+
require 'spree/paypal_platform/version'
|
|
6
|
+
require 'spree/paypal_platform/engine'
|
|
7
|
+
|
|
8
|
+
module Spree
|
|
9
|
+
module PaypalPlatform
|
|
10
|
+
##
|
|
11
|
+
# Table prefix for models nested under this module.
|
|
12
|
+
#
|
|
13
|
+
# Must live on the module, not on {Base}. ActiveRecord walks
|
|
14
|
+
# `module_parents` for `table_name_prefix` and finds `Spree` first
|
|
15
|
+
# (`"spree_"`) unless this closer parent defines it.
|
|
16
|
+
#
|
|
17
|
+
# @return [String]
|
|
18
|
+
#
|
|
19
|
+
def self.table_name_prefix
|
|
20
|
+
'spree_paypal_platform_'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# STI type names that count as this gem's gateway.
|
|
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
|
+
# @return [Array<String>]
|
|
31
|
+
#
|
|
32
|
+
def self.gateway_type_names
|
|
33
|
+
(
|
|
34
|
+
[
|
|
35
|
+
Gateway.name,
|
|
36
|
+
'Spree::PaypalCheckout::Gateway',
|
|
37
|
+
'SpreePaypalCheckout::Gateway'
|
|
38
|
+
] + Gateway.descendants.map(&:name)
|
|
39
|
+
).uniq
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Bundler auto-requires a gem by its *name*, so `gem "spree-paypal_platform"`
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
require 'spree/paypal_checkout'
|
|
4
|
+
# issues `require "spree-paypal_platform"`. The real entry point is
|
|
5
|
+
# `spree/paypal_platform` (matching Spree::PaypalPlatform).
|
|
6
|
+
require 'spree/paypal_platform'
|
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.0
|
|
4
|
+
version: 5.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aypex
|
|
@@ -109,8 +109,7 @@ dependencies:
|
|
|
109
109
|
version: '0'
|
|
110
110
|
description: A Spree 5.6+ payment method for PayPal Checkout. Creates and captures
|
|
111
111
|
PayPal Orders via payment sessions, pins the storefront address, and records PayPal
|
|
112
|
-
wallet, Apple Pay, and card sources.
|
|
113
|
-
RubyGems rejects names too similar to the official spree_paypal_checkout gem.
|
|
112
|
+
wallet, Apple Pay, and card sources.
|
|
114
113
|
email: hello@aypex.io
|
|
115
114
|
executables: []
|
|
116
115
|
extensions: []
|
|
@@ -120,36 +119,36 @@ files:
|
|
|
120
119
|
- LICENSE
|
|
121
120
|
- README.md
|
|
122
121
|
- Rakefile
|
|
123
|
-
- app/models/spree/payment_sessions/
|
|
124
|
-
- app/models/spree/
|
|
125
|
-
- app/models/spree/
|
|
126
|
-
- app/models/spree/
|
|
127
|
-
- app/models/spree/
|
|
128
|
-
- app/models/spree/
|
|
129
|
-
- app/models/spree/
|
|
130
|
-
- app/models/spree/
|
|
131
|
-
- app/models/spree/
|
|
132
|
-
- app/models/spree/
|
|
133
|
-
- app/models/spree/
|
|
134
|
-
- app/presenters/spree/
|
|
135
|
-
- app/services/spree/
|
|
136
|
-
- app/services/spree/
|
|
137
|
-
- app/services/spree/
|
|
138
|
-
- app/views/spree/admin/payment_methods/configuration_guides/
|
|
139
|
-
- app/views/spree/admin/payment_methods/descriptions/
|
|
140
|
-
- app/views/spree/admin/payments/source_forms/
|
|
141
|
-
- app/views/spree/payment_sources/
|
|
122
|
+
- app/models/spree/payment_sessions/paypal_platform.rb
|
|
123
|
+
- app/models/spree/paypal_platform/base.rb
|
|
124
|
+
- app/models/spree/paypal_platform/gateway.rb
|
|
125
|
+
- app/models/spree/paypal_platform/gateway/payment_sessions.rb
|
|
126
|
+
- app/models/spree/paypal_platform/order.rb
|
|
127
|
+
- app/models/spree/paypal_platform/order_decorator.rb
|
|
128
|
+
- app/models/spree/paypal_platform/payment_method_decorator.rb
|
|
129
|
+
- app/models/spree/paypal_platform/payment_sources/apple_pay.rb
|
|
130
|
+
- app/models/spree/paypal_platform/payment_sources/card.rb
|
|
131
|
+
- app/models/spree/paypal_platform/payment_sources/paypal.rb
|
|
132
|
+
- app/models/spree/paypal_platform/store_decorator.rb
|
|
133
|
+
- app/presenters/spree/paypal_platform/order_presenter.rb
|
|
134
|
+
- app/services/spree/paypal_platform/capture_order.rb
|
|
135
|
+
- app/services/spree/paypal_platform/create_payment.rb
|
|
136
|
+
- app/services/spree/paypal_platform/create_source.rb
|
|
137
|
+
- app/views/spree/admin/payment_methods/configuration_guides/_spree_paypal_platform.html.erb
|
|
138
|
+
- app/views/spree/admin/payment_methods/descriptions/_spree_paypal_platform.html.erb
|
|
139
|
+
- app/views/spree/admin/payments/source_forms/_spree_paypal_platform.html.erb
|
|
140
|
+
- app/views/spree/payment_sources/_paypal_platform.html.erb
|
|
142
141
|
- config/initializers/spree.rb
|
|
143
142
|
- db/migrate/20250528095719_create_spree_paypal_checkout_orders.rb
|
|
144
143
|
- db/migrate/20260817120000_rewrite_spree_paypal_checkout_sti_types.rb
|
|
145
144
|
- db/migrate/20260817130000_add_unique_index_on_paypal_checkout_order_paypal_id.rb
|
|
146
|
-
-
|
|
147
|
-
- lib/spree
|
|
145
|
+
- db/migrate/20260817140000_rename_paypal_checkout_orders_to_paypal_platform.rb
|
|
146
|
+
- lib/generators/spree/paypal_platform/install/install_generator.rb
|
|
148
147
|
- lib/spree-paypal_platform.rb
|
|
149
|
-
- lib/spree/
|
|
150
|
-
- lib/spree/
|
|
151
|
-
- lib/spree/
|
|
152
|
-
- lib/spree/
|
|
148
|
+
- lib/spree/paypal_platform.rb
|
|
149
|
+
- lib/spree/paypal_platform/engine.rb
|
|
150
|
+
- lib/spree/paypal_platform/factories.rb
|
|
151
|
+
- lib/spree/paypal_platform/version.rb
|
|
153
152
|
homepage: https://github.com/aypex-io/spree-paypal_platform
|
|
154
153
|
licenses:
|
|
155
154
|
- MIT
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Spree
|
|
4
|
-
module PaypalCheckout
|
|
5
|
-
##
|
|
6
|
-
# Adds a paypal_checkout scope and predicate onto {Spree::PaymentMethod}.
|
|
7
|
-
#
|
|
8
|
-
module PaymentMethodDecorator
|
|
9
|
-
##
|
|
10
|
-
# @param base [Class]
|
|
11
|
-
# @return [void]
|
|
12
|
-
#
|
|
13
|
-
def self.prepended(base)
|
|
14
|
-
base.scope :paypal_checkout, lambda {
|
|
15
|
-
where(type: Spree::PaypalCheckout.gateway_type_names)
|
|
16
|
-
}
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
##
|
|
20
|
-
# @return [TrueClass, FalseClass]
|
|
21
|
-
#
|
|
22
|
-
def paypal_checkout?
|
|
23
|
-
Spree::PaypalCheckout.gateway_type_names.include?(type)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
Spree::PaymentMethod.prepend(Spree::PaypalCheckout::PaymentMethodDecorator)
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Spree
|
|
4
|
-
module PaypalCheckout
|
|
5
|
-
##
|
|
6
|
-
# Looks up the store's active PayPal Checkout gateway.
|
|
7
|
-
#
|
|
8
|
-
module StoreDecorator
|
|
9
|
-
##
|
|
10
|
-
# @return [Spree::PaypalCheckout::Gateway, NilClass]
|
|
11
|
-
#
|
|
12
|
-
def paypal_checkout_gateway
|
|
13
|
-
@paypal_checkout_gateway ||= payment_methods.paypal_checkout.active.last
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
Spree::Store.prepend(Spree::PaypalCheckout::StoreDecorator)
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spree_core'
|
|
4
|
-
require 'paypal_server_sdk'
|
|
5
|
-
require 'spree/paypal_checkout/version'
|
|
6
|
-
require 'spree/paypal_checkout/engine'
|
|
7
|
-
|
|
8
|
-
module Spree
|
|
9
|
-
module PaypalCheckout
|
|
10
|
-
##
|
|
11
|
-
# Table prefix for models nested under this module.
|
|
12
|
-
#
|
|
13
|
-
# Must live on the module, not on {Base}. ActiveRecord walks
|
|
14
|
-
# `module_parents` for `table_name_prefix` and finds `Spree` first
|
|
15
|
-
# (`"spree_"`) unless this closer parent defines it.
|
|
16
|
-
#
|
|
17
|
-
# @return [String]
|
|
18
|
-
#
|
|
19
|
-
def self.table_name_prefix
|
|
20
|
-
'spree_paypal_checkout_'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
##
|
|
24
|
-
# STI type names that count as this gem's gateway.
|
|
25
|
-
#
|
|
26
|
-
# Includes the historical `SpreePaypalCheckout::Gateway` string from the
|
|
27
|
-
# official / forked gem so existing payment-method rows keep matching
|
|
28
|
-
# after a host switches gems, even before the type-rewrite migration
|
|
29
|
-
# runs.
|
|
30
|
-
#
|
|
31
|
-
# @return [Array<String>]
|
|
32
|
-
#
|
|
33
|
-
def self.gateway_type_names
|
|
34
|
-
(
|
|
35
|
-
[Gateway.name, 'SpreePaypalCheckout::Gateway'] + Gateway.descendants.map(&:name)
|
|
36
|
-
).uniq
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Historical top-level namespace from `spree_paypal_checkout`. Existing
|
|
42
|
-
# `spree_payment_methods.type` / `spree_payment_sources.type` rows store
|
|
43
|
-
# `SpreePaypalCheckout::…`; this alias lets those strings constantize
|
|
44
|
-
# onto the new classes.
|
|
45
|
-
SpreePaypalCheckout = Spree::PaypalCheckout
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Bundler auto-requires a gem by its *name*, so `gem "spree-paypal_checkout"`
|
|
4
|
-
# in a host Gemfile issues `require "spree-paypal_checkout"`. The real entry
|
|
5
|
-
# point is `spree/paypal_checkout` (matching the Spree::PaypalCheckout
|
|
6
|
-
# namespace), so this shim keeps the default `Bundler.require` working.
|
|
7
|
-
require 'spree/paypal_checkout'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/data/app/views/spree/payment_sources/{_paypal_checkout.html.erb → _paypal_platform.html.erb}
RENAMED
|
File without changes
|