spree_paypal_api_checkout 0.0.5 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bae3ca282bbb42703dee161639c0bc575070c8743c5731e269017689985fdb26
4
- data.tar.gz: 8acd1a06f1b8ef885359d36b724319107d8ffdfc1378b5238b95ff9afa70c915
3
+ metadata.gz: 6a5a5201c741e77e835868a6fda79d71b658c1b58fabca8ef39d3990199294f2
4
+ data.tar.gz: d9b4e0c18fef43f234f07ed9bfc011811fbd87b49751cb524dfba3f189c428df
5
5
  SHA512:
6
- metadata.gz: 27bd28c102d8d41e14e99a44463f2ed50f1f739e58d8e3da932caa325f08f8af71d1f3737eb8b083865f1d513eac605168c3e83d860489b2dc182f66de749b30
7
- data.tar.gz: 042cdcbf7f71ab1a8e8238d7495d8f947a240a794d21d143e10f925df4adee2e5ac5b5df1ea178ab4f6938a1984fcf858f047c8bf408b3ffeeaced54d65c72b4
6
+ metadata.gz: fb54727dee1cef2a75bdf4527b6ba3c33d2dad98cb14a85ec36099be4c7f3dd9c0ed80918fd4a794330d47055c069113b20fc01fb8b62c0df73cfe2988dc4e33
7
+ data.tar.gz: 9cf9906841e3359b96fae7f8581dcea5c24026035c7a02e46a7351efc9c1b17d8bb9a3c1f029330b07f7f4f89cb5dae9be5c04d14f034cd2335282e31fabfe45
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  1. Add this extension to your Gemfile with this line:
6
6
 
7
- gem 'spree_paypal_checkout', '~> 0.0.5'
7
+ gem 'spree_paypal_api_checkout', '~> 0.0.8'
8
8
 
9
9
  2. Install the gem using Bundler:
10
10
 
@@ -1,5 +1,5 @@
1
1
  module Spree::Admin::PaymentsControllerDecorator
2
- def paypal_refund
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.success?
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
@@ -3,7 +3,7 @@ module Spree
3
3
  before_action :load_order
4
4
 
5
5
  def index
6
- @payments = @order.payments.includes(:payment_method).where(:spree_payment_methods => { :name => 'Spree::Gateway::PayPalCheckout' })
6
+ @payments = @order.payments.includes(:payment_method).where(:spree_payment_methods => {:name => 'PayPal Checkout'})
7
7
  end
8
8
 
9
9
  private
@@ -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
- redirect_to completion_route(order)
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
@@ -2,7 +2,7 @@ module Spree
2
2
  class Gateway::PayPalCheckout < Gateway
3
3
  preference :api_key, :string
4
4
  preference :secret_key, :string
5
- preference :server, :string, default: 'https://api-m.sandbox.paypal.com'
5
+ preference :server, :string, default: 'api-m.sandbox.paypal.com'
6
6
 
7
7
  def supports?(source)
8
8
  true
@@ -1,4 +1,4 @@
1
- <%= form_tag paypal_refund_admin_order_payment_path(@order, @payment) do %>
1
+ <%= form_tag paypal_checkout_refund_admin_order_payment_path(@order, @payment) do %>
2
2
  <div class="label-block left five columns alpha">
3
3
  <div>
4
4
  <fieldset data-hook="admin_variant_new_form">
@@ -6,7 +6,7 @@
6
6
  / <%= Spree.t('refund', :scope => :paypal) %>
7
7
  <% end %>
8
8
 
9
- <%= form_tag paypal_refund_admin_order_payment_path(@order, @payment) do %>
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">
@@ -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.paypal_refund_admin_order_payment_path(@order, payment), icon: 'money' %>
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,3 +1,3 @@
1
1
  module SpreePaypalApiCheckout
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.8'
3
3
  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.5"
3
+ s.version = "0.0.8"
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/_paypal_complete.html.erb".freeze, "app/views/spree/admin/payments/paypal_refund.html.erb".freeze, "app/views/spree/admin/payments/source_forms/_paypal.html.erb".freeze, "app/views/spree/admin/payments/source_views/_paypal.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]
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.5
4
+ version: 0.0.8
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/_paypal_complete.html.erb
367
- - app/views/spree/admin/payments/paypal_refund.html.erb
368
- - app/views/spree/admin/payments/source_forms/_paypal.html.erb
369
- - app/views/spree/admin/payments/source_views/_paypal.html.erb
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
@@ -401,7 +401,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
401
  version: '0'
402
402
  requirements:
403
403
  - none
404
- rubygems_version: 3.2.3
404
+ rubygems_version: 3.2.15
405
405
  signing_key:
406
406
  specification_version: 4
407
407
  summary: Adds PayPal API Checkout as a Payment Method to Spree Commerce