Created
March 20, 2018 12:01
-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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