Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update payment status when refunding from Komoju #54

Open
rramsden opened this issue Oct 26, 2016 · 0 comments
Open

Update payment status when refunding from Komoju #54

rramsden opened this issue Oct 26, 2016 · 0 comments

Comments

@rramsden
Copy link
Member

Currently when a payment is refunded on Komoju the payment status
does not change on Spree:

https://github.com/komoju/spree_komoju/blob/1f820e074dba4fb0deeda54439f7d078f588452d/app/controllers/spree/komoju_controller.rb#L9

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant