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

Allow reuse of payment sources via admin #278

Merged

Conversation

rainerdema
Copy link
Contributor

@rainerdema rainerdema commented Apr 13, 2023

Summary

ℹ️ Please refer to #280 for more details about specific implementation decisions.

  • Allow the admin to reuse existing payment sources by introducing a dedicated source form.
    This enables the reuse of payment sources within the user's wallet (preventing the use of payment methods that the user has removed from their wallet).
  • Re-introduce authorize and purchase gateway methods

Screenshot 2023-04-13 at 20 03 09

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@rainerdema rainerdema added the enhancement New feature or request label Apr 13, 2023
@rainerdema rainerdema self-assigned this Apr 13, 2023
@rainerdema rainerdema force-pushed the rainerd/support-stripe-payment-creation-in-solidus-backend branch 3 times, most recently from 2accbfc to 256ff7e Compare April 14, 2023 11:25
@codecov
Copy link

codecov bot commented Apr 14, 2023

Codecov Report

Merging #278 (33b0ad4) into master (1136a79) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #278      +/-   ##
==========================================
+ Coverage   99.59%   99.62%   +0.03%     
==========================================
  Files          27       30       +3     
  Lines         489      540      +51     
==========================================
+ Hits          487      538      +51     
  Misses          2        2              
Impacted Files Coverage Δ
app/models/solidus_stripe/gateway.rb 100.00% <100.00%> (ø)
app/models/solidus_stripe/payment_intent.rb 100.00% <100.00%> (ø)
app/models/solidus_stripe/payment_method.rb 100.00% <100.00%> (ø)
...spree/admin/payments/source_forms/_stripe.html.erb 100.00% <100.00%> (ø)
...nts/source_forms/existing_payment/_stripe.html.erb 100.00% <100.00%> (ø)
...ource_forms/existing_payment/stripe/_card.html.erb 100.00% <100.00%> (ø)
lib/solidus_stripe/testing_support/factories.rb 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@rainerdema rainerdema force-pushed the rainerd/support-stripe-payment-creation-in-solidus-backend branch 5 times, most recently from 8a0c877 to 2186d27 Compare April 17, 2023 15:48
@rainerdema rainerdema marked this pull request as ready for review April 17, 2023 16:00
Copy link
Member

@elia elia left a comment

Choose a reason for hiding this comment

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

Just a couple of nits

💯 on having an issue open on solidus, we should mark it for fixing whenever we touch that part of the admin (at worst).

app/models/solidus_stripe/gateway.rb Show resolved Hide resolved
app/models/solidus_stripe/payment_intent.rb Outdated Show resolved Hide resolved
@rainerdema rainerdema force-pushed the rainerd/support-stripe-payment-creation-in-solidus-backend branch 2 times, most recently from 98378cd to 140bfbc Compare April 17, 2023 16:53
Copy link
Contributor

@waiting-for-dev waiting-for-dev left a comment

Choose a reason for hiding this comment

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

Thanks, @rainerdema! Great work and great investigation 👏 Left some comments.

app/models/solidus_stripe/gateway.rb Show resolved Hide resolved
app/models/solidus_stripe/payment_method.rb Show resolved Hide resolved
app/models/solidus_stripe/gateway.rb Show resolved Hide resolved
@rainerdema rainerdema force-pushed the rainerd/support-stripe-payment-creation-in-solidus-backend branch from 140bfbc to 55fbb3c Compare April 18, 2023 06:31
This is needed to allow the use of the payment method in the admin interface.
This commit re-introduce the `authorize` and `purchase` methods as they are now handled also backend-side.
@rainerdema rainerdema force-pushed the rainerd/support-stripe-payment-creation-in-solidus-backend branch from 55fbb3c to 3552394 Compare April 18, 2023 06:48
@rainerdema rainerdema force-pushed the rainerd/support-stripe-payment-creation-in-solidus-backend branch from 3552394 to c8c289a Compare April 18, 2023 07:53
This commit adds the Stripe source form partial with only the option to
reuse existing payment sources.
In addition, a logic similar to the one used in the front end is also
implemented to render custom partials for each type of Stripe Payment Method.
This is important to prevent reusing intents with different amount.
@rainerdema rainerdema force-pushed the rainerd/support-stripe-payment-creation-in-solidus-backend branch from c8c289a to 33b0ad4 Compare April 18, 2023 08:11
Copy link
Contributor

@waiting-for-dev waiting-for-dev left a comment

Choose a reason for hiding this comment

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

🙌

@rainerdema rainerdema merged commit 2c4f20d into master Apr 18, 2023
@rainerdema rainerdema deleted the rainerd/support-stripe-payment-creation-in-solidus-backend branch April 18, 2023 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants