Class: SolidusBolt::Handlers::CreditHandler

Inherits:
BaseHandler
  • Object
show all
Defined in:
app/webhooks/solidus_bolt/handlers/credit_handler.rb

Instance Attribute Summary

Attributes inherited from BaseHandler

#params

Instance Method Summary collapse

Methods inherited from BaseHandler

call, #initialize

Constructor Details

This class inherits a constructor from SolidusBolt::Handlers::BaseHandler

Instance Method Details

#callObject



6
7
8
9
10
11
12
13
14
15
# File 'app/webhooks/solidus_bolt/handlers/credit_handler.rb', line 6

def call
  payment_response_code = params[:data][:source_transaction][:reference]
  source_payment = Spree::Payment.find_by(response_code: payment_response_code)
  amount = params[:data][:requested_refund_amount][:amount].to_i
  refund_transaction_id = params[:data][:reference]

  SolidusBolt::Payments::CreditSyncService.call(
    payment: source_payment, amount: amount, transaction_id: refund_transaction_id
  )
end