Skip to content

Conversation

emileswarts
Copy link

In a multi store environment it is desirable to use the store specific payment method.
If one is not defined, default back to the last Adyen payment method it can find.

@Dkendal Dkendal requested a review from luukveenis April 12, 2017 17:26
Copy link
Member

@luukveenis luukveenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this PR!

I'd be happy to merge this in, just 2 minor comments.

payment
end

def payment_method_for(order)
Copy link
Member

@luukveenis luukveenis Jun 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to pass the order to this method since the class is initialized with it. With it removed the method can probably also be renamed to something like hpp_payment_method.


def payment_method_for(order)
order.store.payment_methods.where(type: 'Spree::Gateway::AdyenHPP', active: true).last!
rescue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of rescuing everything, I would prefer something like:
order.store.payment_methods.active.find_by(type: "Spree::Gateway::AdyenHPP") || Spree::Gateway::AdyenHPP.last

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

Successfully merging this pull request may close these issues.

2 participants