Skip to content

send idempotency keys with redirect checkout#8736

Open
atavism wants to merge 4 commits intomainfrom
atavism/payment-redirect
Open

send idempotency keys with redirect checkout#8736
atavism wants to merge 4 commits intomainfrom
atavism/payment-redirect

Conversation

@atavism
Copy link
Copy Markdown
Contributor

@atavism atavism commented May 6, 2026

Copilot AI review requested due to automatic review settings May 6, 2026 19:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR threads an idempotencyKey through the app’s payment redirect flows (Flutter → platform channels/FFI → Go core) so the backend can make redirect-checkout/session creation idempotent, addressing the linked engineering issues.

Changes:

  • Added idempotencyKey as a required parameter to the Dart payment redirect APIs and passed it through both FFI and platform-channel implementations.
  • Generated an idempotency key in PaymentNotifier and included it in redirect calls.
  • Updated Go mobile/FFI exports and core payment methods to accept and forward the idempotency key in the redirect request body.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
macos/Runner/Handlers/MethodHandler.swift Reads idempotencyKey from method-channel args and passes it into Go mobile payment redirect calls.
android/app/src/main/kotlin/org/getlantern/lantern/handler/MethodHandler.kt Passes idempotencyKey from method-channel args into Mobile.paymentRedirect.
lib/lantern/lantern_core_service.dart Extends core service interface with required idempotencyKey for redirect methods.
lib/lantern/lantern_service.dart Propagates idempotencyKey through the top-level service wrapper.
lib/lantern/lantern_platform_service.dart Sends idempotencyKey via method channel for macOS/Android redirect flows.
lib/lantern/lantern_ffi_service.dart Sends idempotencyKey into FFI calls for redirect flows.
lib/lantern/lantern_generated_bindings.dart Updates generated FFI bindings signatures to include idempotencyKey.
lib/features/plans/provider/payment_notifier.dart Generates and supplies an idempotency key when starting redirect flows.
lib/core/common/common.dart Adds generatePaymentRedirectIdempotencyKey() helper.
lantern-core/core.go Adds idempotencyKey to redirect APIs and forwards into account.PaymentRedirectData.
lantern-core/ffi/ffi.go Updates exported C functions to accept and forward idempotencyKey.
lantern-core/mobile/mobile.go Updates gomobile exports to accept and forward idempotencyKey.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread macos/Runner/Handlers/MethodHandler.swift Outdated
Comment thread android/app/src/main/kotlin/org/getlantern/lantern/handler/MethodHandler.kt Outdated
Comment thread lantern-core/core.go
Comment thread lantern-core/core.go
Comment thread lantern-core/core.go

func (lc *LanternCore) StripeSubscriptionPaymentRedirect(subscriptionType, planID, email string) (string, error) {
func (lc *LanternCore) StripeSubscriptionPaymentRedirect(subscriptionType, planID, email, idempotencyKey string) (string, error) {
idempotencyKey, err := normalizePaymentRedirectIdempotencyKey(idempotencyKey)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@atavism Do you think we should just create the idempotencyKey key here, since generation is basically the same, so we don't have to pass it through all the platforms? Is there any issue with that?

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.

3 participants