5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/spree/billets_controller.rb', line 5
def show
if @billet.due_date.past?
old_payment = @billet.payment
old_payment.void_transaction!
params = {order: @billet.order,
amount: old_payment.amount,
payment_method: @billet.payment_method,
source_attributes: {order: @billet.order,
user: @billet.user,
status: 'pending'}}
new_payment = Spree::Payment.new(params)
new_payment.pend!
new_payment.process!
@billet = new_payment.source
end
@document = @billet.generate_document
send_data @document.to_pdf, filename: "boleto_#{@billet.order.number}.pdf"
end
|