-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created checkout using Pagseguro lightbox.
- Loading branch information
1 parent
99ee5aa
commit e0fb171
Showing
10 changed files
with
88 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//Insira o código de checkout gerado no Passo 1 | ||
var pagsegurCodeSelector = document.querySelector('div[data-pagseguro-code]') | ||
if (pagsegurCodeSelector) { | ||
var code = pagsegurCodeSelector.dataset.pagseguroCode; | ||
var callback = { | ||
success : function(transactionCode) { | ||
var checkoutPaymentForm = document.querySelector('form.checkout_form_payment'); | ||
var submit = checkout_form_payment.querySelector("input[type='submit']") | ||
$(submit).trigger('click'); | ||
}, | ||
abort : function() { | ||
console.log("abortado"); | ||
} | ||
}; | ||
var isOpenLightbox = PagSeguroLightbox(code, callback); | ||
if (!isOpenLightbox){ | ||
location.href="https://pagseguro.uol.com.br/v2/checkout/payment.html?code=" + code; | ||
console.log("Redirecionamento") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Spree::CheckoutControllerDecorator | ||
def self.prepended(base) | ||
base.before_action :create_pag_seguro_transaction, only: :edit | ||
end | ||
|
||
def create_pag_seguro_transaction | ||
return unless params[:state] == "payment" | ||
payment = @order.payments.build(payment_method: Spree::PaymentMethod.where(type: 'Spree::PaymentMethod::Pagseguro').last) | ||
SpreePagseguroSimple::Gateway.new(payment) | ||
@pag_seguro_payment = Spree::PagSeguroTransaction.find_by_order_id @order.number | ||
end | ||
end | ||
|
||
::Spree::CheckoutController.prepend Spree::CheckoutControllerDecorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
app/overrides/spree/shared/_order_details/add_pag_seguro.html.erb.deface
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
<p>Finalize seu pedido para efetuar o pagamento no PagSeguro</p> | ||
<p>Aguarde, enquanto carregamos a página para que realize a o pagamento.</p> | ||
<%= content_for :head do %> | ||
<script type="text/javascript" src="https://stc.sandbox.pagseguro.uol.com.br/pagseguro/api/v2/checkout/pagseguro.lightbox.js"></script> | ||
<% end %> | ||
|
||
<div data-pagseguro-code="<%= @pag_seguro_payment.code %>"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddCodeToSpreePayments < ActiveRecord::Migration[6.0] | ||
def change | ||
add_column :spree_payments, :code, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class RemoveCodeToSpreePayments < ActiveRecord::Migration[6.0] | ||
def change | ||
remove_column :spree_payments, :code | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
lib/generators/spree_pagseguro_simple/install/install_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PagSeguro::Url.environment = ENV['PAGSEGURO_ENV'].to_sym |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters