solidus_paypal_commerce_platform 0.7.1 → 1.0.0.beta1
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 +21 -9
- data/.gem_release.yml +1 -1
- data/.gitignore +1 -0
- data/.rspec +0 -1
- data/.rubocop.yml +3 -2
- data/CHANGELOG.md +270 -1
- data/Gemfile +0 -41
- data/README.md +10 -14
- data/Rakefile +6 -2
- data/app/models/solidus_paypal_commerce_platform/payment_method.rb +1 -18
- data/bin/dummy-app +37 -0
- data/bin/rails-dummy-app +17 -0
- data/bin/rspec +11 -0
- data/bin/sandbox +3 -8
- data/config/locales/en.yml +0 -1
- data/lib/generators/solidus_paypal_commerce_platform/install/install_generator.rb +35 -21
- data/lib/generators/solidus_paypal_commerce_platform/install/templates/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js +272 -0
- data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform.js +7 -0
- data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/paypal_orders_controller.rb +1 -1
- data/lib/{views/frontend/spree/checkout → generators/solidus_paypal_commerce_platform/install/templates/app/views/checkouts}/payment/_paypal_commerce_platform.html.erb +5 -4
- data/lib/{views/frontend/spree → generators/solidus_paypal_commerce_platform/install/templates/app/views}/orders/payment/_paypal_commerce_platform.html.erb +4 -3
- data/lib/{views/frontend/spree → generators/solidus_paypal_commerce_platform/install/templates/app/views}/products/payment/_paypal_commerce_platform.html.erb +1 -1
- data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/shared/_javascript_sdk_tag.html.erb +4 -2
- data/lib/solidus_paypal_commerce_platform/version.rb +1 -1
- data/solidus_paypal_commerce_platform.gemspec +2 -3
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.COMPLETED.v2.json +121 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.PROCESSED.v2.json +121 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v1.json +50 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v2.json +72 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v1.json +50 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v2.json +68 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v1.json +51 -0
- data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v2.json +63 -0
- data/spec/jobs/solidus_paypal_commerce_platform/webhook_job_spec.rb +44 -0
- data/spec/lib/solidus_paypal_commerce_platform/client_spec.rb +21 -0
- data/spec/lib/solidus_paypal_commerce_platform/configuration_spec.rb +91 -0
- data/spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb +200 -0
- data/spec/models/solidus_paypal_commerce_platform/payment_source_spec.rb +119 -0
- data/spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb +67 -0
- data/spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb +80 -0
- data/spec/models/solidus_paypal_commerce_platform/state_guesser_spec.rb +38 -0
- data/spec/models/solidus_paypal_commerce_platform/wizard_spec.rb +9 -0
- data/spec/requests/solidus_paypal_commerce_platform/orders_controller_spec.rb +36 -0
- data/spec/requests/solidus_paypal_commerce_platform/shipping_rates_controller_spec.rb +44 -0
- data/spec/requests/solidus_paypal_commerce_platform/wizard_controller_spec.rb +59 -0
- data/spec/solidus_paypal_commerce_platform_spec_helper.rb +5 -0
- data/spec/support/solidus_paypal_commerce_platform/factories.rb +5 -0
- data/spec/support/solidus_paypal_commerce_platform/paypal_sdk_script_tag_helper.rb +13 -0
- data/spec/system/backend/new_payment_method_spec.rb +40 -0
- data/spec/system/frontend/cart_spec.rb +53 -0
- data/spec/system/frontend/checkout_spec.rb +104 -0
- data/spec/system/frontend/product_spec.rb +98 -0
- metadata +54 -44
- data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js +0 -206
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/buttons.js +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/namespace.js +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/assets/stylesheets/spree/frontend/solidus_paypal_commerce_platform.css +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/orders_controller.rb +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/payments_controller.rb +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/shipping_rates_controller.rb +0 -0
- /data/{app → lib/generators/solidus_paypal_commerce_platform/install/templates/app}/controllers/solidus_paypal_commerce_platform/wizard_controller.rb +0 -0
- /data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/cart/_cart_buttons.html.erb +0 -0
- /data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/payments/_payment.html.erb +0 -0
- /data/lib/{views/frontend → generators/solidus_paypal_commerce_platform/install/templates/app/views}/solidus_paypal_commerce_platform/product/_product_buttons.html.erb +0 -0
- /data/lib/generators/solidus_paypal_commerce_platform/install/templates/{initializer.rb → config/initializers/solidus_paypal_commerce_platform.rb} +0 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'solidus_paypal_commerce_platform_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
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'solidus_paypal_commerce_platform_spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe "Cart page" do
|
4
|
+
describe "paypal payment method", :skip 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
|
+
visit '/'
|
12
|
+
click_link 'Login'
|
13
|
+
|
14
|
+
fill_in 'spree_user[email]', with: user.email
|
15
|
+
fill_in 'spree_user[password]', with: 'secret'
|
16
|
+
click_button 'Login'
|
17
|
+
|
18
|
+
paypal_payment_method
|
19
|
+
allow_any_instance_of(OrdersController).to receive_messages(
|
20
|
+
current_order: order,
|
21
|
+
try_spree_current_user: user
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when generating a script tag" do
|
26
|
+
it "generates a url with the correct credentials attached" do
|
27
|
+
visit '/cart/edit'
|
28
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "generates a partner_id attribute with the correct partner code attached" do
|
32
|
+
visit '/cart/edit'
|
33
|
+
expect(js_sdk_script_partner_id).to eq("Solidus_PCP_SP")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "generates a URL with the correct currency" do
|
37
|
+
order.update currency: "EUR"
|
38
|
+
visit '/cart/edit'
|
39
|
+
expect(js_sdk_script_query).to include("currency=EUR")
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when auto-capture is set to true" do
|
43
|
+
it "generates a url with intent capture" do
|
44
|
+
paypal_payment_method.update(auto_capture: true)
|
45
|
+
visit '/cart/edit'
|
46
|
+
|
47
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
48
|
+
expect(js_sdk_script_query).to include("intent=capture")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'solidus_paypal_commerce_platform_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) { double('response', status_code: 500) } # rubocop:disable RSpec/VerifiedDoubles
|
8
|
+
|
9
|
+
before do
|
10
|
+
user = create(:user)
|
11
|
+
visit '/'
|
12
|
+
click_link 'Login'
|
13
|
+
fill_in 'spree_user[email]', with: user.email
|
14
|
+
fill_in 'spree_user[password]', with: 'secret'
|
15
|
+
click_button 'Login'
|
16
|
+
order.user = user
|
17
|
+
order.recalculate
|
18
|
+
|
19
|
+
paypal_payment_method
|
20
|
+
allow_any_instance_of(CheckoutsController).to receive_messages(
|
21
|
+
current_order: order, try_spree_current_user: user
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when generating a script tag" do
|
26
|
+
it "generates a url with the correct credentials attached" do
|
27
|
+
visit '/checkout/payment'
|
28
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "generates a partner_id attribute with the correct partner code attached" do
|
32
|
+
visit '/checkout/payment'
|
33
|
+
expect(js_sdk_script_partner_id).to eq("Solidus_PCP_SP")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "generates a URL with the correct currency" do
|
37
|
+
allow(order).to receive(:currency).and_return "EUR"
|
38
|
+
visit '/checkout/payment'
|
39
|
+
expect(js_sdk_script_query).to include("currency=EUR")
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when auto-capture is set to true" do
|
43
|
+
it "generates a url with intent capture" do
|
44
|
+
paypal_payment_method.update(auto_capture: true)
|
45
|
+
visit '/checkout/payment'
|
46
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
47
|
+
expect(js_sdk_script_query).to include("intent=capture")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when no payment has been made" do
|
53
|
+
it "fails to process" do
|
54
|
+
visit '/checkout/payment'
|
55
|
+
choose(option: paypal_payment_method.id)
|
56
|
+
click_button("Save and Continue")
|
57
|
+
expect(page).to have_content("Payments source PayPal order can't be blank")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "when a payment has been made" do
|
62
|
+
it "proceeds to the next step" do
|
63
|
+
visit '/checkout/payment'
|
64
|
+
choose(option: paypal_payment_method.id)
|
65
|
+
find(:xpath, "//input[@id='payments_source_paypal_order_id']", visible: false).set SecureRandom.hex(8)
|
66
|
+
click_button("Save and Continue")
|
67
|
+
expect(page).to have_css(".current", text: "Confirm")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "records the paypal email address" do
|
71
|
+
visit '/checkout/payment'
|
72
|
+
choose(option: paypal_payment_method.id)
|
73
|
+
find(:xpath, "//input[@id='payments_source_paypal_order_id']", visible: false).set SecureRandom.hex(8)
|
74
|
+
find(:xpath, "//input[@id='payments_source_paypal_email']", visible: false).set "fake@email.com"
|
75
|
+
click_button("Save and Continue")
|
76
|
+
expect(Spree::Payment.last.source.paypal_email).to eq "fake@email.com"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "records the paypal funding source" do
|
80
|
+
visit '/checkout/payment'
|
81
|
+
choose(option: paypal_payment_method.id)
|
82
|
+
find(:xpath, "//input[@id='payments_source_paypal_order_id']", visible: false).set SecureRandom.hex(8)
|
83
|
+
find(:xpath, "//input[@id='payments_source_paypal_email']", visible: false).set "fake@email.com"
|
84
|
+
find(:xpath, "//input[@id='payments_source_paypal_funding_source']", visible: false).set "venmo"
|
85
|
+
click_button("Save and Continue")
|
86
|
+
expect(Spree::Payment.last.source.paypal_funding_source).to eq "venmo"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "when a payment fails" do
|
91
|
+
before { allow_any_instance_of(PayPal::PayPalHttpClient).to receive(:execute) { failed_response } }
|
92
|
+
|
93
|
+
it "redirects the user back to the payments page" do
|
94
|
+
visit '/checkout/payment'
|
95
|
+
choose(option: paypal_payment_method.id)
|
96
|
+
find(:xpath, "//input[@id='payments_source_paypal_order_id']", visible: false).set SecureRandom.hex(8)
|
97
|
+
click_button("Save and Continue")
|
98
|
+
click_button("Place Order")
|
99
|
+
expect(page).to have_current_path("/checkout/payment")
|
100
|
+
expect(page).to have_content("Your payment was declined")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'solidus_paypal_commerce_platform_spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe "Product page", js: true do
|
4
|
+
describe "paypal button", :skip do
|
5
|
+
before { create(:store, default: true) }
|
6
|
+
|
7
|
+
let!(:paypal_payment_method) { create(:paypal_payment_method) }
|
8
|
+
let!(:variants) {
|
9
|
+
option_type = create(:option_type)
|
10
|
+
product = create(:product, option_types: [option_type], slug: 'foo-bar')
|
11
|
+
option_s = create(:option_value, option_type: option_type, presentation: 'S')
|
12
|
+
option_xs = create(:option_value, option_type: option_type, presentation: 'XS')
|
13
|
+
|
14
|
+
[
|
15
|
+
create(:variant, product: product, option_values: [option_s]),
|
16
|
+
create(:variant, product: product, option_values: [option_xs]),
|
17
|
+
]
|
18
|
+
}
|
19
|
+
|
20
|
+
context "when generating a script tag" do
|
21
|
+
it "generates a url with the correct credentials attached" do
|
22
|
+
visit "/products/foo-bar"
|
23
|
+
|
24
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "generates a partner_id attribute with the correct partner code attached" do
|
28
|
+
visit "/products/foo-bar"
|
29
|
+
|
30
|
+
expect(js_sdk_script_partner_id).to eq("Solidus_PCP_SP")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "generates a URL with the correct currency" do
|
34
|
+
allow_any_instance_of(SolidusPaypalCommercePlatform::PricingOptions).to receive(:currency).and_return "EUR"
|
35
|
+
|
36
|
+
visit "/products/foo-bar"
|
37
|
+
|
38
|
+
expect(js_sdk_script_query).to include("currency=EUR")
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when auto-capture is set to true" do
|
42
|
+
it "generates a url with intent capture" do
|
43
|
+
paypal_payment_method.update(auto_capture: true)
|
44
|
+
|
45
|
+
visit "/products/foo-bar"
|
46
|
+
|
47
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
48
|
+
expect(js_sdk_script_query).to include("intent=capture")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "order creation" do
|
54
|
+
it "creates an order successfully" do
|
55
|
+
visit "/products/foo-bar"
|
56
|
+
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
57
|
+
|
58
|
+
expect(Spree::Order.last).to be_an_instance_of(Spree::Order)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "sets the Spree number and token variables" do
|
62
|
+
visit "/products/foo-bar"
|
63
|
+
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
64
|
+
|
65
|
+
order = Spree::Order.last
|
66
|
+
expect(page.evaluate_script("SolidusPaypalCommercePlatform.current_order_id")).to eq order.number
|
67
|
+
expect(page.evaluate_script("SolidusPaypalCommercePlatform.current_order_token")).to eq order.guest_token
|
68
|
+
end
|
69
|
+
|
70
|
+
it "uses the specified quantity" do
|
71
|
+
visit "/products/foo-bar"
|
72
|
+
fill_in('quantity', with: 12)
|
73
|
+
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
74
|
+
|
75
|
+
expect(Spree::Order.last.line_items.first.quantity).to eq(12)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "uses the selected variant" do
|
79
|
+
visit "/products/foo-bar"
|
80
|
+
find('label', text: 'XS').click
|
81
|
+
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
82
|
+
|
83
|
+
expect(Spree::Order.last.line_items.first.variant).to eq(variants.last)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "assigns the order to the api token holder" do
|
87
|
+
user = create(:user)
|
88
|
+
user.generate_spree_api_key!
|
89
|
+
|
90
|
+
visit "/products/foo-bar"
|
91
|
+
page.evaluate_script("SolidusPaypalCommercePlatform.api_key = #{user.spree_api_key.to_json}")
|
92
|
+
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
93
|
+
|
94
|
+
expect(Spree::Order.last.user).to eq(user)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
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.
|
4
|
+
version: 1.0.0.beta1
|
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:
|
12
|
+
date: 2022-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: deface
|
@@ -43,22 +43,16 @@ dependencies:
|
|
43
43
|
name: solidus_core
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '3.0'
|
49
|
-
- - "<"
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '5.0'
|
52
49
|
type: :runtime
|
53
50
|
prerelease: false
|
54
51
|
version_requirements: !ruby/object:Gem::Requirement
|
55
52
|
requirements:
|
56
|
-
- - "
|
53
|
+
- - "~>"
|
57
54
|
- !ruby/object:Gem::Version
|
58
55
|
version: '3.0'
|
59
|
-
- - "<"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '5.0'
|
62
56
|
- !ruby/object:Gem::Dependency
|
63
57
|
name: solidus_support
|
64
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,20 +95,6 @@ dependencies:
|
|
101
95
|
- - ">="
|
102
96
|
- !ruby/object:Gem::Version
|
103
97
|
version: '0'
|
104
|
-
- !ruby/object:Gem::Dependency
|
105
|
-
name: cuprite
|
106
|
-
requirement: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
type: :development
|
112
|
-
prerelease: false
|
113
|
-
version_requirements: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
98
|
- !ruby/object:Gem::Dependency
|
119
99
|
name: solidus_dev_support
|
120
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,17 +130,7 @@ files:
|
|
150
130
|
- app/assets/javascripts/spree/backend/solidus_paypal_commerce_platform.js
|
151
131
|
- app/assets/javascripts/spree/backend/solidus_paypal_commerce_platform/namespace.js
|
152
132
|
- app/assets/javascripts/spree/backend/solidus_paypal_commerce_platform/wizard.js
|
153
|
-
- app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform.js
|
154
|
-
- app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js
|
155
|
-
- app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/buttons.js
|
156
|
-
- app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/namespace.js
|
157
133
|
- app/assets/stylesheets/spree/backend/solidus_paypal_commerce_platform.css
|
158
|
-
- app/assets/stylesheets/spree/frontend/solidus_paypal_commerce_platform.css
|
159
|
-
- app/controllers/solidus_paypal_commerce_platform/orders_controller.rb
|
160
|
-
- app/controllers/solidus_paypal_commerce_platform/payments_controller.rb
|
161
|
-
- app/controllers/solidus_paypal_commerce_platform/paypal_orders_controller.rb
|
162
|
-
- app/controllers/solidus_paypal_commerce_platform/shipping_rates_controller.rb
|
163
|
-
- app/controllers/solidus_paypal_commerce_platform/wizard_controller.rb
|
164
134
|
- app/decorators/models/solidus_paypal_commerce_platform/spree/address_decorator.rb
|
165
135
|
- app/helpers/solidus_paypal_commerce_platform/button_options_helper.rb
|
166
136
|
- app/jobs/solidus_paypal_commerce_platform/application_job.rb
|
@@ -184,10 +154,13 @@ files:
|
|
184
154
|
- app/views/solidus_paypal_commerce_platform/admin/payment_methods/_setup_wizards.html.erb
|
185
155
|
- app/views/solidus_paypal_commerce_platform/admin/payments/_log_entries.html.erb
|
186
156
|
- bin/console
|
157
|
+
- bin/dummy-app
|
187
158
|
- bin/rails
|
159
|
+
- bin/rails-dummy-app
|
188
160
|
- bin/rails-engine
|
189
161
|
- bin/rails-sandbox
|
190
162
|
- bin/rake
|
163
|
+
- bin/rspec
|
191
164
|
- bin/sandbox
|
192
165
|
- bin/setup
|
193
166
|
- codecov.yml
|
@@ -196,7 +169,24 @@ files:
|
|
196
169
|
- db/migrate/20200521190038_add_paypal_commerce_platform_sources.rb
|
197
170
|
- db/migrate/20211220133406_add_paypal_funding_source_to_paypal_commerce_platform_sources.rb
|
198
171
|
- lib/generators/solidus_paypal_commerce_platform/install/install_generator.rb
|
199
|
-
- lib/generators/solidus_paypal_commerce_platform/install/templates/
|
172
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform.js
|
173
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js
|
174
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/buttons.js
|
175
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/namespace.js
|
176
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/assets/stylesheets/spree/frontend/solidus_paypal_commerce_platform.css
|
177
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/controllers/solidus_paypal_commerce_platform/orders_controller.rb
|
178
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/controllers/solidus_paypal_commerce_platform/payments_controller.rb
|
179
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/controllers/solidus_paypal_commerce_platform/paypal_orders_controller.rb
|
180
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/controllers/solidus_paypal_commerce_platform/shipping_rates_controller.rb
|
181
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/controllers/solidus_paypal_commerce_platform/wizard_controller.rb
|
182
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/views/checkouts/payment/_paypal_commerce_platform.html.erb
|
183
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/views/orders/payment/_paypal_commerce_platform.html.erb
|
184
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/views/products/payment/_paypal_commerce_platform.html.erb
|
185
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/views/solidus_paypal_commerce_platform/cart/_cart_buttons.html.erb
|
186
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/views/solidus_paypal_commerce_platform/payments/_payment.html.erb
|
187
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/views/solidus_paypal_commerce_platform/product/_product_buttons.html.erb
|
188
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/app/views/solidus_paypal_commerce_platform/shared/_javascript_sdk_tag.html.erb
|
189
|
+
- lib/generators/solidus_paypal_commerce_platform/install/templates/config/initializers/solidus_paypal_commerce_platform.rb
|
200
190
|
- lib/paypal/access_token.rb
|
201
191
|
- lib/paypal/lib.rb
|
202
192
|
- lib/paypal/paypal_checkout_sdk/orders/orders_authorize_request.rb
|
@@ -233,14 +223,34 @@ files:
|
|
233
223
|
- lib/views/backend/spree/admin/payments/source_forms/_paypal_commerce_platform.html.erb
|
234
224
|
- lib/views/backend/spree/admin/payments/source_views/_paypal_commerce_platform.html.erb
|
235
225
|
- lib/views/backend/spree/admin/shared/preference_fields/_paypal_select.html.erb
|
236
|
-
- lib/views/frontend/solidus_paypal_commerce_platform/cart/_cart_buttons.html.erb
|
237
|
-
- lib/views/frontend/solidus_paypal_commerce_platform/payments/_payment.html.erb
|
238
|
-
- lib/views/frontend/solidus_paypal_commerce_platform/product/_product_buttons.html.erb
|
239
|
-
- lib/views/frontend/solidus_paypal_commerce_platform/shared/_javascript_sdk_tag.html.erb
|
240
|
-
- lib/views/frontend/spree/checkout/payment/_paypal_commerce_platform.html.erb
|
241
|
-
- lib/views/frontend/spree/orders/payment/_paypal_commerce_platform.html.erb
|
242
|
-
- lib/views/frontend/spree/products/payment/_paypal_commerce_platform.html.erb
|
243
226
|
- solidus_paypal_commerce_platform.gemspec
|
227
|
+
- spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.COMPLETED.v2.json
|
228
|
+
- spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.PROCESSED.v2.json
|
229
|
+
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v1.json
|
230
|
+
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v2.json
|
231
|
+
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v1.json
|
232
|
+
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v2.json
|
233
|
+
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v1.json
|
234
|
+
- spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v2.json
|
235
|
+
- spec/jobs/solidus_paypal_commerce_platform/webhook_job_spec.rb
|
236
|
+
- spec/lib/solidus_paypal_commerce_platform/client_spec.rb
|
237
|
+
- spec/lib/solidus_paypal_commerce_platform/configuration_spec.rb
|
238
|
+
- spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb
|
239
|
+
- spec/models/solidus_paypal_commerce_platform/payment_source_spec.rb
|
240
|
+
- spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb
|
241
|
+
- spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb
|
242
|
+
- spec/models/solidus_paypal_commerce_platform/state_guesser_spec.rb
|
243
|
+
- spec/models/solidus_paypal_commerce_platform/wizard_spec.rb
|
244
|
+
- spec/requests/solidus_paypal_commerce_platform/orders_controller_spec.rb
|
245
|
+
- spec/requests/solidus_paypal_commerce_platform/shipping_rates_controller_spec.rb
|
246
|
+
- spec/requests/solidus_paypal_commerce_platform/wizard_controller_spec.rb
|
247
|
+
- spec/solidus_paypal_commerce_platform_spec_helper.rb
|
248
|
+
- spec/support/solidus_paypal_commerce_platform/factories.rb
|
249
|
+
- spec/support/solidus_paypal_commerce_platform/paypal_sdk_script_tag_helper.rb
|
250
|
+
- spec/system/backend/new_payment_method_spec.rb
|
251
|
+
- spec/system/frontend/cart_spec.rb
|
252
|
+
- spec/system/frontend/checkout_spec.rb
|
253
|
+
- spec/system/frontend/product_spec.rb
|
244
254
|
homepage: https://github.com/solidusio/solidus_paypal_commerce_platform
|
245
255
|
licenses:
|
246
256
|
- BSD-3-Clause
|
@@ -260,9 +270,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
260
270
|
version: '2.7'
|
261
271
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
262
272
|
requirements:
|
263
|
-
- - "
|
273
|
+
- - ">"
|
264
274
|
- !ruby/object:Gem::Version
|
265
|
-
version:
|
275
|
+
version: 1.3.1
|
266
276
|
requirements: []
|
267
277
|
rubygems_version: 3.3.23
|
268
278
|
signing_key:
|
data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js
DELETED
@@ -1,206 +0,0 @@
|
|
1
|
-
SolidusPaypalCommercePlatform.showOverlay = function() {
|
2
|
-
document.getElementById("paypal_commerce_platform_overlay").style.display = "block";
|
3
|
-
}
|
4
|
-
|
5
|
-
SolidusPaypalCommercePlatform.hideOverlay = function() {
|
6
|
-
document.getElementById("paypal_commerce_platform_overlay").style.display = "none";
|
7
|
-
}
|
8
|
-
|
9
|
-
SolidusPaypalCommercePlatform.handleError = function(error) {
|
10
|
-
console.error(error);
|
11
|
-
alert("There was a problem connecting with PayPal.")
|
12
|
-
throw error
|
13
|
-
}
|
14
|
-
|
15
|
-
SolidusPaypalCommercePlatform.sendOrder = function(payment_method_id) {
|
16
|
-
return Spree.ajax({
|
17
|
-
url: '/solidus_paypal_commerce_platform/paypal_orders/' + Spree.current_order_id,
|
18
|
-
method: 'GET',
|
19
|
-
data: {
|
20
|
-
payment_method_id: payment_method_id,
|
21
|
-
order_token: Spree.current_order_token
|
22
|
-
}
|
23
|
-
}).then(function(success_response) {
|
24
|
-
return success_response.table.result.table.id
|
25
|
-
}, function(failure_response) {
|
26
|
-
return failure_response.responseJSON.table.error.table
|
27
|
-
})
|
28
|
-
}
|
29
|
-
|
30
|
-
SolidusPaypalCommercePlatform.createAndSendOrder = function(payment_method_id) {
|
31
|
-
return SolidusPaypalCommercePlatform.createOrder().then(function(){
|
32
|
-
return SolidusPaypalCommercePlatform.sendOrder(payment_method_id)
|
33
|
-
})
|
34
|
-
}
|
35
|
-
|
36
|
-
SolidusPaypalCommercePlatform.createOrder = function() {
|
37
|
-
var data = {
|
38
|
-
order: {
|
39
|
-
line_items_attributes: [{
|
40
|
-
variant_id: SolidusPaypalCommercePlatform.getVariantId(),
|
41
|
-
quantity: SolidusPaypalCommercePlatform.getQuantity()
|
42
|
-
}]
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
return Spree.ajax({
|
47
|
-
url: "/solidus_paypal_commerce_platform/orders",
|
48
|
-
method: 'POST',
|
49
|
-
data: data,
|
50
|
-
error: function(response) {
|
51
|
-
message = response.responseJSON
|
52
|
-
alert('A problem has occurred while creating your order - ' + message);
|
53
|
-
}
|
54
|
-
}).then(function(response) {
|
55
|
-
Spree.current_order_id = response.number
|
56
|
-
Spree.current_order_token = response.guest_token
|
57
|
-
});
|
58
|
-
}
|
59
|
-
|
60
|
-
SolidusPaypalCommercePlatform.getVariantId = function() {
|
61
|
-
var variants = document.getElementsByName("variant_id")
|
62
|
-
var variant_id;
|
63
|
-
if(variants.length == 1){
|
64
|
-
variant_id = variants[0].value
|
65
|
-
}else{
|
66
|
-
var i;
|
67
|
-
for (i = 0; i < variants.length; i++) {
|
68
|
-
if (variants[i].checked) {
|
69
|
-
variant_id = variants[i].value
|
70
|
-
}
|
71
|
-
}
|
72
|
-
}
|
73
|
-
return variant_id
|
74
|
-
}
|
75
|
-
|
76
|
-
SolidusPaypalCommercePlatform.getQuantity = function() {
|
77
|
-
return document.getElementById("quantity").value
|
78
|
-
}
|
79
|
-
|
80
|
-
SolidusPaypalCommercePlatform.approveOrder = function(data, actions) {
|
81
|
-
SolidusPaypalCommercePlatform.showOverlay()
|
82
|
-
actions.order.get().then(function(response){
|
83
|
-
SolidusPaypalCommercePlatform.updateAddress(response).then(function() {
|
84
|
-
SolidusPaypalCommercePlatform.verifyTotal(response.purchase_units[0].amount.value).then(function(){
|
85
|
-
$("#payments_source_paypal_order_id").val(data.orderID)
|
86
|
-
$("#payments_source_paypal_email").val(response.payer.email_address)
|
87
|
-
$("#payments_source_paypal_funding_source").val(SolidusPaypalCommercePlatform.fundingSource)
|
88
|
-
$("#checkout_form_payment").submit()
|
89
|
-
})
|
90
|
-
})
|
91
|
-
})
|
92
|
-
}
|
93
|
-
|
94
|
-
SolidusPaypalCommercePlatform.shippingChange = function(data, actions) {
|
95
|
-
Spree.ajax({
|
96
|
-
url: '/solidus_paypal_commerce_platform/shipping_rates',
|
97
|
-
method: 'GET',
|
98
|
-
data: {
|
99
|
-
order_id: Spree.current_order_id,
|
100
|
-
order_token: Spree.current_order_token,
|
101
|
-
address: data.shipping_address
|
102
|
-
},
|
103
|
-
error: function(response) {
|
104
|
-
message = response.responseJSON;
|
105
|
-
console.log('There were some problems with your payment address - ' + message);
|
106
|
-
actions.reject()
|
107
|
-
}
|
108
|
-
}).then(function(response) {
|
109
|
-
actions.order.patch([response]).catch(function() {
|
110
|
-
actions.reject()
|
111
|
-
})
|
112
|
-
})
|
113
|
-
}
|
114
|
-
|
115
|
-
SolidusPaypalCommercePlatform.verifyTotal = function(paypal_total) {
|
116
|
-
return Spree.ajax({
|
117
|
-
url: '/solidus_paypal_commerce_platform/verify_total',
|
118
|
-
method: 'GET',
|
119
|
-
data: {
|
120
|
-
order_id: Spree.current_order_id,
|
121
|
-
order_token: Spree.current_order_token,
|
122
|
-
paypal_total: paypal_total
|
123
|
-
},
|
124
|
-
error: function(response) {
|
125
|
-
SolidusPaypalCommercePlatform.hideOverlay()
|
126
|
-
alert('There were some problems with your payment - ' + response.responseJSON.errors.expected_total);
|
127
|
-
}
|
128
|
-
})
|
129
|
-
}
|
130
|
-
|
131
|
-
SolidusPaypalCommercePlatform.finalizeOrder = function(payment_method_id, data, actions) {
|
132
|
-
SolidusPaypalCommercePlatform.showOverlay()
|
133
|
-
actions.order.get().then(function(response){
|
134
|
-
SolidusPaypalCommercePlatform.updateAddress(response).then(function() {
|
135
|
-
var paypal_amount = response.purchase_units[0].amount.value
|
136
|
-
SolidusPaypalCommercePlatform.advanceOrder().then(function() {
|
137
|
-
SolidusPaypalCommercePlatform.verifyTotal(paypal_amount).then(function(){
|
138
|
-
SolidusPaypalCommercePlatform.addPayment(paypal_amount, payment_method_id, data, response.payer.email_address).then(function() {
|
139
|
-
window.location.href = SolidusPaypalCommercePlatform.checkout_url
|
140
|
-
})
|
141
|
-
})
|
142
|
-
})
|
143
|
-
})
|
144
|
-
})
|
145
|
-
}
|
146
|
-
|
147
|
-
SolidusPaypalCommercePlatform.advanceOrder = function() {
|
148
|
-
return Spree.ajax({
|
149
|
-
url: '/api/checkouts/' + Spree.current_order_id + '/advance',
|
150
|
-
method: 'PUT',
|
151
|
-
data: {
|
152
|
-
order_token: Spree.current_order_token
|
153
|
-
},
|
154
|
-
error: function(response) {
|
155
|
-
SolidusPaypalCommercePlatform.hideOverlay()
|
156
|
-
alert('There were some problems with your order');
|
157
|
-
}
|
158
|
-
})
|
159
|
-
}
|
160
|
-
|
161
|
-
SolidusPaypalCommercePlatform.addPayment = function(paypal_amount, payment_method_id, data, email) {
|
162
|
-
return Spree.ajax({
|
163
|
-
url: '/api/checkouts/' + Spree.current_order_id + '/payments',
|
164
|
-
method: 'POST',
|
165
|
-
data: {
|
166
|
-
order_token: Spree.current_order_token,
|
167
|
-
payment: {
|
168
|
-
amount: paypal_amount,
|
169
|
-
payment_method_id: payment_method_id,
|
170
|
-
source_attributes: {
|
171
|
-
paypal_order_id: data.orderID,
|
172
|
-
paypal_email: email,
|
173
|
-
paypal_funding_source: SolidusPaypalCommercePlatform.fundingSource
|
174
|
-
}
|
175
|
-
}
|
176
|
-
},
|
177
|
-
error: function(response) {
|
178
|
-
SolidusPaypalCommercePlatform.hideOverlay()
|
179
|
-
alert('There were some problems with your payment');
|
180
|
-
}
|
181
|
-
})
|
182
|
-
}
|
183
|
-
|
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;
|
189
|
-
return Spree.ajax({
|
190
|
-
url: '/solidus_paypal_commerce_platform/update_address',
|
191
|
-
method: 'POST',
|
192
|
-
data: {
|
193
|
-
address: {
|
194
|
-
updated_address: updated_address,
|
195
|
-
recipient: response.payer
|
196
|
-
},
|
197
|
-
order_id: Spree.current_order_id,
|
198
|
-
order_token: Spree.current_order_token
|
199
|
-
},
|
200
|
-
error: function(response) {
|
201
|
-
SolidusPaypalCommercePlatform.hideOverlay()
|
202
|
-
message = response.responseJSON;
|
203
|
-
alert('There were some problems with your payment address - ' + message);
|
204
|
-
}
|
205
|
-
})
|
206
|
-
}
|
File without changes
|