solidus_paypal_commerce_platform 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +4 -0
- data/.rubocop.yml +4 -4
- data/CHANGELOG.md +46 -2
- data/Gemfile +2 -2
- data/README.md +25 -0
- data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js +3 -1
- data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/buttons.js +14 -0
- data/app/controllers/solidus_paypal_commerce_platform/payments_controller.rb +4 -2
- data/app/helpers/solidus_paypal_commerce_platform/button_options_helper.rb +4 -0
- data/app/models/solidus_paypal_commerce_platform/gateway.rb +20 -1
- data/app/models/solidus_paypal_commerce_platform/payment_method.rb +20 -0
- data/app/models/solidus_paypal_commerce_platform/payment_source.rb +11 -0
- data/app/models/solidus_paypal_commerce_platform/wizard.rb +1 -1
- data/bin/rails-engine +1 -1
- data/config/locales/en.yml +34 -1
- data/db/migrate/20211220133406_add_paypal_funding_source_to_paypal_commerce_platform_sources.rb +5 -0
- data/lib/solidus_paypal_commerce_platform/client.rb +3 -3
- data/lib/solidus_paypal_commerce_platform/configuration.rb +3 -3
- data/lib/solidus_paypal_commerce_platform/engine.rb +11 -3
- data/lib/solidus_paypal_commerce_platform/testing_support/factories.rb +2 -1
- data/lib/solidus_paypal_commerce_platform/version.rb +1 -1
- data/lib/views/backend/spree/admin/payments/source_views/_paypal_commerce_platform.html.erb +3 -0
- data/lib/views/frontend/solidus_paypal_commerce_platform/payments/_payment.html.erb +4 -0
- data/lib/views/frontend/spree/checkout/payment/_paypal_commerce_platform.html.erb +17 -3
- data/solidus_paypal_commerce_platform.gemspec +2 -2
- metadata +11 -63
- data/spec/features/backend/new_payment_method_spec.rb +0 -40
- data/spec/features/frontend/cart_spec.rb +0 -46
- data/spec/features/frontend/checkout_spec.rb +0 -89
- data/spec/features/frontend/product_spec.rb +0 -91
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.COMPLETED.v2.json +0 -121
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.PROCESSED.v2.json +0 -121
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v1.json +0 -50
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v2.json +0 -72
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v1.json +0 -50
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v2.json +0 -68
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v1.json +0 -51
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v2.json +0 -63
- data/spec/jobs/solidus_paypal_commerce_platform/webhook_job_spec.rb +0 -44
- data/spec/lib/solidus_paypal_commerce_platform/client_spec.rb +0 -21
- data/spec/lib/solidus_paypal_commerce_platform/configuration_spec.rb +0 -91
- data/spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb +0 -129
- data/spec/models/solidus_paypal_commerce_platform/payment_source_spec.rb +0 -62
- data/spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb +0 -67
- data/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb +0 -33
- data/spec/models/solidus_paypal_commerce_platform/state_guesser_spec.rb +0 -38
- data/spec/models/solidus_paypal_commerce_platform/wizard_spec.rb +0 -9
- data/spec/requests/solidus_paypal_commerce_platform/orders_controller_spec.rb +0 -36
- data/spec/requests/solidus_paypal_commerce_platform/shipping_rates_controller_spec.rb +0 -44
- data/spec/requests/solidus_paypal_commerce_platform/wizard_controller_spec.rb +0 -44
- data/spec/spec_helper.rb +0 -32
- data/spec/support/capybara.rb +0 -11
- data/spec/support/paypal_sdk_script_tag_helper.rb +0 -13
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Denny
|
8
8
|
- Elia Schito
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: deface
|
@@ -121,7 +121,7 @@ dependencies:
|
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '2.5'
|
124
|
-
description:
|
124
|
+
description:
|
125
125
|
email: contact@solidus.io
|
126
126
|
executables: []
|
127
127
|
extensions: []
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- config/locales/en.yml
|
187
187
|
- config/routes.rb
|
188
188
|
- db/migrate/20200521190038_add_paypal_commerce_platform_sources.rb
|
189
|
+
- db/migrate/20211220133406_add_paypal_funding_source_to_paypal_commerce_platform_sources.rb
|
189
190
|
- lib/generators/solidus_paypal_commerce_platform/install/install_generator.rb
|
190
191
|
- lib/generators/solidus_paypal_commerce_platform/install/templates/initializer.rb
|
191
192
|
- lib/solidus_paypal_commerce_platform.rb
|
@@ -208,33 +209,6 @@ files:
|
|
208
209
|
- lib/views/frontend/spree/orders/payment/_paypal_commerce_platform.html.erb
|
209
210
|
- lib/views/frontend/spree/products/payment/_paypal_commerce_platform.html.erb
|
210
211
|
- solidus_paypal_commerce_platform.gemspec
|
211
|
-
- spec/features/backend/new_payment_method_spec.rb
|
212
|
-
- spec/features/frontend/cart_spec.rb
|
213
|
-
- spec/features/frontend/checkout_spec.rb
|
214
|
-
- spec/features/frontend/product_spec.rb
|
215
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.COMPLETED.v2.json
|
216
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.PROCESSED.v2.json
|
217
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v1.json
|
218
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v2.json
|
219
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v1.json
|
220
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v2.json
|
221
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v1.json
|
222
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v2.json
|
223
|
-
- spec/jobs/solidus_paypal_commerce_platform/webhook_job_spec.rb
|
224
|
-
- spec/lib/solidus_paypal_commerce_platform/client_spec.rb
|
225
|
-
- spec/lib/solidus_paypal_commerce_platform/configuration_spec.rb
|
226
|
-
- spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb
|
227
|
-
- spec/models/solidus_paypal_commerce_platform/payment_source_spec.rb
|
228
|
-
- spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb
|
229
|
-
- spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb
|
230
|
-
- spec/models/solidus_paypal_commerce_platform/state_guesser_spec.rb
|
231
|
-
- spec/models/solidus_paypal_commerce_platform/wizard_spec.rb
|
232
|
-
- spec/requests/solidus_paypal_commerce_platform/orders_controller_spec.rb
|
233
|
-
- spec/requests/solidus_paypal_commerce_platform/shipping_rates_controller_spec.rb
|
234
|
-
- spec/requests/solidus_paypal_commerce_platform/wizard_controller_spec.rb
|
235
|
-
- spec/spec_helper.rb
|
236
|
-
- spec/support/capybara.rb
|
237
|
-
- spec/support/paypal_sdk_script_tag_helper.rb
|
238
212
|
homepage: https://github.com/solidusio-contrib/solidus_paypal_commerce_platform
|
239
213
|
licenses:
|
240
214
|
- BSD-3-Clause
|
@@ -242,13 +216,14 @@ metadata:
|
|
242
216
|
homepage_uri: https://github.com/solidusio-contrib/solidus_paypal_commerce_platform
|
243
217
|
source_code_uri: https://github.com/solidusio-contrib/solidus_paypal_commerce_platform
|
244
218
|
changelog_uri: https://github.com/solidusio-contrib/solidus_paypal_commerce_platform/releases
|
245
|
-
|
219
|
+
rubygems_mfa_required: 'true'
|
220
|
+
post_install_message:
|
246
221
|
rdoc_options: []
|
247
222
|
require_paths:
|
248
223
|
- lib
|
249
224
|
required_ruby_version: !ruby/object:Gem::Requirement
|
250
225
|
requirements:
|
251
|
-
- - "
|
226
|
+
- - "~>"
|
252
227
|
- !ruby/object:Gem::Version
|
253
228
|
version: '2.5'
|
254
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -257,35 +232,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
232
|
- !ruby/object:Gem::Version
|
258
233
|
version: '0'
|
259
234
|
requirements: []
|
260
|
-
rubygems_version: 3.1.
|
261
|
-
signing_key:
|
235
|
+
rubygems_version: 3.1.6
|
236
|
+
signing_key:
|
262
237
|
specification_version: 4
|
263
238
|
summary: Integrate Solidus with Paypal Commerce Platform
|
264
|
-
test_files:
|
265
|
-
- spec/features/backend/new_payment_method_spec.rb
|
266
|
-
- spec/features/frontend/cart_spec.rb
|
267
|
-
- spec/features/frontend/checkout_spec.rb
|
268
|
-
- spec/features/frontend/product_spec.rb
|
269
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.COMPLETED.v2.json
|
270
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.PROCESSED.v2.json
|
271
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v1.json
|
272
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v2.json
|
273
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v1.json
|
274
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v2.json
|
275
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v1.json
|
276
|
-
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v2.json
|
277
|
-
- spec/jobs/solidus_paypal_commerce_platform/webhook_job_spec.rb
|
278
|
-
- spec/lib/solidus_paypal_commerce_platform/client_spec.rb
|
279
|
-
- spec/lib/solidus_paypal_commerce_platform/configuration_spec.rb
|
280
|
-
- spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb
|
281
|
-
- spec/models/solidus_paypal_commerce_platform/payment_source_spec.rb
|
282
|
-
- spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb
|
283
|
-
- spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb
|
284
|
-
- spec/models/solidus_paypal_commerce_platform/state_guesser_spec.rb
|
285
|
-
- spec/models/solidus_paypal_commerce_platform/wizard_spec.rb
|
286
|
-
- spec/requests/solidus_paypal_commerce_platform/orders_controller_spec.rb
|
287
|
-
- spec/requests/solidus_paypal_commerce_platform/shipping_rates_controller_spec.rb
|
288
|
-
- spec/requests/solidus_paypal_commerce_platform/wizard_controller_spec.rb
|
289
|
-
- spec/spec_helper.rb
|
290
|
-
- spec/support/capybara.rb
|
291
|
-
- spec/support/paypal_sdk_script_tag_helper.rb
|
239
|
+
test_files: []
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe "creating a new payment" do
|
4
|
-
stub_authorization!
|
5
|
-
|
6
|
-
it "displays PayPal Commerce Platform as an option" do
|
7
|
-
visit "/admin/payment_methods/new"
|
8
|
-
expect(page).to have_select('payment_method_type', options: [
|
9
|
-
"PayPal Commerce Platform",
|
10
|
-
"Bogus Credit Card Payments",
|
11
|
-
"Check Payments",
|
12
|
-
"Simple Bogus Credit Card Payments",
|
13
|
-
"Store Credit Payments",
|
14
|
-
])
|
15
|
-
select "PayPal Commerce Platform", from: 'payment_method_type'
|
16
|
-
fill_in "Name", with: "PayPal!"
|
17
|
-
click_on "Create"
|
18
|
-
expect(page).to have_text("Payment Method has been successfully created!")
|
19
|
-
|
20
|
-
fill_in "Client", with: "cli-123"
|
21
|
-
fill_in "Client secret", with: "cli-sec-123"
|
22
|
-
click_on "Update"
|
23
|
-
expect(page).to have_text("Payment Method has been successfully updated!")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "displays the onboarding button", :js do
|
27
|
-
visit "/admin/payment_methods"
|
28
|
-
|
29
|
-
# main_window = current_window
|
30
|
-
|
31
|
-
within ".setup-wizard" do
|
32
|
-
paypal_button = page.find("button")
|
33
|
-
expect(paypal_button.text).to eq("Setup PayPal Commerce Platform")
|
34
|
-
# TODO: make this more complete
|
35
|
-
# paypal_window = window_opened_by do
|
36
|
-
# paypal_button.click
|
37
|
-
# end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe "Cart page" do
|
4
|
-
describe "paypal payment method" do
|
5
|
-
let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:address) }
|
6
|
-
let(:paypal_payment_method) { create(:paypal_payment_method) }
|
7
|
-
|
8
|
-
before do
|
9
|
-
user = create(:user)
|
10
|
-
order.user = user
|
11
|
-
|
12
|
-
paypal_payment_method
|
13
|
-
allow_any_instance_of(Spree::OrdersController).to receive_messages(
|
14
|
-
current_order: order,
|
15
|
-
try_spree_current_user: user
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
context "when generating a script tag" do
|
20
|
-
it "generates a url with the correct credentials attached" do
|
21
|
-
visit '/cart'
|
22
|
-
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
23
|
-
end
|
24
|
-
|
25
|
-
it "generates a partner_id attribute with the correct partner code attached" do
|
26
|
-
visit '/cart'
|
27
|
-
expect(js_sdk_script_partner_id).to eq("Solidus_PCP_SP")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "generates a URL with the correct currency" do
|
31
|
-
allow(order).to receive(:currency).and_return "EUR"
|
32
|
-
visit '/cart'
|
33
|
-
expect(js_sdk_script_query).to include("currency=EUR")
|
34
|
-
end
|
35
|
-
|
36
|
-
context "when auto-capture is set to true" do
|
37
|
-
it "generates a url with intent capture" do
|
38
|
-
paypal_payment_method.update(auto_capture: true)
|
39
|
-
visit '/cart'
|
40
|
-
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
41
|
-
expect(js_sdk_script_query).to include("intent=capture")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe "Checkout" do
|
4
|
-
describe "paypal payment method" do
|
5
|
-
let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:payment) }
|
6
|
-
let(:paypal_payment_method) { create(:paypal_payment_method) }
|
7
|
-
let(:failed_response) { OpenStruct.new(status_code: 500) }
|
8
|
-
|
9
|
-
before do
|
10
|
-
user = create(:user)
|
11
|
-
order.user = user
|
12
|
-
order.recalculate
|
13
|
-
|
14
|
-
paypal_payment_method
|
15
|
-
allow_any_instance_of(Spree::CheckoutController).to receive_messages(
|
16
|
-
current_order: order, try_spree_current_user: user
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
context "when generating a script tag" do
|
21
|
-
it "generates a url with the correct credentials attached" do
|
22
|
-
visit '/checkout/payment'
|
23
|
-
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "generates a partner_id attribute with the correct partner code attached" do
|
27
|
-
visit '/checkout/payment'
|
28
|
-
expect(js_sdk_script_partner_id).to eq("Solidus_PCP_SP")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "generates a URL with the correct currency" do
|
32
|
-
allow(order).to receive(:currency).and_return "EUR"
|
33
|
-
visit '/checkout/payment'
|
34
|
-
expect(js_sdk_script_query).to include("currency=EUR")
|
35
|
-
end
|
36
|
-
|
37
|
-
context "when auto-capture is set to true" do
|
38
|
-
it "generates a url with intent capture" do
|
39
|
-
paypal_payment_method.update(auto_capture: true)
|
40
|
-
visit '/checkout/payment'
|
41
|
-
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
42
|
-
expect(js_sdk_script_query).to include("intent=capture")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context "when no payment has been made" do
|
48
|
-
it "fails to process" do
|
49
|
-
visit '/checkout/payment'
|
50
|
-
choose(option: paypal_payment_method.id)
|
51
|
-
click_button("Save and Continue")
|
52
|
-
expect(page).to have_content("Payments source PayPal order can't be blank")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "when a payment has been made" do
|
57
|
-
it "proceeds to the next step" do
|
58
|
-
visit '/checkout/payment'
|
59
|
-
choose(option: paypal_payment_method.id)
|
60
|
-
find(:xpath, "//input[@id='payments_source_paypal_order_id']", visible: false).set SecureRandom.hex(8)
|
61
|
-
click_button("Save and Continue")
|
62
|
-
expect(page).to have_css(".current", text: "Confirm")
|
63
|
-
end
|
64
|
-
|
65
|
-
it "records the paypal email address" do
|
66
|
-
visit '/checkout/payment'
|
67
|
-
choose(option: paypal_payment_method.id)
|
68
|
-
find(:xpath, "//input[@id='payments_source_paypal_order_id']", visible: false).set SecureRandom.hex(8)
|
69
|
-
find(:xpath, "//input[@id='payments_source_paypal_email']", visible: false).set "fake@email.com"
|
70
|
-
click_button("Save and Continue")
|
71
|
-
expect(Spree::Payment.last.source.paypal_email).to eq "fake@email.com"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "when a payment fails" do
|
76
|
-
before { allow_any_instance_of(PayPal::PayPalHttpClient).to receive(:execute) { failed_response } }
|
77
|
-
|
78
|
-
it "redirects the user back to the payments page" do
|
79
|
-
visit '/checkout/payment'
|
80
|
-
choose(option: paypal_payment_method.id)
|
81
|
-
find(:xpath, "//input[@id='payments_source_paypal_order_id']", visible: false).set SecureRandom.hex(8)
|
82
|
-
click_button("Save and Continue")
|
83
|
-
click_button("Place Order")
|
84
|
-
expect(page).to have_current_path("/checkout/payment")
|
85
|
-
expect(page).to have_content("Your payment was declined")
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe "Product page", js: true do
|
4
|
-
describe "paypal button" do
|
5
|
-
let(:paypal_payment_method) { create(:paypal_payment_method) }
|
6
|
-
let(:product) { create(:product, variants: [variant, variant_two]) }
|
7
|
-
let(:store) { create(:store) }
|
8
|
-
let(:variant) { create(:variant) }
|
9
|
-
let(:variant_two) { create(:variant) }
|
10
|
-
|
11
|
-
before do
|
12
|
-
paypal_payment_method
|
13
|
-
end
|
14
|
-
|
15
|
-
context "when generating a script tag" do
|
16
|
-
it "generates a url with the correct credentials attached" do
|
17
|
-
visit "/products/#{product.slug}"
|
18
|
-
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
19
|
-
end
|
20
|
-
|
21
|
-
it "generates a partner_id attribute with the correct partner code attached" do
|
22
|
-
visit "/products/#{product.slug}"
|
23
|
-
expect(js_sdk_script_partner_id).to eq("Solidus_PCP_SP")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "generates a URL with the correct currency" do
|
27
|
-
allow_any_instance_of(SolidusPaypalCommercePlatform::PricingOptions).to receive(:currency).and_return "EUR"
|
28
|
-
visit "/products/#{product.slug}"
|
29
|
-
expect(js_sdk_script_query).to include("currency=EUR")
|
30
|
-
end
|
31
|
-
|
32
|
-
context "when auto-capture is set to true" do
|
33
|
-
it "generates a url with intent capture" do
|
34
|
-
paypal_payment_method.update(auto_capture: true)
|
35
|
-
visit "/products/#{product.slug}"
|
36
|
-
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
37
|
-
expect(js_sdk_script_query).to include("intent=capture")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "order creation" do
|
43
|
-
before do
|
44
|
-
allow_any_instance_of(Spree::Core::ControllerHelpers::Store).to receive(:current_store) { store }
|
45
|
-
visit "/products/#{product.slug}"
|
46
|
-
|
47
|
-
# Stubbing out paypal methods since their JS doesn't load in correctly on tests
|
48
|
-
page.execute_script("paypal = {}")
|
49
|
-
page.execute_script("paypal.render = function(){}")
|
50
|
-
page.execute_script("paypal.Buttons = function(){return paypal}")
|
51
|
-
|
52
|
-
# Waiting until the paypal button becomes available, because the SPCP namespace
|
53
|
-
# isn't immediately available
|
54
|
-
page.find("#paypal-button-container")
|
55
|
-
end
|
56
|
-
|
57
|
-
it "creates an order successfully" do
|
58
|
-
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
59
|
-
page.driver.wait_for_network_idle
|
60
|
-
|
61
|
-
expect(Spree::Order.last).not_to be nil
|
62
|
-
end
|
63
|
-
|
64
|
-
it "sets the Spree number and token variables" do
|
65
|
-
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
66
|
-
page.driver.wait_for_network_idle
|
67
|
-
|
68
|
-
expect(page.evaluate_script("Spree.current_order_id")).to eq Spree::Order.last.number
|
69
|
-
expect(page.evaluate_script("Spree.current_order_token")).to eq Spree::Order.last.guest_token
|
70
|
-
end
|
71
|
-
|
72
|
-
it "uses the specified quantity" do
|
73
|
-
quantity = 12
|
74
|
-
fill_in('quantity', with: quantity)
|
75
|
-
|
76
|
-
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
77
|
-
page.driver.wait_for_network_idle
|
78
|
-
|
79
|
-
expect(Spree::Order.last.line_items.first.quantity).to eq quantity
|
80
|
-
end
|
81
|
-
|
82
|
-
it "uses the selected variant" do
|
83
|
-
page.choose("variant_id_#{variant_two.id}")
|
84
|
-
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
85
|
-
page.driver.wait_for_network_idle
|
86
|
-
|
87
|
-
expect(Spree::Order.last.line_items.first.variant_id).to eq variant_two.id
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"id": "WH-COC11055RA711503B-4YM959094A144403T",
|
3
|
-
"create_time": "2018-04-16T21:21:49.000Z",
|
4
|
-
"resource_type": "checkout-order",
|
5
|
-
"event_type": "CHECKOUT.ORDER.COMPLETED",
|
6
|
-
"summary": "Checkout Order Completed",
|
7
|
-
"resource": {
|
8
|
-
"update_time": "2018-04-01T21:20:49Z",
|
9
|
-
"create_time": "2018-04-01T21:18:49Z",
|
10
|
-
"purchase_units": [
|
11
|
-
{
|
12
|
-
"reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
|
13
|
-
"amount": {
|
14
|
-
"currency_code": "USD",
|
15
|
-
"value": "100.00"
|
16
|
-
},
|
17
|
-
"payee": {
|
18
|
-
"email_address": "seller@example.com"
|
19
|
-
},
|
20
|
-
"shipping": {
|
21
|
-
"method": "United States Postal Service",
|
22
|
-
"address": {
|
23
|
-
"address_line_1": "2211 N First Street",
|
24
|
-
"address_line_2": "Building 17",
|
25
|
-
"admin_area_2": "San Jose",
|
26
|
-
"admin_area_1": "CA",
|
27
|
-
"postal_code": "95131",
|
28
|
-
"country_code": "US"
|
29
|
-
}
|
30
|
-
},
|
31
|
-
"payments": {
|
32
|
-
"captures": [
|
33
|
-
{
|
34
|
-
"id": "3C679366HH908993F",
|
35
|
-
"status": "COMPLETED",
|
36
|
-
"amount": {
|
37
|
-
"currency_code": "USD",
|
38
|
-
"value": "100.00"
|
39
|
-
},
|
40
|
-
"seller_protection": {
|
41
|
-
"status": "ELIGIBLE",
|
42
|
-
"dispute_categories": [
|
43
|
-
"ITEM_NOT_RECEIVED",
|
44
|
-
"UNAUTHORIZED_TRANSACTION"
|
45
|
-
]
|
46
|
-
},
|
47
|
-
"final_capture": true,
|
48
|
-
"seller_receivable_breakdown": {
|
49
|
-
"gross_amount": {
|
50
|
-
"currency_code": "USD",
|
51
|
-
"value": "100.00"
|
52
|
-
},
|
53
|
-
"paypal_fee": {
|
54
|
-
"currency_code": "USD",
|
55
|
-
"value": "3.00"
|
56
|
-
},
|
57
|
-
"net_amount": {
|
58
|
-
"currency_code": "USD",
|
59
|
-
"value": "97.00"
|
60
|
-
}
|
61
|
-
},
|
62
|
-
"create_time": "2018-04-01T21:20:49Z",
|
63
|
-
"update_time": "2018-04-01T21:20:49Z",
|
64
|
-
"links": [
|
65
|
-
{
|
66
|
-
"href": "https://api.paypal.com/v2/payments/captures/3C679366HH908993F",
|
67
|
-
"rel": "self",
|
68
|
-
"method": "GET"
|
69
|
-
},
|
70
|
-
{
|
71
|
-
"href": "https://api.paypal.com/v2/payments/captures/3C679366HH908993F/refund",
|
72
|
-
"rel": "refund",
|
73
|
-
"method": "POST"
|
74
|
-
}
|
75
|
-
]
|
76
|
-
}
|
77
|
-
]
|
78
|
-
}
|
79
|
-
}
|
80
|
-
],
|
81
|
-
"links": [
|
82
|
-
{
|
83
|
-
"href": "https://api.paypal.com/v2/checkout/orders/5O190127TN364715T",
|
84
|
-
"rel": "self",
|
85
|
-
"method": "GET"
|
86
|
-
}
|
87
|
-
],
|
88
|
-
"id": "5O190127TN364715T",
|
89
|
-
"gross_amount": {
|
90
|
-
"currency_code": "USD",
|
91
|
-
"value": "100.00"
|
92
|
-
},
|
93
|
-
"intent": "CAPTURE",
|
94
|
-
"payer": {
|
95
|
-
"name": {
|
96
|
-
"given_name": "John",
|
97
|
-
"surname": "Doe"
|
98
|
-
},
|
99
|
-
"email_address": "buyer@example.com",
|
100
|
-
"payer_id": "QYR5Z8XDVJNXQ"
|
101
|
-
},
|
102
|
-
"status": "COMPLETED"
|
103
|
-
},
|
104
|
-
"links": [
|
105
|
-
{
|
106
|
-
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-COC11055RA711503B-4YM959094A144403T",
|
107
|
-
"rel": "self",
|
108
|
-
"method": "GET",
|
109
|
-
"encType": "application/json"
|
110
|
-
},
|
111
|
-
{
|
112
|
-
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-COC11055RA711503B-4YM959094A144403T/resend",
|
113
|
-
"rel": "resend",
|
114
|
-
"method": "POST",
|
115
|
-
"encType": "application/json"
|
116
|
-
}
|
117
|
-
],
|
118
|
-
"event_version": "1.0",
|
119
|
-
"zts": 1494957670,
|
120
|
-
"resource_version": "2.0"
|
121
|
-
}
|
@@ -1,121 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"id": "WH-COC11055RA711503B-4YM959094A144403T",
|
3
|
-
"create_time": "2018-04-16T21:21:49.000Z",
|
4
|
-
"resource_type": "checkout-order",
|
5
|
-
"event_type": "CHECKOUT.ORDER.COMPLETED",
|
6
|
-
"summary": "Checkout Order Completed",
|
7
|
-
"resource": {
|
8
|
-
"update_time": "2018-04-01T21:20:49Z",
|
9
|
-
"create_time": "2018-04-01T21:18:49Z",
|
10
|
-
"purchase_units": [
|
11
|
-
{
|
12
|
-
"reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
|
13
|
-
"amount": {
|
14
|
-
"currency_code": "USD",
|
15
|
-
"value": "100.00"
|
16
|
-
},
|
17
|
-
"payee": {
|
18
|
-
"email_address": "seller@example.com"
|
19
|
-
},
|
20
|
-
"shipping": {
|
21
|
-
"method": "United States Postal Service",
|
22
|
-
"address": {
|
23
|
-
"address_line_1": "2211 N First Street",
|
24
|
-
"address_line_2": "Building 17",
|
25
|
-
"admin_area_2": "San Jose",
|
26
|
-
"admin_area_1": "CA",
|
27
|
-
"postal_code": "95131",
|
28
|
-
"country_code": "US"
|
29
|
-
}
|
30
|
-
},
|
31
|
-
"payments": {
|
32
|
-
"captures": [
|
33
|
-
{
|
34
|
-
"id": "3C679366HH908993F",
|
35
|
-
"status": "COMPLETED",
|
36
|
-
"amount": {
|
37
|
-
"currency_code": "USD",
|
38
|
-
"value": "100.00"
|
39
|
-
},
|
40
|
-
"seller_protection": {
|
41
|
-
"status": "ELIGIBLE",
|
42
|
-
"dispute_categories": [
|
43
|
-
"ITEM_NOT_RECEIVED",
|
44
|
-
"UNAUTHORIZED_TRANSACTION"
|
45
|
-
]
|
46
|
-
},
|
47
|
-
"final_capture": true,
|
48
|
-
"seller_receivable_breakdown": {
|
49
|
-
"gross_amount": {
|
50
|
-
"currency_code": "USD",
|
51
|
-
"value": "100.00"
|
52
|
-
},
|
53
|
-
"paypal_fee": {
|
54
|
-
"currency_code": "USD",
|
55
|
-
"value": "3.00"
|
56
|
-
},
|
57
|
-
"net_amount": {
|
58
|
-
"currency_code": "USD",
|
59
|
-
"value": "97.00"
|
60
|
-
}
|
61
|
-
},
|
62
|
-
"create_time": "2018-04-01T21:20:49Z",
|
63
|
-
"update_time": "2018-04-01T21:20:49Z",
|
64
|
-
"links": [
|
65
|
-
{
|
66
|
-
"href": "https://api.paypal.com/v2/payments/captures/3C679366HH908993F",
|
67
|
-
"rel": "self",
|
68
|
-
"method": "GET"
|
69
|
-
},
|
70
|
-
{
|
71
|
-
"href": "https://api.paypal.com/v2/payments/captures/3C679366HH908993F/refund",
|
72
|
-
"rel": "refund",
|
73
|
-
"method": "POST"
|
74
|
-
}
|
75
|
-
]
|
76
|
-
}
|
77
|
-
]
|
78
|
-
}
|
79
|
-
}
|
80
|
-
],
|
81
|
-
"links": [
|
82
|
-
{
|
83
|
-
"href": "https://api.paypal.com/v2/checkout/orders/5O190127TN364715T",
|
84
|
-
"rel": "self",
|
85
|
-
"method": "GET"
|
86
|
-
}
|
87
|
-
],
|
88
|
-
"id": "5O190127TN364715T",
|
89
|
-
"gross_amount": {
|
90
|
-
"currency_code": "USD",
|
91
|
-
"value": "100.00"
|
92
|
-
},
|
93
|
-
"intent": "CAPTURE",
|
94
|
-
"payer": {
|
95
|
-
"name": {
|
96
|
-
"given_name": "John",
|
97
|
-
"surname": "Doe"
|
98
|
-
},
|
99
|
-
"email_address": "buyer@example.com",
|
100
|
-
"payer_id": "QYR5Z8XDVJNXQ"
|
101
|
-
},
|
102
|
-
"status": "COMPLETED"
|
103
|
-
},
|
104
|
-
"links": [
|
105
|
-
{
|
106
|
-
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-COC11055RA711503B-4YM959094A144403T",
|
107
|
-
"rel": "self",
|
108
|
-
"method": "GET",
|
109
|
-
"encType": "application/json"
|
110
|
-
},
|
111
|
-
{
|
112
|
-
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-COC11055RA711503B-4YM959094A144403T/resend",
|
113
|
-
"rel": "resend",
|
114
|
-
"method": "POST",
|
115
|
-
"encType": "application/json"
|
116
|
-
}
|
117
|
-
],
|
118
|
-
"event_version": "1.0",
|
119
|
-
"zts": 1494957670,
|
120
|
-
"resource_version": "2.0"
|
121
|
-
}
|