solidus_paypal_commerce_platform 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/stale.yml +1 -17
- data/CHANGELOG.md +42 -9
- data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js +7 -4
- data/app/controllers/solidus_paypal_commerce_platform/orders_controller.rb +2 -1
- data/app/controllers/solidus_paypal_commerce_platform/paypal_orders_controller.rb +1 -1
- data/app/models/solidus_paypal_commerce_platform/payment_method.rb +6 -5
- data/app/models/solidus_paypal_commerce_platform/paypal_address.rb +6 -2
- data/app/models/solidus_paypal_commerce_platform/paypal_order.rb +22 -15
- data/bin/sandbox +3 -24
- data/lib/generators/solidus_paypal_commerce_platform/install/install_generator.rb +46 -21
- data/lib/paypal/paypal_checkout_sdk/orders/orders_authorize_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/orders/orders_capture_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/orders/orders_create_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/orders/orders_get_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/orders/orders_patch_request.rb +0 -52
- data/lib/paypal/paypal_checkout_sdk/orders/orders_validate_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_capture_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_get_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_reauthorize_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/authorizations_void_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/captures_get_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/captures_refund_request.rb +0 -2
- data/lib/paypal/paypal_checkout_sdk/payments/refunds_get_request.rb +0 -2
- data/lib/paypal/paypal_http_client.rb +4 -4
- data/lib/solidus_paypal_commerce_platform/client.rb +6 -3
- data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_patch_request.rb +1 -54
- data/lib/solidus_paypal_commerce_platform/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64ecb1bbe9f5e77a70613976318354d6b0e3011c529e95d410229e31c55c3fb1
|
4
|
+
data.tar.gz: 7d6aae5716b1c2a9aa88a2c843755c0312b7025f5dde7cdd539c5ea7cb059974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 532b61e156f5a3cd0ff0eca30e65fcdf7f9e70fdfb0c69f299b2528cf3ed96bd9c08540007bafc19f26e17a1e317067270506f1da986f5e52e38dd757ef62605
|
7
|
+
data.tar.gz: 9e79910413c373e01efd301789b1b3dce257976102c7de3ce61383a1aa3e8f32ac13f1ff54e514263ce0dfdad971e49ef2eddb8d7c59deb360e8b98f3a4c06d6
|
data/.github/stale.yml
CHANGED
@@ -1,17 +1 @@
|
|
1
|
-
|
2
|
-
daysUntilStale: 60
|
3
|
-
# Number of days of inactivity before a stale issue is closed
|
4
|
-
daysUntilClose: false
|
5
|
-
# Issues with these labels will never be considered stale
|
6
|
-
exemptLabels:
|
7
|
-
- pinned
|
8
|
-
- security
|
9
|
-
# Label to use when marking an issue as stale
|
10
|
-
staleLabel: stale
|
11
|
-
# Comment to post when marking an issue as stale. Set to `false` to disable
|
12
|
-
markComment: >
|
13
|
-
This issue has been automatically marked as stale because it has not had
|
14
|
-
recent activity. It might be closed if no further activity occurs. Thank you
|
15
|
-
for your contributions.
|
16
|
-
# Comment to post when closing a stale issue. Set to `false` to disable
|
17
|
-
closeComment: false
|
1
|
+
_extends: .github
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.6.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.6.0) (2022-11-25)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.6.0...v0.6.0)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- More fixes and improvements extracted from SSF support [\#168](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/168) ([elia](https://github.com/elia))
|
10
|
+
* inline the load_order before action
|
11
|
+
* require the payment_method_id param when loading the payment method
|
12
|
+
* mark the javascript_sdk_url as HTML safe
|
13
|
+
* ensure amounts are presented with 2 decimals for the PayPal API
|
14
|
+
* fixed the sign in requests
|
15
|
+
- Reorganize the install generator and deprecate `--skip-migrations` [\#167](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/167) ([elia](https://github.com/elia))
|
16
|
+
- Move 'shipping\_preference' preference under PaypalOrder\#to\_json [\#152](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/152) ([retsef](https://github.com/retsef))
|
17
|
+
- Truncate the product name to 127 characters [\#139](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/139) ([DanielePalombo](https://github.com/DanielePalombo))
|
18
|
+
- Fix issue on international transactions [\#129](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/129) ([jtapia](https://github.com/jtapia))
|
19
|
+
|
20
|
+
## [v0.6.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.6.0) (2022-11-25)
|
21
|
+
|
22
|
+
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.5.0...v0.6.0)
|
23
|
+
|
24
|
+
**Fixed bugs:**
|
25
|
+
|
26
|
+
- Gem does not support Ruby 3.0 [\#145](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/145)
|
27
|
+
|
28
|
+
**Closed issues:**
|
29
|
+
|
30
|
+
- Invalid string length error [\#135](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/135)
|
31
|
+
- PayPal SDK JS Error: Disallowed query param: shipping\_preference [\#133](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/133)
|
32
|
+
|
3
33
|
## [v0.5.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.5.0) (2022-10-07)
|
4
34
|
|
5
35
|
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.4.0...v0.5.0)
|
@@ -7,8 +37,7 @@
|
|
7
37
|
**Merged pull requests:**
|
8
38
|
|
9
39
|
- Update links after moving to @solidusio [\#164](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/164) ([elia](https://github.com/elia))
|
10
|
-
-
|
11
|
-
- Require Solidus 3 & Ruby 2.7 [\#163](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/163) ([elia](https://github.com/elia))
|
40
|
+
- Assign created orders to users / Require Solidus 3 & Ruby 2.7 [\#163](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/163) ([elia](https://github.com/elia))
|
12
41
|
- Fix master, import paypal-checkout-sdk [\#161](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/161) ([cpfergus1](https://github.com/cpfergus1))
|
13
42
|
- Update to use forked solidus\_frontend when needed [\#160](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/160) ([waiting-for-dev](https://github.com/waiting-for-dev))
|
14
43
|
- Fix paypal\_order name address bug [\#153](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/153) ([RyanofWoods](https://github.com/RyanofWoods))
|
@@ -108,13 +137,7 @@
|
|
108
137
|
|
109
138
|
## [v0.2.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.2.0) (2020-10-13)
|
110
139
|
|
111
|
-
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.
|
112
|
-
|
113
|
-
**Closed issues:**
|
114
|
-
|
115
|
-
- README lists two different types of PayPal credentials [\#97](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/97)
|
116
|
-
- `paypal_email_confirmed` is not an actual preference [\#96](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/96)
|
117
|
-
- Make this extension the default option for Solidus [\#88](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/88)
|
140
|
+
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.2.0.alpha.1...v0.2.0)
|
118
141
|
|
119
142
|
**Merged pull requests:**
|
120
143
|
|
@@ -126,6 +149,16 @@
|
|
126
149
|
- Add skip migration option to installer [\#94](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/94) ([seand7565](https://github.com/seand7565))
|
127
150
|
- Update README to reflect referral fee [\#93](https://github.com/solidusio/solidus_paypal_commerce_platform/pull/93) ([seand7565](https://github.com/seand7565))
|
128
151
|
|
152
|
+
## [v0.2.0.alpha.1](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.2.0.alpha.1) (2020-10-07)
|
153
|
+
|
154
|
+
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.1.0...v0.2.0.alpha.1)
|
155
|
+
|
156
|
+
**Closed issues:**
|
157
|
+
|
158
|
+
- README lists two different types of PayPal credentials [\#97](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/97)
|
159
|
+
- `paypal_email_confirmed` is not an actual preference [\#96](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/96)
|
160
|
+
- Make this extension the default option for Solidus [\#88](https://github.com/solidusio/solidus_paypal_commerce_platform/issues/88)
|
161
|
+
|
129
162
|
## [v0.1.0](https://github.com/solidusio/solidus_paypal_commerce_platform/tree/v0.1.0) (2020-09-03)
|
130
163
|
|
131
164
|
[Full Changelog](https://github.com/solidusio/solidus_paypal_commerce_platform/compare/v0.0.1...v0.1.0)
|
data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js
CHANGED
@@ -7,9 +7,9 @@ SolidusPaypalCommercePlatform.hideOverlay = function() {
|
|
7
7
|
}
|
8
8
|
|
9
9
|
SolidusPaypalCommercePlatform.handleError = function(error) {
|
10
|
-
console.
|
11
|
-
console.log("PayPal Debug ID: " + error.debug_id)
|
10
|
+
console.error(error);
|
12
11
|
alert("There was a problem connecting with PayPal.")
|
12
|
+
throw error
|
13
13
|
}
|
14
14
|
|
15
15
|
SolidusPaypalCommercePlatform.sendOrder = function(payment_method_id) {
|
@@ -181,8 +181,11 @@ SolidusPaypalCommercePlatform.addPayment = function(paypal_amount, payment_metho
|
|
181
181
|
})
|
182
182
|
}
|
183
183
|
|
184
|
-
SolidusPaypalCommercePlatform.updateAddress = function(response) {
|
185
|
-
var
|
184
|
+
SolidusPaypalCommercePlatform.updateAddress = function(response) {
|
185
|
+
var shipping = response.purchase_units[0].shipping;
|
186
|
+
if (!shipping) return Promise.resolve({});
|
187
|
+
|
188
|
+
var updated_address = shipping.address;
|
186
189
|
return Spree.ajax({
|
187
190
|
url: '/solidus_paypal_commerce_platform/update_address',
|
188
191
|
method: 'POST',
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module SolidusPaypalCommercePlatform
|
4
4
|
class OrdersController < ::Spree::Api::BaseController
|
5
|
-
before_action :load_order, except: :create
|
6
5
|
skip_before_action :authenticate_user
|
7
6
|
include ::Spree::Core::ControllerHelpers::Auth
|
8
7
|
|
@@ -25,6 +24,7 @@ module SolidusPaypalCommercePlatform
|
|
25
24
|
end
|
26
25
|
|
27
26
|
def update_address
|
27
|
+
load_order
|
28
28
|
authorize! :update, @order, order_token
|
29
29
|
paypal_address = SolidusPaypalCommercePlatform::PaypalAddress.new(@order)
|
30
30
|
|
@@ -38,6 +38,7 @@ module SolidusPaypalCommercePlatform
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def verify_total
|
41
|
+
load_order
|
41
42
|
authorize! :show, @order, order_token
|
42
43
|
|
43
44
|
if total_is_correct?(params[:paypal_total])
|
@@ -15,7 +15,7 @@ module SolidusPaypalCommercePlatform
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def load_payment_method
|
18
|
-
@payment_method = ::Spree::PaymentMethod.find(params
|
18
|
+
@payment_method = ::Spree::PaymentMethod.find(params.require(:payment_method_id))
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -74,6 +74,8 @@ module SolidusPaypalCommercePlatform
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def javascript_sdk_url(order: nil, currency: nil)
|
77
|
+
# Ref: https://developer.paypal.com/sdk/js/configuration/
|
78
|
+
|
77
79
|
# Both instance and class respond to checkout_steps.
|
78
80
|
step_names = order ? order.checkout_steps : ::Spree::Order.checkout_steps.keys
|
79
81
|
|
@@ -84,17 +86,16 @@ module SolidusPaypalCommercePlatform
|
|
84
86
|
intent: auto_capture ? "capture" : "authorize",
|
85
87
|
commit: commit_immediately ? "false" : "true",
|
86
88
|
components: options[:display_credit_messaging] ? "buttons,messages" : "buttons",
|
87
|
-
currency: currency
|
89
|
+
currency: currency,
|
88
90
|
}
|
89
91
|
|
90
|
-
parameters[:shipping_preference] = 'NO_SHIPPING' if step_names.exclude? 'delivery'
|
91
92
|
parameters['enable-funding'] = 'venmo' if venmo_standalone_enabled?
|
92
93
|
|
93
|
-
|
94
|
-
parameters['buyer-country'] = options[:force_buyer_country]
|
94
|
+
unless Rails.env.production?
|
95
|
+
parameters['buyer-country'] = options[:force_buyer_country].presence
|
95
96
|
end
|
96
97
|
|
97
|
-
"https://www.paypal.com/sdk/js?#{parameters.to_query}"
|
98
|
+
"https://www.paypal.com/sdk/js?#{parameters.compact.to_query}".html_safe # rubocop:disable Rails/OutputSafety
|
98
99
|
end
|
99
100
|
end
|
100
101
|
end
|
@@ -61,12 +61,16 @@ module SolidusPaypalCommercePlatform
|
|
61
61
|
|
62
62
|
def address_attributes(address, recipient)
|
63
63
|
country = ::Spree::Country.find_by(iso: address[:country_code])
|
64
|
+
state = find_state(
|
65
|
+
address[:admin_area_1] || address[:admin_area_2] || address[:state],
|
66
|
+
country,
|
67
|
+
)
|
64
68
|
|
65
69
|
attributes = {
|
66
70
|
address1: address[:address_line_1],
|
67
71
|
address2: address[:address_line_2],
|
68
|
-
|
69
|
-
state_name:
|
72
|
+
state_id: state.try(:id),
|
73
|
+
state_name: state.try(:name),
|
70
74
|
city: address[:admin_area_2] || address[:city],
|
71
75
|
country: country,
|
72
76
|
zipcode: address[:postal_code],
|
@@ -10,14 +10,15 @@ module SolidusPaypalCommercePlatform
|
|
10
10
|
{
|
11
11
|
intent: intent,
|
12
12
|
purchase_units: purchase_units,
|
13
|
-
payer: (payer if @order.bill_address)
|
13
|
+
payer: (payer if @order.bill_address),
|
14
|
+
application_context: application_context
|
14
15
|
}
|
15
16
|
end
|
16
17
|
|
17
18
|
def to_replace_json
|
18
19
|
{
|
19
20
|
op: 'replace',
|
20
|
-
path:
|
21
|
+
path: "/purchase_units/@reference_id=='default'",
|
21
22
|
value: purchase_units(include_shipping_address: false)[0]
|
22
23
|
}
|
23
24
|
end
|
@@ -55,10 +56,10 @@ module SolidusPaypalCommercePlatform
|
|
55
56
|
def purchase_units(include_shipping_address: true)
|
56
57
|
[
|
57
58
|
{
|
58
|
-
amount:
|
59
|
+
amount: price(@order.total).merge(breakdown: breakdown),
|
59
60
|
items: line_items,
|
60
61
|
shipping: (shipping_info if @order.ship_address && include_shipping_address)
|
61
|
-
}
|
62
|
+
}.compact
|
62
63
|
]
|
63
64
|
end
|
64
65
|
|
@@ -79,21 +80,13 @@ module SolidusPaypalCommercePlatform
|
|
79
80
|
def line_items
|
80
81
|
@order.line_items.map{ |line_item|
|
81
82
|
{
|
82
|
-
name: line_item.product.name,
|
83
|
+
name: line_item.product.name.truncate(127),
|
83
84
|
unit_amount: price(line_item.price),
|
84
|
-
quantity: line_item.quantity
|
85
|
+
quantity: line_item.quantity.to_i.to_s
|
85
86
|
}
|
86
87
|
}
|
87
88
|
end
|
88
89
|
|
89
|
-
def amount
|
90
|
-
{
|
91
|
-
currency_code: @order.currency,
|
92
|
-
value: @order.total,
|
93
|
-
breakdown: breakdown
|
94
|
-
}
|
95
|
-
end
|
96
|
-
|
97
90
|
def breakdown
|
98
91
|
{
|
99
92
|
item_total: price(@order.item_total),
|
@@ -106,8 +99,22 @@ module SolidusPaypalCommercePlatform
|
|
106
99
|
def price(amount)
|
107
100
|
{
|
108
101
|
currency_code: @order.currency,
|
109
|
-
value: amount
|
102
|
+
value: ('%.2f' % amount.to_f)
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
106
|
+
def application_context
|
107
|
+
{
|
108
|
+
shipping_preference: require_shipping? ? 'SET_PROVIDED_ADDRESS' : 'NO_SHIPPING'
|
110
109
|
}
|
111
110
|
end
|
111
|
+
|
112
|
+
def require_shipping?
|
113
|
+
step_names.include? :delivery
|
114
|
+
end
|
115
|
+
|
116
|
+
def step_names
|
117
|
+
@order ? @order.checkout_steps.map(&:to_sym) : ::Spree::Order.checkout_steps.keys
|
118
|
+
end
|
112
119
|
end
|
113
120
|
end
|
data/bin/sandbox
CHANGED
@@ -49,34 +49,13 @@ fi
|
|
49
49
|
|
50
50
|
cd ./sandbox
|
51
51
|
cat <<RUBY >> Gemfile
|
52
|
-
gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
|
53
|
-
gem '
|
54
|
-
gem 'rails-i18n'
|
55
|
-
gem 'solidus_i18n'
|
56
|
-
|
57
|
-
gem '$extension_name', path: '..'
|
58
|
-
|
59
|
-
group :test, :development do
|
60
|
-
platforms :mri do
|
61
|
-
gem 'pry-byebug'
|
62
|
-
end
|
63
|
-
end
|
52
|
+
gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
|
53
|
+
gem 'pry-byebug', platforms: :mri, groups: [:test, :development]
|
64
54
|
RUBY
|
65
55
|
|
66
56
|
unbundled bundle install --gemfile Gemfile
|
67
|
-
|
68
57
|
unbundled bundle exec rake db:drop db:create
|
69
|
-
|
70
|
-
unbundled bundle exec rails generate solidus:install \
|
71
|
-
--auto-accept \
|
72
|
-
--user_class=Spree::User \
|
73
|
-
--enforce_available_locales=true \
|
74
|
-
--with-authentication=false \
|
75
|
-
--payment-method=none \
|
76
|
-
$@
|
77
|
-
|
78
|
-
unbundled bundle exec rails generate solidus:auth:install
|
79
|
-
unbundled bundle exec rails generate ${extension_name}:install
|
58
|
+
unbundled bundle exec rails generate solidus:install --auto-accept $@
|
80
59
|
|
81
60
|
echo
|
82
61
|
echo "🚀 Sandbox app successfully created for $extension_name!"
|
@@ -4,44 +4,69 @@ module SolidusPaypalCommercePlatform
|
|
4
4
|
module Generators
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
6
6
|
class_option :auto_run_migrations, type: :boolean, default: false
|
7
|
-
|
7
|
+
|
8
|
+
# This should only be used by the solidus installer prior to v3.3.
|
9
|
+
class_option :skip_migrations, type: :boolean, default: false, hide: true
|
8
10
|
|
9
11
|
source_root File.expand_path('templates', __dir__)
|
10
12
|
|
11
|
-
def
|
13
|
+
def install_solidus_core_support
|
12
14
|
template 'initializer.rb', 'config/initializers/solidus_paypal_commerce_platform.rb'
|
15
|
+
rake 'railties:install:migrations FROM=solidus_paypal_commerce_platform'
|
16
|
+
route "mount SolidusPaypalCommercePlatform::Engine, at: '/solidus_paypal_commerce_platform'"
|
13
17
|
end
|
14
18
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
19
|
+
def install_solidus_backend_support
|
20
|
+
support_code_for('solidus_backend') do
|
21
|
+
append_file(
|
22
|
+
'vendor/assets/javascripts/spree/backend/all.js',
|
23
|
+
"//= require spree/backend/solidus_paypal_commerce_platform\n"
|
24
|
+
)
|
25
|
+
inject_into_file(
|
26
|
+
'vendor/assets/stylesheets/spree/backend/all.css',
|
27
|
+
" *= require spree/backend/solidus_paypal_commerce_platform\n",
|
28
|
+
before: %r{\*/},
|
29
|
+
verbose: true,
|
30
|
+
)
|
31
|
+
end
|
18
32
|
end
|
19
33
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
34
|
+
def install_solidus_frontend_support
|
35
|
+
support_code_for('solidus_frontend') do
|
36
|
+
append_file(
|
37
|
+
'vendor/assets/javascripts/spree/frontend/all.js',
|
38
|
+
"//= require spree/frontend/solidus_paypal_commerce_platform\n",
|
39
|
+
)
|
40
|
+
inject_into_file(
|
41
|
+
'vendor/assets/stylesheets/spree/frontend/all.css',
|
42
|
+
" *= require spree/frontend/solidus_paypal_commerce_platform\n",
|
43
|
+
before: %r{\*/},
|
44
|
+
verbose: true,
|
45
|
+
)
|
46
|
+
directory engine.root.join("lib/views/frontend"), 'app/views/'
|
47
|
+
end
|
23
48
|
end
|
24
49
|
|
25
|
-
def
|
26
|
-
|
27
|
-
end
|
50
|
+
def run_migrations
|
51
|
+
return rake 'db:migrate' if options[:auto_run_migrations] && !options[:skip_migrations]
|
28
52
|
|
29
|
-
|
30
|
-
insert_into_file File.join('config', 'routes.rb'), after: "Rails.application.routes.draw do\n" do
|
31
|
-
"mount SolidusPaypalCommercePlatform::Engine, at: '/solidus_paypal_commerce_platform'\n"
|
32
|
-
end
|
53
|
+
say_status :skip, 'db:migrate'
|
33
54
|
end
|
34
55
|
|
35
|
-
|
36
|
-
return if options[:skip_migrations]
|
56
|
+
private
|
37
57
|
|
38
|
-
|
39
|
-
if
|
40
|
-
|
58
|
+
def support_code_for(gem_name, run_if: Bundler.locked_gems.specs.map(&:name).include?(gem_name), &block)
|
59
|
+
if run_if
|
60
|
+
say_status :install, "[#{engine.engine_name}] #{gem_name} code", :blue
|
61
|
+
shell.indent(&block)
|
41
62
|
else
|
42
|
-
|
63
|
+
say_status :skip, "[#{engine.engine_name}] #{gem_name} code", :blue
|
43
64
|
end
|
44
65
|
end
|
66
|
+
|
67
|
+
def engine
|
68
|
+
SolidusPaypalCommercePlatform::Engine
|
69
|
+
end
|
45
70
|
end
|
46
71
|
end
|
47
72
|
end
|
@@ -1,61 +1,9 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# This class was generated on Mon, 27 Aug 2018 13:51:59 PDT by version 0.1.0-dev+904328-dirty of Braintree SDK Generator
|
4
|
-
|
5
3
|
require 'cgi'
|
6
4
|
|
7
5
|
module PayPalCheckoutSdk
|
8
6
|
module Orders
|
9
|
-
#
|
10
|
-
# Updates an order that has the `CREATED` or `APPROVED` status. You cannot update an order with `COMPLETED` status.
|
11
|
-
# You can patch these attributes and objects:
|
12
|
-
# <table>
|
13
|
-
# <thead>
|
14
|
-
# <tr>
|
15
|
-
# <th align="left">Attribute or object</th>
|
16
|
-
# <th align="left">Operations</th>
|
17
|
-
# </tr>
|
18
|
-
# </thead>
|
19
|
-
# <tbody>
|
20
|
-
# <tr>
|
21
|
-
# <td><code>intent</code></td>
|
22
|
-
# <td align="left">Replace</td>
|
23
|
-
# </tr>
|
24
|
-
# <tr>
|
25
|
-
# <td><code>purchase_units</code></td>
|
26
|
-
# <td align="left">Replace, add</td>
|
27
|
-
# </tr>
|
28
|
-
# <tr>
|
29
|
-
# <td><code>purchase_units[].custom_id</code></td>
|
30
|
-
# <td align="left">Replace, add, remove</td>
|
31
|
-
# </tr>
|
32
|
-
# <tr>
|
33
|
-
# <td><code>purchase_units[].description</code></td>
|
34
|
-
# <td align="left">Replace, add, remove</td>
|
35
|
-
# </tr>
|
36
|
-
# <tr>
|
37
|
-
# <td><code>purchase_units[].payee.email</code></td>
|
38
|
-
# <td align="left">Replace, add</td>
|
39
|
-
# </tr>
|
40
|
-
# <tr>
|
41
|
-
# <td><code>purchase_units[].shipping</code></td>
|
42
|
-
# <td align="left">Replace, add, remove</td>
|
43
|
-
# </tr>
|
44
|
-
# <tr>
|
45
|
-
# <td><code>purchase_units[].soft_descriptor</code></td>
|
46
|
-
# <td align="left">Replace, add, remove</td>
|
47
|
-
# </tr>
|
48
|
-
# <tr>
|
49
|
-
# <td><code>purchase_units[].amount</code></td>
|
50
|
-
# <td align="left">Replace</td>
|
51
|
-
# </tr>
|
52
|
-
# <tr>
|
53
|
-
# <td><code>purchase_units[].invoice_id</code></td>
|
54
|
-
# <td align="left">Replace, add, remove</td>
|
55
|
-
# </tr>
|
56
|
-
# </tbody>
|
57
|
-
# </table>
|
58
|
-
#
|
59
7
|
class OrdersPatchRequest
|
60
8
|
attr_accessor :path, :body, :headers, :verb
|
61
9
|
|
@@ -11,8 +11,8 @@ module PayPal
|
|
11
11
|
super(environment)
|
12
12
|
@refresh_token = refresh_token
|
13
13
|
|
14
|
-
add_injector(
|
15
|
-
add_injector(
|
14
|
+
add_injector { |r| _sign_request(r) }
|
15
|
+
add_injector { |r| _add_headers(r) }
|
16
16
|
end
|
17
17
|
|
18
18
|
def user_agent
|
@@ -27,10 +27,10 @@ module PayPal
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def _sign_request(request)
|
30
|
-
return if
|
30
|
+
return if _has_auth_header(request) || _is_auth_request(request)
|
31
31
|
|
32
32
|
if !@access_token || @access_token.expired?
|
33
|
-
access_token_request = PayPal.
|
33
|
+
access_token_request = PayPal::AccessTokenRequest.new(@environment, @refresh_token)
|
34
34
|
token_response = execute(access_token_request)
|
35
35
|
@access_token = PayPal::AccessToken.new(token_response.result)
|
36
36
|
end
|
@@ -13,7 +13,7 @@ module SolidusPaypalCommercePlatform
|
|
13
13
|
request.headers["PayPal-Partner-Attribution-Id"] = SolidusPaypalCommercePlatform.config.partner_code
|
14
14
|
}.freeze
|
15
15
|
|
16
|
-
Response = Struct.new(:status_code, :error)
|
16
|
+
Response = Struct.new(:status_code, :error, keyword_init: true)
|
17
17
|
|
18
18
|
attr_reader :environment
|
19
19
|
|
@@ -28,9 +28,12 @@ module SolidusPaypalCommercePlatform
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def execute(request)
|
31
|
-
|
31
|
+
Rails.logger.info "[SolidusPaypalCommercePlatform::Client#execute] #{request.inspect}"
|
32
|
+
@paypal_client.execute(request).tap do |response|
|
33
|
+
Rails.logger.info "[SolidusPaypalCommercePlatform::Client#execute] #{response.inspect}"
|
34
|
+
end
|
32
35
|
rescue PayPalHttp::HttpError => e
|
33
|
-
Rails.logger.error e.result
|
36
|
+
Rails.logger.error "[SolidusPaypalCommercePlatform::Client#execute] #{e.result.inspect}"
|
34
37
|
Response.new(status_code: 422, error: e.result)
|
35
38
|
end
|
36
39
|
|
data/lib/solidus_paypal_commerce_platform/paypal_checkout_sdk/orders/orders_patch_request.rb
CHANGED
@@ -1,63 +1,10 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# frozen_string_literal :true
|
4
|
-
|
5
|
-
# This module was automatically generated from paypal_checkout_sdk 1.0.1
|
6
3
|
require 'cgi'
|
7
4
|
|
8
5
|
module SolidusPaypalCommercePlatform
|
9
6
|
module PayPalCheckoutSdk
|
10
7
|
module Orders
|
11
|
-
#
|
12
|
-
# Updates an order that has the `CREATED` or `APPROVED` status. You cannot update
|
13
|
-
# an order with `COMPLETED` status. You can patch these attributes and objects:
|
14
|
-
# <table>
|
15
|
-
# <thead>
|
16
|
-
# <tr>
|
17
|
-
# <th align="left">Attribute or object</th>
|
18
|
-
# <th align="left">Operations</th>
|
19
|
-
# </tr>
|
20
|
-
# </thead>
|
21
|
-
# <tbody>
|
22
|
-
# <tr>
|
23
|
-
# <td><code>intent</code></td>
|
24
|
-
# <td align="left">Replace</td>
|
25
|
-
# </tr>
|
26
|
-
# <tr>
|
27
|
-
# <td><code>purchase_units</code></td>
|
28
|
-
# <td align="left">Replace, add</td>
|
29
|
-
# </tr>
|
30
|
-
# <tr>
|
31
|
-
# <td><code>purchase_units[].custom_id</code></td>
|
32
|
-
# <td align="left">Replace, add, remove</td>
|
33
|
-
# </tr>
|
34
|
-
# <tr>
|
35
|
-
# <td><code>purchase_units[].description</code></td>
|
36
|
-
# <td align="left">Replace, add, remove</td>
|
37
|
-
# </tr>
|
38
|
-
# <tr>
|
39
|
-
# <td><code>purchase_units[].payee.email</code></td>
|
40
|
-
# <td align="left">Replace, add</td>
|
41
|
-
# </tr>
|
42
|
-
# <tr>
|
43
|
-
# <td><code>purchase_units[].shipping</code></td>
|
44
|
-
# <td align="left">Replace, add, remove</td>
|
45
|
-
# </tr>
|
46
|
-
# <tr>
|
47
|
-
# <td><code>purchase_units[].soft_descriptor</code></td>
|
48
|
-
# <td align="left">Replace, add, remove</td>
|
49
|
-
# </tr>
|
50
|
-
# <tr>
|
51
|
-
# <td><code>purchase_units[].amount</code></td>
|
52
|
-
# <td align="left">Replace</td>
|
53
|
-
# </tr>
|
54
|
-
# <tr>
|
55
|
-
# <td><code>purchase_units[].invoice_id</code></td>
|
56
|
-
# <td align="left">Replace, add, remove</td>
|
57
|
-
# </tr>
|
58
|
-
# </tbody>
|
59
|
-
# </table>
|
60
|
-
#
|
61
8
|
class OrdersPatchRequest
|
62
9
|
attr_accessor :path, :body, :headers, :verb
|
63
10
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_paypal_commerce_platform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Denny
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: deface
|
@@ -258,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
258
|
- !ruby/object:Gem::Version
|
259
259
|
version: '0'
|
260
260
|
requirements: []
|
261
|
-
rubygems_version: 3.3.
|
261
|
+
rubygems_version: 3.3.23
|
262
262
|
signing_key:
|
263
263
|
specification_version: 4
|
264
264
|
summary: Integrate Solidus with Paypal Commerce Platform
|