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

Support auto_capture for the Stripe payment method #260

Merged
merged 2 commits into from Mar 31, 2023

Conversation

rainerdema
Copy link
Contributor

@rainerdema rainerdema commented Mar 29, 2023

Summary

Fixes #178

With this PR, the Solidus auto-capture feature has been incorporated into the Stripe integration through the use of the auto_capture flag in the Spree::PaymentMethod base model.
Stripe capture_method is now auto-configured during the intent creation with "manual" or "automatic" based on the auto_capture flag in the related payment method.

More information can be found in the Stripe documentation:
https://stripe.com/docs/api/payment_intents/object#payment_intent_object-capture_method

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 Mar 29, 2023
@rainerdema rainerdema self-assigned this Mar 29, 2023
@rainerdema rainerdema force-pushed the rainer/auto-capture-support branch 3 times, most recently from 5d68c75 to 769c05b Compare March 29, 2023 16:30
@rainerdema rainerdema force-pushed the elia+rainer/thanks-stripe-beta-team branch from 64caa28 to 265aa6e Compare March 29, 2023 16:42
@codecov
Copy link

codecov bot commented Mar 29, 2023

Codecov Report

Merging #260 (dcafcca) into elia+rainer/thanks-stripe-beta-team (1cab1dc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@                         Coverage Diff                          @@
##           elia+rainer/thanks-stripe-beta-team     #260   +/-   ##
====================================================================
  Coverage                                99.77%   99.77%           
====================================================================
  Files                                       24       24           
  Lines                                      442      446    +4     
====================================================================
+ Hits                                       441      445    +4     
  Misses                                       1        1           
Impacted Files Coverage Δ
app/models/solidus_stripe/payment_intent.rb 100.00% <100.00%> (ø)
...lates/app/views/checkouts/payment/_stripe.html.erb 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 elia+rainer/thanks-stripe-beta-team branch from 265aa6e to 0723ed7 Compare March 30, 2023 10:44
@rainerdema rainerdema force-pushed the rainer/auto-capture-support branch 2 times, most recently from 2e2087e to a69f0ef Compare March 30, 2023 10:55
@rainerdema rainerdema marked this pull request as ready for review March 30, 2023 11:07
@elia elia force-pushed the elia+rainer/thanks-stripe-beta-team branch from 0723ed7 to 1cab1dc Compare March 30, 2023 11:57
With this commit, the Solidus auto-capture feature has been incorporated into
the Stripe integration through the use of the auto_capture flag in
the Spree::PaymentMethod base model.
Stripe `capture_method` is now auto configured during the intent creation with
 "manual" or "automatic" based on the auto_capture flag in the related
payment method.

More information can be found in the Stripe documentation:
https://stripe.com/docs/api/payment_intents/object#payment_intent_object-capture_method
- Update payment_element_options hash to include the `captureMethod` parameter
- Ensure captureMethod value matches the capture_method provided when creating
the Payment Intent

Adding `captureMethod` improves security by ensuring that the capture_method
value used during payment method creation matches the value provided when
creating the Payment Intent. This helps prevent fraudulent activity and errors,
such as a scenario where an admin changes the auto-capture mode after the
Stripe Payment Method creation, causing the payment to fail.

Reference: https://stripe.com/docs/js/elements_object/create_without_intent
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!!

Base automatically changed from elia+rainer/thanks-stripe-beta-team to master March 31, 2023 10:48
@rainerdema rainerdema merged commit 5bc8eb6 into master Mar 31, 2023
2 checks passed
@rainerdema rainerdema deleted the rainer/auto-capture-support branch March 31, 2023 10:59
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
Development

Successfully merging this pull request may close these issues.

Support auto_capture: true for the payment method
3 participants