Sha256: 6d1f398d344d090459d96b9aa4a986126bfccdb6ee313415467cd937dc3543db
Contents?: true
Size: 1.52 KB
Versions: 3
Compression:
Stored size: 1.52 KB
Contents
Spree::CheckoutController.class_eval do def edit if ((@order.state == "payment") && @order.valid?) puts "valid, processing" if @order.payable_via_pag_seguro? puts "payable via pag_seguro, adding payment" payment = Spree::Payment.new payment.amount = @order.total payment.payment_method = Spree::Order.pag_seguro_payment_method @order.payments << payment pag_seguro_payment = PagSeguro::Payment.new( Spree::PagSeguro::Config.email, Spree::PagSeguro::Config.token, redirect_url: "#{root_url}/pag_seguro/callback", id: @order.id) pag_seguro_payment.items = @order.line_items.collect do |item| PagSeguro::Item.new( id: item.id, description: item.product.description, amount: format("%.2f", item.price.round(2)), quantity: item.quantity, weight: item.product.weight, ) end pag_seguro_payment.sender = PagSeguro::Sender.new(name: @order.name, email: @order.email, phone_number: @order.ship_address.phone) pag_seguro_payment.shipping = PagSeguro::Shipping.new(type: PagSeguro::Shipping::SEDEX, state: @order.ship_address.state.abbr, city: @order.ship_address.city, postal_code: @order.ship_address.zipcode, street: @order.ship_address.address1, complement: @order.ship_address.address2) @pag_seguro_url = pag_seguro_payment.checkout_payment_url payment.started_processing end end end end
Version data entries
3 entries across 3 versions & 1 rubygems