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

Interfaces for persist_user_credit_card and assign_default_credit_card #1086

Merged

Conversation

jordan-brough
Copy link
Contributor

Extract the logic for persist_user_credit_card and
assign_default_credit_card into configurable classes.

Does this seem like something we'd like to do? This is from a pairing session with
@mamhoff around non-credit card payment sources. If it seems good then I'll
add some specs around it.

@cbrunsdon
Copy link
Contributor

I'm torn on having the "add after order complete" being a separate objects. I almost think it should be supported somehow by the wallet API itself to keep the api more cohese and clear for anyone using it.

I'd almost expect something more generic to be called like:

wallet.events.order_complete(order)

which users could do as they wish with (including persist it, if desired).

The second one, the add_default_payment_source I'm weirded out about for another reason. It seems weird that a Wallet:: class would be responsible for creating a payment on an order after a transition. But thats maybe mostly related to how ugly it is now.

@@ -0,0 +1,24 @@
class Spree::Wallet::AddDefaultPayment
Copy link
Member

Choose a reason for hiding this comment

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

We should consider to call this class DefaultPaymentBuilder as we actually don't add something, we build something. Otherwise great!

Copy link
Contributor

Choose a reason for hiding this comment

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

And with that name change, the method could be named just build I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tvdeyen @peterberkenbosch updated. Thanks!

@tvdeyen
Copy link
Member

tvdeyen commented Apr 26, 2016

Good step in the right direction. I Like that.

@peterberkenbosch
Copy link
Contributor

I see a Wallet as an abstraction for the payment sources, and ideally very loosely coupled with any state event change on Order. I have some comments inline as well that reflect that opinion.

Love to discuss this further and move forward :)

@jordan-brough
Copy link
Contributor Author

jordan-brough commented Jul 27, 2016

@cbrunsdon I hear you on the weirdness and current ugliness. I'd lean toward getting this in since it solves the biggest problem of stores being able to customize this logic without monkey patching and then revisit during or after the main Wallet PR. What do you think though?

wallet.events.order_complete(order)

I like that. How about I make that change in the main Wallet PR after we merge this? (e.g. the User#wallet namespace doesn't exist yet at this point).

@peterberkenbosch
Copy link
Contributor

Also, this PR is pointing to master right now. Should it be towards this branch? solidusio:jordan/non-credit-card-payment-sources-base

@jordan-brough
Copy link
Contributor Author

Also, this PR is pointing to master right now. Should it be towards this branch?

@peterberkenbosch I did want to point it at master. I did this in a weird way...but this was one of three things in that other branch that I wanted to get into master before the main Wallet PR.

@peterberkenbosch
Copy link
Contributor

Got it @jordan-brough, I missed the add commit with the Spree::Wallet namespace here. Perfect!

@peterberkenbosch
Copy link
Contributor

wdyt @cbrunsdon @jhawthorn

# AddAfterOrderComplete is called after an order transitions to complete. It
# is responsible for saving payment sources in the user's "wallet" for future
# use.
def add_to_wallet
Copy link
Contributor

Choose a reason for hiding this comment

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

Given this comment (https://github.com/solidusio/solidus/pull/1086/files#diff-a9fae1594c22d1ec005ac8501d80d7afR356) and the importance of documenting these interfaces, could we add some more YARD docs to this method?

@bbuchalter
Copy link
Contributor

I would find this PR helpful. We've got these customizations hacked into our app now and would love to have a nice interface for it!

@cbrunsdon
Copy link
Contributor

I've thought about this one for a few days and can't think of anything that would improve it, and I think its better than what we have now, so I'm at a 👍 if @jhawthorn is.

@peterberkenbosch
Copy link
Contributor

Thanks @cbrunsdon! @jhawthorn wdyt? :)

@jordan-brough
Copy link
Contributor Author

@jhawthorn updated as per our chat
@bbuchalter I added some more comments/YARD docs also

@jhawthorn
Copy link
Contributor

👍 Looks good

@jordan-brough jordan-brough merged commit c3a4bcd into solidusio:master Aug 10, 2016
@jordan-brough jordan-brough deleted the configurable-wallet-behavior branch August 10, 2016 22:14
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.

None yet

6 participants