Skip to content

Commit

Permalink
Add captureMethod to Stripe Elements options
Browse files Browse the repository at this point in the history
- 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 during the
confirm to complete order transition, causing the payment to fail.

Reference: https://stripe.com/docs/js/elements_object/create_without_intent
  • Loading branch information
rainerdema committed Mar 30, 2023
1 parent d465a72 commit 1a699cb
Showing 1 changed file with 1 addition and 0 deletions.
Expand Up @@ -6,6 +6,7 @@
),
currency: current_order.currency.downcase,
paymentMethodCreation: 'manual',
captureMethod: payment_method.auto_capture? ? 'automatic' : 'manual',
# Fully customizable with appearance API.
# https://stripe.com/docs/elements/appearance-api
# appearance: {},
Expand Down

0 comments on commit 1a699cb

Please sign in to comment.