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

[BUG] Incorrect functionality to Android SDK #3442

Open
chrisjenx opened this issue Mar 21, 2024 · 1 comment
Open

[BUG] Incorrect functionality to Android SDK #3442

chrisjenx opened this issue Mar 21, 2024 · 1 comment
Labels
kind:bug triaged Issue has been reviewed by Stripe and is being tracked internally

Comments

@chrisjenx
Copy link

Summary

Confirming a Mandate works differently to Android SDK.

Issue 1:
Why do we need the customer ephemeral key at this point? For bank mandates it's not even required for the PaymentLauncher on Android.
Issue 2
The main issue is that your version of STPCustomerContext requires the raw json vs the actual key on android:

 PaymentSheet.CustomerConfiguration(
//                id = stripeSetupIntent.customerId,
//                ephemeralKeySecret = eKey,
//            )

Can we omit the whole STPPaymentContext or at least only pass through just the Key so I don't have to completely change a bankend call when creating a setup intent.

let setupIntentParams = STPSetupIntentConfirmParams(
            clientSecret: stripeSetupIntentResponse.clientSecret,
            paymentMethodType: .USBankAccount
        )
    
        let paymentContext = STPPaymentContext(
            customerContext: STPCustomerContext(
                keyProvider: MyCustomerEphemeralKeyProvider(
                    customerKey: stripeSetupIntentResponse.ephemeralKey!
                )
            )
        )
        return await withCheckedContinuation { continuation in
            STPPaymentHandler.shared().confirmSetupIntent(
                setupIntentParams, with: paymentContext
            ) { (status, intent, error) in
                if(error != nil) {
                    return continuation.resume(returning: AddPaymentMethodResult.Failed(
                        error: KotlinThrowable(message: error?.localizedDescription))
                    )
                }
                switch status {
                case .failed:
                    continuation.resume(returning: AddPaymentMethodResult.Failed(error: KotlinError()))
                case .canceled:
                    continuation.resume(returning: AddPaymentMethodResult.Canceled())
                case .succeeded:
                    continuation.resume(returning: AddPaymentMethodResult.Completed())
                @unknown default:
                    fatalError()
                }
            }
        }

iOS version

15+

Installation method

Pods

SDK version

22.36

Other information

Thirdly why are your SDK so far apart and inconsistant, iOS and Android basically work the same these days, it's not great they work completely differently.

@porter-stripe
Copy link
Collaborator

Hi @chrisjenx

Issue 1:
Why do we need the customer ephemeral key at this point? For bank mandates it's not even required for the PaymentLauncher on Android.

PaymentSheet on iOS and PaymentLauncher on Android are not equivalents. PaymentSheet is called PaymentSheet on both platforms. For example, the PaymentSheet on Android does require a ephemeral key for the customer configuration.
https://github.com/stripe/stripe-android/blob/2f395065d4655723f82b03665521b88bea7fc742/paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt#L340

PaymentLauncher is more similar to STPPaymentHandler on iOS.

Issue 2
The main issue is that your version of STPCustomerContext requires the raw json vs the actual key on android:
Can we omit the whole STPPaymentContext or at least only pass through just the Key so I don't have to completely change a bankend call when creating a setup intent.

You do not need to pass in a STPCustomerContext to confirm a SetupIntent, you simply just need to pass in a type that conforms to STPAuthenticationContext.

public func confirmSetupIntent(
        _ setupIntentConfirmParams: STPSetupIntentConfirmParams,
        with authenticationContext: STPAuthenticationContext,
        completion: @escaping STPPaymentHandlerActionSetupIntentCompletionBlock
)

A common way to do this is something similar to:

extension ExampleViewController: STPAuthenticationContext {
    func authenticationPresentingViewController() -> UIViewController {
        self
    }
}

Then confirm your SetupIntent as:

// Inside of ExampleViewController...

STPPaymentHandler.shared().confirmSetup(
                    setupIntentParams,
                    with: self
                ) { ( ...

You can see this in various examples in the SDK.

Thirdly why are your SDK so far apart and inconsistant, iOS and Android basically work the same these days, it's not great they work completely differently.

Could you elaborate further? Based on my replies above, the functionality is largely the same. Some names are different, but overall functionality and set of available APIs is similar.

Additionally, you mention you are on version 22.36, but we have not published a version 22.36 of the iOS SDK, which version are you on? It is recommended to be on the latest version.

@davidme-stripe davidme-stripe added the triaged Issue has been reviewed by Stripe and is being tracked internally label May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug triaged Issue has been reviewed by Stripe and is being tracked internally
Projects
None yet
Development

No branches or pull requests

3 participants