Update payment status when refunding from Komoju
Opened this issue · 0 comments
rramsden commented
Currently when a payment is refunded on Komoju the payment status
does not change on Spree:
After doing some research I believe in order to fix this issue we need to add
the following code to komoju_controller.rb
when "payment.refunded"
refund = params[:data][:refunds].last
order_number = extract_payment_number(params[:data][:external_order_num])
payment = Spree::Payment.find_by_number!(order_number)
reason = Spree::RefundReason.find_or_create_by!(name: refund[:description] || "Refund")
payment.refunds.create!(amount: payment.amount, reason: reason, transaction_id: refund[:id] )
end