Skip to content

Remove Spree::Order#add_default_payment_from_wallet checkout transition - #4185

Closed
danielpuglisi wants to merge 2 commits into
solidusio:mainfrom
codegestalt:remove-default-checkout-payment
Closed

Remove Spree::Order#add_default_payment_from_wallet checkout transition#4185
danielpuglisi wants to merge 2 commits into
solidusio:mainfrom
codegestalt:remove-default-checkout-payment

Conversation

@danielpuglisi

@danielpuglisi danielpuglisi commented Sep 29, 2021

Copy link
Copy Markdown

This PR is still work in progress.

I'm currently building a shop with solidus and found some logic that seems unnecessary that originated from a 7 year old PR from before the fork: spree/spree#5148

The current behaviour is this:

  1. A user with an existing payment source transitions from delivery to payment state
  2. Spree::Order#add_default_payment_from_wallet gets triggered by the state machine and creates a payment record.
  3. User transitions to confirm state
  4. Through how the checkout logic works with Spree::OrderUpdateAttributes, that default payment does not get reused and is always replaced with a new payment, resulting every time in an invalid payment record:

image

My expectations would be one of the following:

  1. The default payment record has some kind of use (so far I haven't found one) and gets updated instead of invalidated (I'm also not sure how this affects fraud detection)
  2. No default payment record gets created as it has no use

I started this PR by removing Spree::Order#add_default_payment_from_wallet to see what breaks. So far only the spec removed in this commit have been affected but it seems to me that these are directly tied to the creation of the default payment source and have no further use. The only spec I'm unsure about is the one about assigning a billing address if none exists yet, but I can't think of a scenario where this should be the case.

Another thing the removal of Spree::Order#add_default_payment_from_wallet would affect is that it makes Spree::Wallet::DefaultPaymentBuilder obsolete. So I guess there is a concern about breaking compatibility with existing shops that rely on that one. Although I'm not sure what a use case could be.

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

@jarednorman

Copy link
Copy Markdown
Member

This is related to #2680.

@adammathys adammathys 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.

This generally seems reasonable to me. (Removing the add_default_payment_from_wallet method.) I can't see any reason why we would ever want that extra invalid payment and we're always going to create a new one during the payment step of checkout.

I think we should probably start by deprecating the method instead of outright removing it. (Along with maybe deprecating the Spree::Config.default_payment_builder_class config option and corresponding class.) Just in case there's anyone out there relying on this behaviour for some reason.

Then we could add a new configuration option to skip this callback step for everyone ready to remove this functionality ahead of it being removed in a future release. e.g.:

unless Spree::Config.disable_adding_default_payment_to_order
  before_transition to: :payment, do: :add_default_payment_from_wallet
end

@danielpuglisi

Copy link
Copy Markdown
Author

@adammathys makes sense. If there are no other concerns, I'll gladly put something together.

@jarednorman

Copy link
Copy Markdown
Member

Thanks @danielpuglisi (and @adammathys), that would be great!

@danielpuglisi
danielpuglisi force-pushed the remove-default-checkout-payment branch from ec4bdf3 to e53cc37 Compare December 14, 2021 14:46
@danielpuglisi
danielpuglisi force-pushed the remove-default-checkout-payment branch from a90bbe9 to 053acba Compare December 14, 2021 15:35
@danielpuglisi

Copy link
Copy Markdown
Author

Finally got the time to take a jab at this.

Added the deprecation preference and warnings based on @adammathys suggestion. The current default preference although creates a lot of noise when running the specs. What is the preferred way to handle this?

@waiting-for-dev

Copy link
Copy Markdown
Contributor

We appreciate your contribution, @danielpuglisi. After talking with @kennyadsl, we decided to put it on hold for the meantime. It looks like a legit change, although it's entirely possible it'd break some extensions. We feel we need to define a clear path for the evolution of the payment system before introducing more changes.

@waiting-for-dev waiting-for-dev added the release:major Breaking change on hold until next major release label Jun 13, 2022
@danielpuglisi

Copy link
Copy Markdown
Author

I understand. Let me know if I can be of any help in the future.

@kennyadsl kennyadsl added Bug and removed release:major Breaking change on hold until next major release labels Aug 23, 2022
@kennyadsl

Copy link
Copy Markdown
Member

Hey @danielpuglisi, first of all thanks for the PR and sorry for taking so long to come back on this. We'd love to move this forward because this is annoying on all levels (Admin UX and for the developer).

We have a couple of things left to do before we can merge this:

  1. Rebase the PR against master
  2. Change the preference usage to use the new versioned preferences (here you can find a usage example).
  3. run specs of a couple of payment gateway extensions against the local version of solidus that contains this change. I suggest to try with solidus_stripe and solidus_paypal_braintree, which are the most used.

Please let us know if you have time to take care of these last things otherwise, we will happily take over this work as soon as we have some availability.

Thanks again! 🙏

@danielpuglisi

Copy link
Copy Markdown
Author

Hey @kennyadsl. I'm a bit flooded right now. Feel free to take over if you get the time and I haven't done anything.

@waiting-for-dev waiting-for-dev added the changelog:solidus_core Changes to the solidus_core gem label Aug 30, 2022
@tvdeyen tvdeyen self-assigned this Apr 23, 2026
@jarednorman

jarednorman commented Aug 31, 2026

Copy link
Copy Markdown
Member

I'm closing this in favour of #6564. @adammathys is working on broadly improving how payments are handled and this approach is incompatible with his, (besides being suuuuper stale). With payment reuse, we don't need to remove add_default_payment_from_wallet. The transition will do what it intends to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_core Changes to the solidus_core gem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants