#shiva_code
1 messages · Page 1 of 1 (latest)
👋 Welcome to your new thread!
⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1386851091454627972
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
hello! looking at this now
hmm i'm not super familiar with how to do this specifically in iOS but i might be able to take a stab at it. any chance you can share your code where you're creating the ephemeral key, customer, and then configuring the EmbeddedPaymentElement?
wait you already shared some, let me take a look at that
let me see if i can build this out in my own test app real quick too
ahh it looks like i do have a functional example already. let me compare it with the code you shared...
Hey thanks for getting back so quickly. Here is the full code I used to setup the embeddable view
private func loadEmbeddedViewModel(_ booking: Booking) async {
do {
let intentConfiguration = PaymentSheet.IntentConfiguration(
mode: .payment(amount: booking.revenueInCents, currency: "MYR", setupFutureUsage: .offSession)
) { _, _, intentCreationCallback in
self.handleConfirm(booking, intentCreationCallback)
}
let customerSession = try await getStripeSession()
var configuration = EmbeddedPaymentElement.Configuration()
configuration.merchantDisplayName = "Myapp"
configuration.returnURL = "com.myapp.app://stripe-redirect"
// configuration.savePaymentMethodOptInBehavior = .requiresOptOut
configuration.customer = .init(id: customerSession.stripeCustomerId, ephemeralKeySecret: customerSession.ephemeralKey)
try await stripeEmbeddedViewModel.load(intentConfiguration: intentConfiguration, configuration: configuration)
currentIntentConfig = intentConfiguration
} catch {
debugPrint("Unable to load embedded view model: \(error.localizedDescription)")
}
}
fyi code looks much better if you wrap it in triple backticks! single works too
hmmm nothing looks obviously wrong with what you've shared so far. can you share stripeEmbeddedViewModel too?
Update the backticks. Good suggestions
The stripeEmbeddedViewModel is a EmbeddedPaymentElementViewModel. There’s nothing else done beyond calling the load function
Hi! Stepping in for my colleague! You should remove setupFutureUsage: .offSession from the configuration. Adding setupFutureUsage tells Stripe SDK that the payment method will be saved so the UI won't show the "save card for future usage" checkbox.
Alright, this makes sense. Let me give this a try and report back later today. Thanks @remote thicket @native pelican