spree_paypal_api_checkout 0.0.6 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/spree/admin/payments_controller_decorator.rb +2 -2
- data/app/controllers/spree/paypal_checkout_controller.rb +34 -9
- data/app/views/spree/admin/payments/{_paypal_complete.html.erb → _paypal_checkout_complete.html.erb} +1 -1
- data/app/views/spree/admin/payments/{paypal_refund.html.erb → paypal_checkout_refund.html.erb} +1 -1
- data/app/views/spree/admin/payments/source_forms/{_paypal.html.erb → _paypal_checkout.html.erb} +0 -0
- data/app/views/spree/admin/payments/source_views/{_paypal.html.erb → _paypal_checkout.html.erb} +1 -1
- data/app/views/spree/checkout/payment/_paypal_checkout.html.erb +4 -1
- data/config/routes.rb +11 -0
- data/lib/spree_paypal_api_checkout/version.rb +1 -1
- data/spree_paypal_api_checkout.gemspec +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07c55f4fc562fc1c5cafec50afb576a3498ff4569cc6d390c1f02fc174efa002
|
4
|
+
data.tar.gz: 7ad4654823019c8eb7b7ee1b14132ce1974240ae373c42fafba6ef0d22d8656a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 168e3b4bf6eb7f34e7f0838853a2bdbfdc4b14bb19520cf7ec737a1e9124b8f6c972786022dccaf8353ac9fb8ffdd5f323f1d7011d096411b93f5c4dae93aaa4
|
7
|
+
data.tar.gz: 36ca56115090032c1487903d9f7b8bde7a7612a37d061fbd37ebe8fd7e02a81e5f4ba2e9b70d30b76b63e1538a068d5a5592db9b7eb0176f40b2df7dc8285a89
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Spree::Admin::PaymentsControllerDecorator
|
2
|
-
def
|
2
|
+
def paypal_checkout_refund
|
3
3
|
if request.get?
|
4
4
|
if @payment.source.state == 'refunded'
|
5
5
|
flash[:error] = Spree.t(:already_refunded, :scope => 'paypal')
|
@@ -7,7 +7,7 @@ module Spree::Admin::PaymentsControllerDecorator
|
|
7
7
|
end
|
8
8
|
elsif request.post?
|
9
9
|
response = @payment.payment_method.refund(@payment, params[:refund_amount])
|
10
|
-
if response
|
10
|
+
if response['status']=='COMPLETED'
|
11
11
|
flash[:success] = Spree.t(:refund_successful, :scope => 'paypal')
|
12
12
|
redirect_to admin_order_payments_path(@order)
|
13
13
|
else
|
@@ -19,7 +19,7 @@ module Spree
|
|
19
19
|
items << {
|
20
20
|
name: adjustment.label,
|
21
21
|
quantity: 1,
|
22
|
-
|
22
|
+
unit_amount: {
|
23
23
|
currency_code: order.currency,
|
24
24
|
value: adjustment.amount
|
25
25
|
}
|
@@ -49,14 +49,14 @@ module Spree
|
|
49
49
|
order = current_order || raise(ActiveRecord::RecordNotFound)
|
50
50
|
order.payments.last.source.update(transaction_id: params[:transaction_id])
|
51
51
|
order.next
|
52
|
+
path = checkout_state_path(order.state)
|
52
53
|
if order.complete?
|
53
54
|
flash.notice = Spree.t(:order_processed_successfully)
|
54
55
|
flash[:order_completed] = true
|
55
56
|
session[:order_id] = nil
|
56
|
-
|
57
|
-
else
|
58
|
-
redirect_to checkout_state_path(order.state)
|
57
|
+
path = completion_route(order)
|
59
58
|
end
|
59
|
+
render json: { redirect_to: path }
|
60
60
|
end
|
61
61
|
|
62
62
|
def cancel
|
@@ -70,13 +70,14 @@ module Spree
|
|
70
70
|
def line_item(item)
|
71
71
|
{
|
72
72
|
name: item.product.name,
|
73
|
-
|
73
|
+
sku: item.variant.sku,
|
74
74
|
quantity: item.quantity,
|
75
|
-
|
75
|
+
description: item.product.meta_description,
|
76
|
+
unit_amount: {
|
76
77
|
currency_code: item.order.currency,
|
77
78
|
value: item.price
|
78
79
|
},
|
79
|
-
|
80
|
+
item_category: "Physical"
|
80
81
|
}
|
81
82
|
end
|
82
83
|
|
@@ -87,14 +88,38 @@ module Spree
|
|
87
88
|
{
|
88
89
|
amount: {
|
89
90
|
currency_code: current_order.currency,
|
90
|
-
value: order.total
|
91
|
+
value: order.total,
|
92
|
+
breakdown: {
|
93
|
+
item_total: {
|
94
|
+
currency_code: current_order.currency,
|
95
|
+
value: items.sum{|r| (r[:unit_amount][:value] * r[:quantity]) }
|
96
|
+
}
|
97
|
+
}
|
91
98
|
},
|
92
|
-
|
99
|
+
items: items,
|
100
|
+
shipping: address_options
|
93
101
|
},
|
94
102
|
]
|
95
103
|
}
|
96
104
|
end
|
97
105
|
|
106
|
+
def address_options
|
107
|
+
address = current_order.ship_address
|
108
|
+
{
|
109
|
+
name: { full_name: address.try(:full_name) },
|
110
|
+
address: {
|
111
|
+
address_line_1: address.address1,
|
112
|
+
address_line_2: address.address2,
|
113
|
+
# phone: address.phone,
|
114
|
+
admin_area_1: address.state_text,
|
115
|
+
admin_area_2: address.city,
|
116
|
+
country_code: address.country.iso,
|
117
|
+
postal_code: address.zipcode
|
118
|
+
},
|
119
|
+
type: 'SHIPPING'
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
98
123
|
def payment_method
|
99
124
|
Spree::PaymentMethod.find(params[:payment_method_id])
|
100
125
|
end
|
data/app/views/spree/admin/payments/{paypal_refund.html.erb → paypal_checkout_refund.html.erb}
RENAMED
@@ -6,7 +6,7 @@
|
|
6
6
|
/ <%= Spree.t('refund', :scope => :paypal) %>
|
7
7
|
<% end %>
|
8
8
|
|
9
|
-
<%= form_tag
|
9
|
+
<%= form_tag paypal_checkout_refund_admin_order_payment_path(@order, @payment) do %>
|
10
10
|
<div class="label-block left five columns alpha">
|
11
11
|
<div>
|
12
12
|
<fieldset data-hook="admin_variant_new_form">
|
data/app/views/spree/admin/payments/source_forms/{_paypal.html.erb → _paypal_checkout.html.erb}
RENAMED
File without changes
|
data/app/views/spree/admin/payments/source_views/{_paypal.html.erb → _paypal_checkout.html.erb}
RENAMED
@@ -16,7 +16,7 @@
|
|
16
16
|
</div>
|
17
17
|
|
18
18
|
<% if payment.source.state != 'refunded' %>
|
19
|
-
<%= button_link_to Spree.t('actions.refund', scope: :paypal), spree.
|
19
|
+
<%= button_link_to Spree.t('actions.refund', scope: :paypal), spree.paypal_checkout_refund_admin_order_payment_path(@order, payment), icon: 'money' %>
|
20
20
|
<% else %>
|
21
21
|
<div class="alpha six columns">
|
22
22
|
<dl>
|
@@ -27,7 +27,10 @@
|
|
27
27
|
var transaction = orderData.purchase_units[0].payments.captures[0];
|
28
28
|
fetch(`/paypal_checkout/proceed?number=${data.orderID}&status=${transaction.status}&transaction_id=${transaction.id}`, {
|
29
29
|
method: "get",
|
30
|
-
})
|
30
|
+
}).then((response) => response.json())
|
31
|
+
.then((orderData2) => {
|
32
|
+
window.location.href = `${window.location.origin}${orderData2.redirect_to}`
|
33
|
+
});
|
31
34
|
});
|
32
35
|
}
|
33
36
|
}).render('#paypal-button-container');
|
data/config/routes.rb
CHANGED
@@ -4,4 +4,15 @@ Spree::Core::Engine.add_routes do
|
|
4
4
|
get '/paypal_checkout/cancel', :to => "paypal_checkout#cancel", :as => :cancel_paypal_checkout
|
5
5
|
get '/paypal_checkout/notify', :to => "paypal_checkout#notify", :as => :notify_paypal_checkout
|
6
6
|
get '/paypal_checkout/proceed', :to => "paypal_checkout#proceed", :as => :proceed_paypal_checkout
|
7
|
+
namespace :admin do
|
8
|
+
# Using :only here so it doesn't redraw those routes
|
9
|
+
resources :orders, :only => [] do
|
10
|
+
resources :payments, :only => [] do
|
11
|
+
member do
|
12
|
+
get 'paypal_checkout_refund'
|
13
|
+
post 'paypal_checkout_refund'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
7
18
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "spree_paypal_api_checkout".freeze
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.9"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
6
6
|
s.require_paths = ["lib".freeze]
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.date = "2022-02-22"
|
9
9
|
s.description = "Adds PayPal API Checkout as a Payment Method to Spree Commerce".freeze
|
10
10
|
s.email = "gems@spreecommerce.com".freeze
|
11
|
-
s.files = [".gitignore".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "app/assets/javascripts/spree/backend/spree_paypal_checkout.js".freeze, "app/assets/javascripts/spree/frontend/spree_paypal_checkout.js".freeze, "app/assets/stylesheets/spree/backend/spree_paypal_checkout.css".freeze, "app/assets/stylesheets/spree/frontend/spree_paypal_checkout.css".freeze, "app/controllers/spree/admin/payments_controller_decorator.rb".freeze, "app/controllers/spree/admin/paypal_checkout_payments_controller.rb".freeze, "app/controllers/spree/paypal_checkout_controller.rb".freeze, "app/models/spree/gateway/pay_pal_checkout.rb".freeze, "app/models/spree/paypal_api_checkout.rb".freeze, "app/views/spree/admin/payments/
|
11
|
+
s.files = [".gitignore".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "app/assets/javascripts/spree/backend/spree_paypal_checkout.js".freeze, "app/assets/javascripts/spree/frontend/spree_paypal_checkout.js".freeze, "app/assets/stylesheets/spree/backend/spree_paypal_checkout.css".freeze, "app/assets/stylesheets/spree/frontend/spree_paypal_checkout.css".freeze, "app/controllers/spree/admin/payments_controller_decorator.rb".freeze, "app/controllers/spree/admin/paypal_checkout_payments_controller.rb".freeze, "app/controllers/spree/paypal_checkout_controller.rb".freeze, "app/models/spree/gateway/pay_pal_checkout.rb".freeze, "app/models/spree/paypal_api_checkout.rb".freeze, "app/views/spree/admin/payments/_paypal_checkout_complete.html.erb".freeze, "app/views/spree/admin/payments/paypal_checkout_refund.html.erb".freeze, "app/views/spree/admin/payments/source_forms/_paypal_checkout.html.erb".freeze, "app/views/spree/admin/payments/source_views/_paypal_checkout.html.erb".freeze, "app/views/spree/checkout/payment/_paypal_checkout.html.erb".freeze, "config/locales/de.yml".freeze, "config/locales/en.yml".freeze, "config/locales/es.yml".freeze, "config/locales/it.yml".freeze, "config/locales/pl.yml".freeze, "config/locales/pt.yml".freeze, "config/routes.rb".freeze, "db/migrate/20220620042734_create_spree_paypal_api_checkouts.rb".freeze, "lib/generators/spree_paypal_api_checkout/install/install_generator.rb".freeze, "lib/spree_paypal_api_checkout.rb".freeze, "lib/spree_paypal_api_checkout/engine.rb".freeze, "lib/spree_paypal_api_checkout/version.rb".freeze, "script/rails".freeze, "spree_paypal_api_checkout.gemspec".freeze]
|
12
12
|
s.homepage = "http://www.spreecommerce.com".freeze
|
13
13
|
s.required_ruby_version = Gem::Requirement.new(">= 2.2.2".freeze)
|
14
14
|
s.requirements = ["none".freeze]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_paypal_api_checkout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spree Commerce
|
@@ -363,10 +363,10 @@ files:
|
|
363
363
|
- app/controllers/spree/paypal_checkout_controller.rb
|
364
364
|
- app/models/spree/gateway/pay_pal_checkout.rb
|
365
365
|
- app/models/spree/paypal_api_checkout.rb
|
366
|
-
- app/views/spree/admin/payments/
|
367
|
-
- app/views/spree/admin/payments/
|
368
|
-
- app/views/spree/admin/payments/source_forms/
|
369
|
-
- app/views/spree/admin/payments/source_views/
|
366
|
+
- app/views/spree/admin/payments/_paypal_checkout_complete.html.erb
|
367
|
+
- app/views/spree/admin/payments/paypal_checkout_refund.html.erb
|
368
|
+
- app/views/spree/admin/payments/source_forms/_paypal_checkout.html.erb
|
369
|
+
- app/views/spree/admin/payments/source_views/_paypal_checkout.html.erb
|
370
370
|
- app/views/spree/checkout/payment/_paypal_checkout.html.erb
|
371
371
|
- config/locales/de.yml
|
372
372
|
- config/locales/en.yml
|