From 0539ede3de6ae8335a8622414d055dc7be224ea2 Mon Sep 17 00:00:00 2001 From: porter Date: Thu, 11 Jun 2026 15:31:36 +0000 Subject: [PATCH] Remove updateCheckout from EmbeddedPaymentElement Remove the updateCheckout(checkout) method from the EmbeddedPaymentElement class and all associated native plumbing across iOS, Android, and JS/TS. - Remove updateCheckout method from EmbeddedPaymentElement class - Remove updateEmbeddedPaymentElementWithCheckout from native module spec - Remove updateWithCheckout from NativeCommands and supportedCommands - Remove iOS implementation in StripeSdkImpl+Embedded.swift and bridge - Remove Android Event.UpdateWithCheckout and its handler - Remove updateWithCheckout command from ViewManager and oldarch files - Remove updateWithCheckout stub from NewArch ComponentView - Update hook's update callback to only accept IntentConfiguration The existing updateIntent functionality is unaffected. Committed-By-Agent: goose --- .../EmbeddedPaymentElementView.kt | 22 ------------- .../EmbeddedPaymentElementViewManager.kt | 22 ------------- .../reactnativestripesdk/StripeSdkModule.kt | 9 ------ ...ddedPaymentElementViewManagerDelegate.java | 3 -- ...dedPaymentElementViewManagerInterface.java | 1 - .../NativeStripeSdkModuleSpec.java | 4 --- etc/stripe-react-native.api.md | 5 +-- ...EmbeddedPaymentElementViewComponentView.mm | 4 --- ios/StripeSdk.mm | 7 ----- ios/StripeSdkImpl+Embedded.swift | 24 -------------- src/specs/NativeEmbeddedPaymentElement.ts | 11 +------ src/specs/NativeStripeSdkModule.ts | 3 -- src/types/EmbeddedPaymentElement.tsx | 31 +++---------------- 13 files changed, 6 insertions(+), 140 deletions(-) diff --git a/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt b/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt index 4ee0c2dac6..70807a08e6 100644 --- a/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +++ b/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt @@ -64,10 +64,6 @@ class EmbeddedPaymentElementView( val intentConfiguration: PaymentSheet.IntentConfiguration, ) : Event - data class UpdateWithCheckout( - val checkout: Checkout, - ) : Event - data object Confirm : Event data object ClearPaymentOption : Event @@ -347,20 +343,6 @@ class EmbeddedPaymentElementView( latestIntentConfig = ev.intentConfiguration } - is Event.UpdateWithCheckout -> { - val elemConfig = latestElementConfig ?: return@collect emitUpdateMissingConfiguration() - - val result = - embedded.configure( - checkout = ev.checkout, - configuration = elemConfig, - ) - - handleUpdateResult(result) - - latestCheckout = ev.checkout - } - is Event.Confirm -> { embedded.confirm() } @@ -506,10 +488,6 @@ class EmbeddedPaymentElementView( events.trySend(Event.Update(intentConfig)) } - fun updateWithCheckout(checkout: Checkout) { - events.trySend(Event.UpdateWithCheckout(checkout)) - } - fun confirm() { events.trySend(Event.Confirm) } diff --git a/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt b/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt index d3bf40bf26..34c6046d95 100644 --- a/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +++ b/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt @@ -244,28 +244,6 @@ class EmbeddedPaymentElementViewManager : } } - override fun updateWithCheckout( - view: EmbeddedPaymentElementView, - sessionKey: String?, - ) { - if (sessionKey == null) return - - val stripeSdkModule = - (view.context as ThemedReactContext).getNativeModule(StripeSdkModule::class.java) - val checkout = stripeSdkModule?.checkoutInstances?.get(sessionKey) - if (checkout == null) { - val payload = - Arguments.createMap().apply { - putString("message", "Checkout session not found.") - } - stripeSdkModule?.eventEmitter?.emitEmbeddedPaymentElementLoadingFailed(payload) - stripeSdkModule?.eventEmitter?.emitEmbeddedPaymentElementUpdateComplete(null) - return - } - - view.updateWithCheckout(checkout) - } - private fun jsonToWritableMap(json: JSONObject): WritableMap { val map = Arguments.createMap() val keys = json.keys() diff --git a/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt b/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt index 81603c6bfe..ee259097ba 100644 --- a/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +++ b/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt @@ -1443,15 +1443,6 @@ class StripeSdkModule( // TODO: } - @ReactMethod - override fun updateEmbeddedPaymentElementWithCheckout( - sessionKey: String, - promise: Promise, - ) { - // No-op on Android. JS dispatches Checkout updates through the view command instead. - promise.resolve(null) - } - @ReactMethod override fun clearEmbeddedPaymentOption( viewTag: Double, diff --git a/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java b/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java index 5d46cc5be4..2d142968da 100644 --- a/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +++ b/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java @@ -50,9 +50,6 @@ public void receiveCommand(T view, String commandName, @Nullable ReadableArray a case "update": mViewManager.update(view, args != null ? args.getString(0) : null); break; - case "updateWithCheckout": - mViewManager.updateWithCheckout(view, args != null ? args.getString(0) : null); - break; } } } diff --git a/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java b/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java index 4d37b7bd29..6806907b7f 100644 --- a/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +++ b/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java @@ -20,5 +20,4 @@ public interface EmbeddedPaymentElementViewManagerInterface { void confirm(T view); void clearPaymentOption(T view); void update(T view, @Nullable String intentConfigurationJson); - void updateWithCheckout(T view, @Nullable String sessionKey); } diff --git a/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java b/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java index bee610bf50..661439908c 100644 --- a/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +++ b/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java @@ -265,10 +265,6 @@ private void invoke(String eventName) { @DoNotStrip public abstract void updateEmbeddedPaymentElement(ReadableMap intentConfig, Promise promise); - @ReactMethod - @DoNotStrip - public abstract void updateEmbeddedPaymentElementWithCheckout(String sessionKey, Promise promise); - @ReactMethod @DoNotStrip public abstract void clearEmbeddedPaymentOption(double viewTag, Promise promise); diff --git a/etc/stripe-react-native.api.md b/etc/stripe-react-native.api.md index df1e64484e..f09f044de0 100644 --- a/etc/stripe-react-native.api.md +++ b/etc/stripe-react-native.api.md @@ -4000,10 +4000,7 @@ export interface UseEmbeddedPaymentElementResult { // (undocumented) loadingError: Error | null; paymentOption: PaymentOptionDisplayData | null; - update: { - (intentConfig: PaymentSheet.IntentConfiguration): void; - (checkout: Checkout): void; - }; + update: (intentConfig: PaymentSheet.IntentConfiguration) => void; } // @public diff --git a/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm b/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm index b662344a68..00c93096e5 100644 --- a/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm +++ b/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm @@ -68,10 +68,6 @@ - (void)update:(NSString *)intentConfigurationJson { } -- (void)updateWithCheckout:(NSString *)sessionKey -{ -} - #pragma mark - RCTComponentViewProtocol + (ComponentDescriptorProvider)componentDescriptorProvider diff --git a/ios/StripeSdk.mm b/ios/StripeSdk.mm index 30237eec8f..691221fe0d 100644 --- a/ios/StripeSdk.mm +++ b/ios/StripeSdk.mm @@ -578,13 +578,6 @@ - (instancetype)init [StripeSdkImpl.shared updateEmbeddedPaymentElement:intentConfig resolve:resolve reject:reject]; } -RCT_EXPORT_METHOD(updateEmbeddedPaymentElementWithCheckout:(nonnull NSString *)sessionKey - resolve:(nonnull RCTPromiseResolveBlock)resolve - reject:(nonnull RCTPromiseRejectBlock)reject) -{ - [StripeSdkImpl.shared updateEmbeddedPaymentElementWithCheckout:sessionKey resolve:resolve reject:reject]; -} - RCT_EXPORT_METHOD(clearEmbeddedPaymentOption:(NSInteger)viewTag resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject) diff --git a/ios/StripeSdkImpl+Embedded.swift b/ios/StripeSdkImpl+Embedded.swift index 6327cac455..9ca6554444 100644 --- a/ios/StripeSdkImpl+Embedded.swift +++ b/ios/StripeSdkImpl+Embedded.swift @@ -213,30 +213,6 @@ extension StripeSdkImpl { } } - @objc(updateEmbeddedPaymentElementWithCheckout:resolve:reject:) - public func updateEmbeddedPaymentElementWithCheckout( - sessionKey: String, - resolve: @escaping RCTPromiseResolveBlock, - reject: @escaping RCTPromiseRejectBlock - ) { - guard let checkout = checkoutInstances[sessionKey] else { - resolve(Errors.createError(ErrorType.Failed, "Checkout session not found")) - return - } - - Task { - guard let updateResult = await self.embeddedInstance?.update(checkout: checkout) else { - resolve(Errors.createError( - ErrorType.Failed, - "No EmbeddedPaymentElement instance — did you call create first?" - )) - return - } - - self.resolveEmbeddedUpdateResult(updateResult, resolve: resolve) - } - } - @objc(clearEmbeddedPaymentOption) public func clearEmbeddedPaymentOption() { DispatchQueue.main.async { diff --git a/src/specs/NativeEmbeddedPaymentElement.ts b/src/specs/NativeEmbeddedPaymentElement.ts index eaa50791ba..311d4e4666 100644 --- a/src/specs/NativeEmbeddedPaymentElement.ts +++ b/src/specs/NativeEmbeddedPaymentElement.ts @@ -20,19 +20,10 @@ export interface NativeCommands { viewRef: React.ElementRef>, intentConfigurationJson: string ) => void; - updateWithCheckout: ( - viewRef: React.ElementRef>, - sessionKey: string - ) => void; } export const Commands: NativeCommands = codegenNativeCommands({ - supportedCommands: [ - 'confirm', - 'clearPaymentOption', - 'update', - 'updateWithCheckout', - ], + supportedCommands: ['confirm', 'clearPaymentOption', 'update'], }); type ComponentType = HostComponent; diff --git a/src/specs/NativeStripeSdkModule.ts b/src/specs/NativeStripeSdkModule.ts index 7c49e91183..596b6ca0a8 100644 --- a/src/specs/NativeStripeSdkModule.ts +++ b/src/specs/NativeStripeSdkModule.ts @@ -209,9 +209,6 @@ export interface Spec extends TurboModule { updateEmbeddedPaymentElement( intentConfig: UnsafeObject ): Promise | null>; - updateEmbeddedPaymentElementWithCheckout( - sessionKey: string - ): Promise | null>; clearEmbeddedPaymentOption(viewTag: Int32): Promise; createRadarSession(): Promise; diff --git a/src/types/EmbeddedPaymentElement.tsx b/src/types/EmbeddedPaymentElement.tsx index ba63e03ca1..c79d885334 100644 --- a/src/types/EmbeddedPaymentElement.tsx +++ b/src/types/EmbeddedPaymentElement.tsx @@ -251,12 +251,6 @@ class EmbeddedPaymentElement { ); } - async updateCheckout(checkout: Checkout): Promise { - return await NativeStripeSdkModule.updateEmbeddedPaymentElementWithCheckout( - checkout.sessionKey - ); - } - /** * Confirm the payment or setup intent. * Waits for any in-progress `update()` call to finish before proceeding. @@ -438,16 +432,7 @@ export interface UseEmbeddedPaymentElementResult { * @note Upon completion, `paymentOption` may become null if it's no longer available. * @note If you call `update` while a previous call to `update` is still in progress, the previous call is canceled. */ - update: { - (intentConfig: PaymentSheetTypes.IntentConfiguration): void; - /** - * Call this method when the Checkout Session values you used to initialize - * `EmbeddedPaymentElement` change. - * @checkoutSessionsPreview - * @internal - */ - (checkout: Checkout): void; - }; + update: (intentConfig: PaymentSheetTypes.IntentConfiguration) => void; // Sets the currently selected payment option to null clearPaymentOption: () => void; // Any error encountered during creation/update, or null @@ -642,9 +627,7 @@ export function useEmbeddedPaymentElement( return getElementOrThrow(elementRef).confirm(); }, [isAndroid]); const update = useCallback( - ( - updateSource: PaymentSheetTypes.IntentConfiguration | Checkout - ): Promise => { + (updateSource: PaymentSheetTypes.IntentConfiguration): Promise => { if (isAndroid) { const currentRef = viewRef.current; if (currentRef) { @@ -656,11 +639,7 @@ export function useEmbeddedPaymentElement( resolve(result); } ); - if (isCheckoutSession(updateSource)) { - Commands.updateWithCheckout(currentRef, updateSource.sessionKey); - } else { - Commands.update(currentRef, JSON.stringify(updateSource)); - } + Commands.update(currentRef, JSON.stringify(updateSource)); }); } return Promise.reject( @@ -670,9 +649,7 @@ export function useEmbeddedPaymentElement( // iOS: use native module directly const embeddedElement = getElementOrThrow(elementRef); - return isCheckoutSession(updateSource) - ? embeddedElement.updateCheckout(updateSource) - : embeddedElement.updateIntent(updateSource); + return embeddedElement.updateIntent(updateSource); }, [isAndroid] );