Skip to content

fix(stripe): pass idempotency key for charge intents#6

Open
EfeDurmaz16 wants to merge 1 commit into
stripe:mainfrom
EfeDurmaz16:fix/stripe-payment-intent-idempotency
Open

fix(stripe): pass idempotency key for charge intents#6
EfeDurmaz16 wants to merge 1 commit into
stripe:mainfrom
EfeDurmaz16:fix/stripe-payment-intent-idempotency

Conversation

@EfeDurmaz16
Copy link
Copy Markdown

Summary

Adds a Stripe idempotency key when the Ruby Stripe charge intent creates and confirms a PaymentIntent.

The key is derived from the MPP challenge ID, so retries of the same verified charge operation reuse the same logical Stripe request instead of risking a duplicate PaymentIntent creation. This matches Stripe's guidance to pass idempotency keys in request options for POST create/update calls.

Changes

  • Pass { idempotency_key: ... } as the Stripe SDK request options when creating the PaymentIntent
  • Derive the key from the MPP challenge ID: mpp-stripe-charge-<challenge_id>
  • Update Stripe charge intent tests to assert the idempotency option is sent

Verification

  • mise exec ruby@3.3 -- ruby -Ilib:test test/mpp/methods/stripe/test_charge_intent.rb
  • mise exec ruby@3.3 -- standardrb lib/mpp/methods/stripe/charge_intent.rb test/mpp/methods/stripe/test_charge_intent.rb
  • git diff --check

Note: full bundle install could not complete in my local macOS environment because the rbsecp256k1 native extension needs aclocal while building eth. The targeted Stripe test and StandardRB check both ran successfully after installing Ruby 3.3 with mise.

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.

1 participant