solidus_paypal_commerce_platform 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/app/models/solidus_paypal_commerce_platform/payment_method.rb +2 -0
- data/app/models/solidus_paypal_commerce_platform/paypal_order.rb +26 -5
- data/bin/sandbox +1 -1
- data/lib/solidus_paypal_commerce_platform/configuration.rb +3 -3
- data/lib/solidus_paypal_commerce_platform/engine.rb +2 -1
- data/lib/solidus_paypal_commerce_platform/version.rb +1 -1
- data/solidus_paypal_commerce_platform.gemspec +1 -1
- data/spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb +8 -0
- data/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb +33 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0a234ec6a201a2b7e7a4f9e3c65359c70acaea23995134f7de9513a96530fc4
|
4
|
+
data.tar.gz: b94786018f9da41a5e5915db8c87b87c2eaa767580e8739c11ae472fb248d782
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 825f4bcff61bbb9ff666391607dc657383d67b2635454375bc12df1a8bef1c02e2cff334b0474ce53dd9d7e04c4d8885dcc9a85ccb729d31a641ab5b9ccaa84c
|
7
|
+
data.tar.gz: 7589bcb66e13a57e5154227ef9212b209177f1a3f76338c67c852ca837c9df60670e8ce1730153b7121db364034f191170f59d95a863b563663ba47fcfde6b35
|
data/LICENSE
CHANGED
@@ -44,10 +44,19 @@ module SolidusPaypalCommercePlatform
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def name(address)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
if greater_than_2_10?
|
48
|
+
name = ::Spree::Address::Name.new @order.ship_address.name
|
49
|
+
|
50
|
+
{
|
51
|
+
given_name: name.first_name,
|
52
|
+
surname: name.last_name
|
53
|
+
}
|
54
|
+
else
|
55
|
+
{
|
56
|
+
given_name: address.firstname,
|
57
|
+
surname: address.lastname
|
58
|
+
}
|
59
|
+
end
|
51
60
|
end
|
52
61
|
|
53
62
|
def purchase_units(include_shipping_address: true)
|
@@ -63,13 +72,21 @@ module SolidusPaypalCommercePlatform
|
|
63
72
|
def shipping_info
|
64
73
|
{
|
65
74
|
name: {
|
66
|
-
full_name:
|
75
|
+
full_name: full_name,
|
67
76
|
},
|
68
77
|
email_address: @order.email,
|
69
78
|
address: get_address(@order.ship_address)
|
70
79
|
}
|
71
80
|
end
|
72
81
|
|
82
|
+
def full_name
|
83
|
+
if greater_than_2_10?
|
84
|
+
@order.ship_address.name
|
85
|
+
else
|
86
|
+
@order.ship_address.full_name
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
73
90
|
def line_items
|
74
91
|
@order.line_items.map{ |line_item|
|
75
92
|
{
|
@@ -103,5 +120,9 @@ module SolidusPaypalCommercePlatform
|
|
103
120
|
value: amount
|
104
121
|
}
|
105
122
|
end
|
123
|
+
|
124
|
+
def greater_than_2_10?
|
125
|
+
::Spree.solidus_gem_version >= Gem::Version.new('2.11')
|
126
|
+
end
|
106
127
|
end
|
107
128
|
end
|
data/bin/sandbox
CHANGED
@@ -67,7 +67,7 @@ unbundled bundle install --gemfile Gemfile
|
|
67
67
|
|
68
68
|
unbundled bundle exec rake db:drop db:create
|
69
69
|
|
70
|
-
unbundled bundle exec rails generate
|
70
|
+
unbundled bundle exec rails generate solidus:install \
|
71
71
|
--auto-accept \
|
72
72
|
--user_class=Spree::User \
|
73
73
|
--enforce_available_locales=true \
|
@@ -39,7 +39,7 @@ module SolidusPaypalCommercePlatform
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def default_env
|
42
|
-
return ENV['PAYPAL_ENV'] if ENV['PAYPAL_ENV']
|
42
|
+
return ENV['PAYPAL_ENV'] if ENV['PAYPAL_ENV'] # rubocop:disable Rails/EnvironmentVariableAccess
|
43
43
|
|
44
44
|
case Rails.env
|
45
45
|
when 'production'
|
@@ -60,11 +60,11 @@ module SolidusPaypalCommercePlatform
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def partner_id
|
63
|
-
@partner_id ||= ENV['PAYPAL_PARTNER_ID'] || DEFAULT_PARTNER_ID[env.to_sym]
|
63
|
+
@partner_id ||= ENV['PAYPAL_PARTNER_ID'] || DEFAULT_PARTNER_ID[env.to_sym] # rubocop:disable Rails/EnvironmentVariableAccess
|
64
64
|
end
|
65
65
|
|
66
66
|
def partner_client_id
|
67
|
-
@partner_client_id ||= ENV['PAYPAL_PARTNER_CLIENT_ID'] || DEFAULT_PARTNER_CLIENT_ID[env.to_sym]
|
67
|
+
@partner_client_id ||= ENV['PAYPAL_PARTNER_CLIENT_ID'] || DEFAULT_PARTNER_CLIENT_ID[env.to_sym] # rubocop:disable Rails/EnvironmentVariableAccess
|
68
68
|
end
|
69
69
|
|
70
70
|
def partner_code
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'deface'
|
4
|
-
require '
|
4
|
+
require 'solidus_core'
|
5
5
|
require 'solidus_paypal_commerce_platform'
|
6
6
|
require 'solidus_webhooks'
|
7
|
+
require 'solidus_support'
|
7
8
|
|
8
9
|
module SolidusPaypalCommercePlatform
|
9
10
|
class Engine < Rails::Engine
|
@@ -36,5 +36,5 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_dependency 'paypal-checkout-sdk'
|
37
37
|
|
38
38
|
spec.add_development_dependency 'cuprite'
|
39
|
-
spec.add_development_dependency 'solidus_dev_support', '~> 2.
|
39
|
+
spec.add_development_dependency 'solidus_dev_support', '~> 2.5'
|
40
40
|
end
|
@@ -93,6 +93,14 @@ RSpec.describe SolidusPaypalCommercePlatform::PaymentMethod, type: :model do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
+
context 'when checkout_steps does not include "delivery"' do
|
97
|
+
let(:order) { instance_double(Spree::Order, checkout_steps: { "foo" => "bar" }) }
|
98
|
+
|
99
|
+
it 'disables autocommit' do
|
100
|
+
expect(url.query.split("&")).to include("shipping_preference=NO_SHIPPING")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
96
104
|
context 'when messaging is turned on' do
|
97
105
|
let(:order) { instance_double(Spree::Order, checkout_steps: { "foo" => "bar" }) }
|
98
106
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe SolidusPaypalCommercePlatform::PaypalOrder, type: :model do
|
6
|
+
describe '#to_json' do
|
7
|
+
subject(:to_json) { described_class.new(order).to_json('intent') }
|
8
|
+
|
9
|
+
let(:order) { create(:order_ready_to_complete) }
|
10
|
+
|
11
|
+
it { expect { to_json }.not_to raise_error }
|
12
|
+
|
13
|
+
if Spree.solidus_gem_version >= Gem::Version.new('2.11')
|
14
|
+
it 'returns the name of the user' do
|
15
|
+
expect(to_json).to match hash_including(
|
16
|
+
purchase_units: array_including(
|
17
|
+
hash_including(shipping: hash_including(name: { full_name: 'John Von Doe' }))
|
18
|
+
),
|
19
|
+
payer: hash_including(name: { given_name: 'John', surname: 'Von Doe' })
|
20
|
+
)
|
21
|
+
end
|
22
|
+
else
|
23
|
+
it 'returns the name and surname of the user' do
|
24
|
+
expect(to_json).to match hash_including(
|
25
|
+
purchase_units: array_including(
|
26
|
+
hash_including(shipping: hash_including(name: { full_name: 'John' }))
|
27
|
+
),
|
28
|
+
payer: hash_including(name: { given_name: 'John', surname: nil })
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
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.3.
|
4
|
+
version: 0.3.2
|
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: 2021-
|
12
|
+
date: 2021-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: deface
|
@@ -113,14 +113,14 @@ dependencies:
|
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: '2.
|
116
|
+
version: '2.5'
|
117
117
|
type: :development
|
118
118
|
prerelease: false
|
119
119
|
version_requirements: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '2.
|
123
|
+
version: '2.5'
|
124
124
|
description:
|
125
125
|
email: contact@solidus.io
|
126
126
|
executables: []
|
@@ -226,6 +226,7 @@ files:
|
|
226
226
|
- spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb
|
227
227
|
- spec/models/solidus_paypal_commerce_platform/payment_source_spec.rb
|
228
228
|
- spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb
|
229
|
+
- spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb
|
229
230
|
- spec/models/solidus_paypal_commerce_platform/state_guesser_spec.rb
|
230
231
|
- spec/models/solidus_paypal_commerce_platform/wizard_spec.rb
|
231
232
|
- spec/requests/solidus_paypal_commerce_platform/orders_controller_spec.rb
|
@@ -279,6 +280,7 @@ test_files:
|
|
279
280
|
- spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb
|
280
281
|
- spec/models/solidus_paypal_commerce_platform/payment_source_spec.rb
|
281
282
|
- spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb
|
283
|
+
- spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb
|
282
284
|
- spec/models/solidus_paypal_commerce_platform/state_guesser_spec.rb
|
283
285
|
- spec/models/solidus_paypal_commerce_platform/wizard_spec.rb
|
284
286
|
- spec/requests/solidus_paypal_commerce_platform/orders_controller_spec.rb
|