Skip to content

Instantly share code, notes, and snippets.

@vernondegoede
Created March 20, 2018 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vernondegoede/ff017b53e4201e352316bfacf29b4357 to your computer and use it in GitHub Desktop.
Save vernondegoede/ff017b53e4201e352316bfacf29b4357 to your computer and use it in GitHub Desktop.
Create a Mollie transaction, even when the order is completed (but not paid for).
Spree::Payment.class_eval do
delegate :transaction_id, to: :source
def build_source
return unless new_record?
if source_attributes.present? && source.blank? && payment_method.try(:payment_source_class)
self.source = payment_method.payment_source_class.new(source_attributes)
source.payment_method_id = payment_method.id
source.user_id = order.user_id if order
# Spree will not process payments if order is completed.
# We should call process! for completed orders to create a new Mollie payment.
process! if order.completed?
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment