#nerder_unexpected
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/1309493295906422835
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- nerder_best-practices, 1 day ago, 72 messages
- nerder_error, 3 days ago, 62 messages
Hey @stray turtle, this one seems like a strange bug with Apple Pay, but maybe there is something I don't know and there is some sort of caching going on
hi! not sure what you mean without seeing exact code/context/error messages/logs etc. Why would you call it multiple times?
Imagine the customer purchase 1 thing, and they within the same session they would like to purchase another
extension STPAPIClient {
// MARK: Tokens
func createToken(
withParameters parameters: [String: Any],
completion: @escaping STPTokenCompletionBlock
) {
let tokenType = STPAnalyticsClient.tokenType(fromParameters: parameters)
STPAnalyticsClient.sharedClient.logTokenCreationAttempt(
with: _stored_configuration,
tokenType: tokenType
)
let preparedParameters = Self.paramsAddingPaymentUserAgent(parameters)
APIRequest<STPToken>.post(
with: self,
endpoint: APIEndpointToken,
parameters: preparedParameters
) { object, _, error in
completion(object, error)
}
}
}
i'm talking about this, from your SDK
If I put a breakpoint at APIRequest<STPToken>.post i see the program reaching there
but then in the workbanch logs i don't see the POST request actually arriving
If you check this req_le5uB5qLlpaefT
this is correct and has been sent by the IOS SDK
sorry is this your code above or is that in our SDK source?
SDK source
and they within the same session they would like to purchase another
I mean they still have to go through the process of clicking the Apple Pay UI as a separate process for each attempt.
What is the code that you're writing to invoke this and call createToken?
Yes this happens
this is the method that i use from Dart
@override
Future<String> retrieveToken({
required WalletType walletType,
required Map<String, dynamic> paymentResult,
}) async {
if (walletType == WalletType.apple_pay) {
final token = await _stripe.createApplePayToken(paymentResult);
return token.id;
}
if (walletType == WalletType.google_pay) {
final token = paymentResult['paymentMethodData']['tokenizationData']['token'];
final tokenJson = Map.castFrom(json.decode(token));
return tokenJson['id'];
}
throw Exception("Unsupported wallet type");
}
the interesting bit from the flutter_stripe implementation is this:
STPAPIClient.shared.createToken(with: payment) { (token, error) in
if error != nil || token == nil {
result(Errors.createError("Failed", error?.localizedDescription ?? ""))
} else {
result(Mappers.createResult("token", Mappers.mapFromToken(token: token!)))
}
}
} catch {
result(Errors.createError("Failed", error.localizedDescription ))
}
which as you can see end up calling the SDK code i've pasted above
If i restart the app, the first time it works perfectly
then any other attempt to pay with Apple Pay will fail, because I try to create a PM from the token, but the token is not getting created by the SDK
it's quite weird and unexpected tbh
no idea really, there's so much context I don't have on the overall integration. I'm not aware of anything in our SDK that caches or prevents a request like that
Yes, i'll be probably end up opening an issue on the SDK itself
we'll probably just tell you that it could be something in the flutter/dart code above really, it's too hard to say without a clean self-contained repro.
also not sure if you realised but a few minutes after req_le5uB5qLlpaefT you mentioned above, you ran a request to v1/tokens, but on a connected account. Maybe that's related and it's where your 'missing' request went
like check this: req_139wlxPd1EH4TT
wait, might be that i'm not seeing in workbanch events sent to connected accounts?
omg, I know what is happening
This was the gotcha!
yes I see, I think I misunderstood what you were saying and that you were claiming the SDK never made a request and you verified that with the breakpoint. But I see what you meant was it made the request but you couldn't find it, which yes, is because it was done as a Connect request on a different account
damn
yes, and the fact that the same code suceed the first time and the second it fails
is because I do that
_setupConnectedAccount(String? stripeAccountId) {
Stripe.stripeAccountId = stripeAccountId;
}
so basically the first time as createToken has been called before confirmPayment the Stripe client is not setup to call the connected account
then since the instance doesn't change within the same session
and i'm no resetting that to null
the second subsequent call to createToken is done on the connected account