Class: SolidusInter::Gateway
- Inherits:
-
Object
- Object
- SolidusInter::Gateway
- Defined in:
- app/models/solidus_inter/gateway.rb
Instance Method Summary collapse
- #credit(money, transaction_id, options = {}) ⇒ Object
-
#initialize(options) ⇒ Gateway
constructor
A new instance of Gateway.
- #void(transaction_id, options = {}) ⇒ Object
Constructor Details
#initialize(options) ⇒ Gateway
Returns a new instance of Gateway.
3 4 |
# File 'app/models/solidus_inter/gateway.rb', line 3 def initialize() end |
Instance Method Details
#credit(money, transaction_id, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/solidus_inter/gateway.rb', line 12 def credit(money, transaction_id, = {}) payment = Spree::Payment.find_by(response_code: transaction_id) payment_source = payment.source refund = payment_source.refund! if refund.status == "DEVOLVIDO" response = successful_response("Pagamento reembolsado (#{refund.status})", transaction_id) payment.log_entries.create(parsed_payment_response_details_with_fallback: response) successful_response("Reembolso realizado", refund.id) else response = successful_response("Pagamento não reembolsado - #{refund.status} - #{refund.try(:motivo)}", transaction_id) payment.log_entries.create(parsed_payment_response_details_with_fallback: response) successful_response("Erro ao reembolsar", refund.id) end end |
#void(transaction_id, options = {}) ⇒ Object
6 7 8 9 10 |
# File 'app/models/solidus_inter/gateway.rb', line 6 def void(transaction_id, = {}) # Respondendo com falha pois atualmente todo pedido concluido ja teve seu pagamento processado # e nesse caso o credit é mais adequado (Ao cancelar um pedido pela interface, o 'void' é chamado, se ele retornar falha o Solidus chama o 'credit') failure_response("Pagamento já processado") end |