Skip to content

Prefer a store specific payment method if it exists#106

Open
emileswarts wants to merge 1 commit into
StemboltHQ:masterfrom
emileswarts:master
Open

Prefer a store specific payment method if it exists#106
emileswarts wants to merge 1 commit into
StemboltHQ:masterfrom
emileswarts:master

Conversation

@emileswarts

Copy link
Copy Markdown

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

@luukveenis luukveenis left a comment

Copy link
Copy Markdown
Member

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)

@luukveenis luukveenis Jun 13, 2017

Copy link
Copy Markdown
Member

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
Copy Markdown
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