#Adrian Moreno
1 messages · Page 1 of 1 (latest)
Hi there. What's the issue you're seeing exactly
Hi!
The issue is when I do this:
paymentHandler.confirmPayment(
paymentIntentParams,
with: authContext
) { (status, _, _) in
switch status {
case .failed:
self.isLoading.value = false
self.stripeFailedCallback.fire()
case .canceled:
self.isLoading.value = false
self.stripeCancelledCallback.fire()
case .succeeded:
self.addDayToCalendarService()
self.purchaseService()
@unknown default:
self.isLoading.value = false
self.stripeFailedCallback.fire()
}
}```
The part inside of the succeeded isn't being executed when the payment with Klarna has been completed
Gotcha. What about if the payment fails or is canceled, do those blocks execute?
Yes, they work perfect
Does the default case execute on success or nothing happens?
Nothing happens
Well, what happen is that the app is redirected because of the deeplink
paymentIntentParams.paymentMethodParams = klarnaMethodParams
paymentIntentParams.returnURL = deepLink ```
That's on top of the previous code I sent you
Hm gotcha. Let me see if I can get a colleague who's more familiar with iOS to check this out. Will get back to you
Perfect, thank you
Hello 👋
Just to clarify, when you say the code inside .succeeded isn't getting executed are you seeing any errors in your logs which could indicate something going wrong?
Have you tried setting a breakpoint on the switch .succeeded ?
Is it being called or just getting skipped altogether?
Skipped afaik
Can you double check just in case? I'd also recommend using the stepper to see what case is being followed if not succeeded
Also you mentioned it works fine for other payment methods?
what happens when you set a breakpoint on the switch status and step through the execution cycle?
I'm executing it right now, it's taking a little bit more than expected to compile
NP! Take your time 🙂
Weird
It ignored the whole switch
Just completed the payment and jumped directly to the deeplink
Perfect, let me know if there's something you want me to explain
Basically as summary:
- I'm configuring Klarna payment with iOS and the part where I do the switch case isn't working as expected when I complete the payment.
Hmmm weird
The code looks fine as far as I can tell...
Can you try commenting out the switch statement completely and just do a really simple print statment?
Just see if your callback is getting hit at all without the switch
All good
If I don't complete the payment at least does the print
I'm checking now if completing the payment
Okey, completing the payment don't
It directly jumps to the deeplink
Okay so it is indeed the deeplink stopping this next code from running 🤔
Wait
When you "dont complete the payment"
This means you failed it?
So it still deep links for this back to your app, no?
Ah okay so without the deeplink firing
The deeplink gets fired when you fail the payment?
It should I believe if you attempted to authorize with Klarna but it failed authorization
Hmmm maybe not though. I might be misremembering...
Hmmm, then I have another problem because my deeplink is supposed to go to the complete payment screen but that's a different issue 😂
Right that's why I'm thinking I'm wrong 🙂
First I want to fix the issue with the deeplink not letting the rest of the switch work
Do you have any idea what should I start checking first? Because I'm not sure at what point the deeplink gets fired
Do you know if there's any option to just don't fire any deeplink?
Just complete the switch as usually
Sure you can just stick any return_url in there to test
you don't have to deep link
But it is a bad experience and you do want to deep link
But that is a good thing to start with
In terms of testing
Have you confirmed the deep link works in other places?
Yes
So if you use a different PaymentMethod it deeplinks correctly?
Also, are you using PaymentSheet or integrating Klarna directly?
Looks like Payment Sheet, right?
I have deeplinks for entering the app from an url and have tested that deeplink itself from outside and does what it's supposed to do
It's not exactly a Payment Sheet
Which guide did you follow?
Gotcha so yeah not Payment Sheet
Ah wait
Nvm you do have handlerStatus set
status in your case
Yeah hmmm
Yes, it's only status but works too xD
Also it clearly isn't the switch statement
It's the part inside the confirmPayment
Can you confirm that that the code afterwards does fire if you use a non-deeplink returnURL?
paymentIntentParams,
with: authContext
) { (status, _, _) in
some code that's not being executed when I complete the payment
} ```
Like can you try just www.example.com?
I'll try
If the returnURL is www.example.com I can't even go to the payment page
Just goes to the status.failed directly
Hrmmm
What if you remove the returnURL completely?
Can't remember if it is required here.
Huh I don't think this should be required iirc.
I think it should just open a default web view
What error are you seeing?
Let me check
Yeah confirmed that returnURL isn't required
So curious why this is failing
Only thing required is the clientSecret
It's in spanish but it seems is required
Optional("Error Domain=com.stripe.lib Code=50 "Se ha producido un error inesperado. Vuelve a intentarlo en unos segundos" UserInfo={com.stripe.lib:ErrorParameterKey=returnUrl, com.stripe.lib:StripeErrorCodeKey=parameter_invalid_empty, NSLocalizedDescription=Se ha producido un error inesperado. Vuelve a intentarlo en unos segundos, com.stripe.lib:ErrorMessageKey=Especificaste una cadena vacÃa para 'return_url'. Asumimos que los valores vacÃos son un intento de anular un parámetro; no obstante, 'return_url' no se puede anular. Debes eliminar 'return_url' de tu petición o suministrar un valor que no esté vacÃo.,
It says: return_url can not be null
With card I don't need the returnURL and works perfect
There's no error with that one
Also can you add { (handlerStatus, paymentIntent, error) and print("error: ", error) afterward
I get the payment screen
Yep
kk let me kow
I get the <- Return to Merchant screen
Works
Okay so at least we know the deeplink is indeed the issue and everything else is fine
It goes to .succeded
Can you show me your deeplink code?
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
window!.rootViewController = myApp.initialScreen
guard let url = URLContexts.first?.url else {
return
}
if url.absoluteString.contains("stripe-redirect"), let deeplink = URL(string: url.absoluteString) {
goToConfirmPayment(deeplink)
} else if let deeplink = URL(string: url.absoluteString.replacingOccurrences(of: "home/", with: "")) {
adjustDeeplinkResponse(deeplink)
}
window?.makeKeyAndVisible()
ApplicationDelegate.shared.application(
UIApplication.shared,
open: url,
sourceApplication: nil,
annotation: [UIApplication.OpenURLOptionsKey.annotation]
)
} ```
Then the confirmPayment function just goes to the complete payment page with the correct parameters.
Not sure if that's what you want to see
I'm not an iOS expert but that looks fine as far as I can tell....
Is there a way to close the SVC when the payment gets completed?
Don't think so
What version of our iOS SDK are you using?
I think the next step here will have to be for us to reproduce this flow and ensure there is nothing bugged on our end. Then play with it in the way you are handling it to find out what is going on. I'm not sure how much more troubleshooting we will be able to do here unfortunately.
22.6.0
Should I update to the last version?
You can try that... it shouldn't really make a difference
But I'm out of ideas so probably worth it.
I'm gonna update and see what happens then
Sounds good
I updated but on the website it says the last released version is 23.3.1
I get the 22.8.4 when I update from XCode, any idea why?
Minimum iOS version for 23.0.0 is 13.0. Maybe you are still set to 12.0?
Ah
I know why
In 23.0.0 we split up the modules
Aaaaaah, makes sense
Hello! I'm taking over and catching up...
Hi!
To clarify, the issue is that goToConfirmPayment(deeplink) is not running, correct? If you log url immediately after the guard let url block what URL are you seeing? Is it what you expect?
The issue is that when I go to the SVC to pay with Klarna and complete the payment the deeplink gets fired right as soon as I complete the payment and the paymentHandler.confirmPayment() don't complete the switch .succeded
So goToConfirmPayment(deeplink) is being run?
In your confirmPayment handler you have (status, _, _) which means you're ignoring the last argument, the error. If you change that to (status, _, error) and then log the error out do you see anything? Or does it not run at all, ever?
Where is paymentHandler coming from?
let paymentHandler = STPPaymentHandler.shared()
Not sure if that's what u are asking
Yep, that's what I was asking! Let me think on this for a bit...
Okey, thanks!
Let me know if you have an update 😄
I've got another question: what is authContext and where is it coming from?
STPAuthenticationContext
Right, but where is it coming from? Can you share that code?
guard klarnaPayRequirementsValidated else { return }
viewModel.inputs.klarnaPayPurchase(withAuthenticationContext: self)
} ```
Is that what you need?
Where is the authContext variable being set?
Hm. Yeah, I'm not sure what else to check. Did upgrading the version of the SDK change anything?
// Billing details
let billingDetails = STPPaymentMethodBillingDetails()
guard let clientSecret = stripePI?.clientSecret
else { return }
isLoading.value = true
let klarnaMethodParams = STPPaymentMethodParams(klarna: STPPaymentMethodKlarnaParams(),
billingDetails: billingDetails,
metadata: nil)
let paymentIntentParams = STPPaymentIntentParams(clientSecret: clientSecret)
paymentIntentParams.paymentMethodParams = klarnaMethodParams
let deepLink = "com.myapp://stripe-redirect"
var components = URLComponents(string: deepLink)
...
let finalDeepLink = components?.string
paymentIntentParams.returnURL = finalDeepLink
let paymentHandler = STPPaymentHandler.shared()
paymentHandler.confirmPayment(
paymentIntentParams,
with: authContext
) { (status, _, _) in
switch status {
case .failed:
self.isLoading.value = false
self.stripeFailedCallback.fire()
case .canceled:
self.isLoading.value = false
self.stripeCancelledCallback.fire()
case .succeeded:
self.addDayToCalendarService()
self.purchaseService()
@unknown default:
self.isLoading.value = false
self.stripeFailedCallback.fire()
}
}
}
Nope
I mean, I have an idea of how to "patch" the issue but it's not what I want to do if I can make the switch work
Hm... I've never seen a deeplink with a . in the first part before. It's a long shot, but can you change com.myapp to com-myapp and see if that has an affect?
I'm gonna try
The deeplink didn't work
I could go to the switch case but because the deeplink failed 😂
Nevermind
Forgot to change the URL Schemes on the Info.plist, it did the same with com-myapp
No difference with com-myapp and com.myapp
Hi again Adrian. Rubeus had to step out, so I'm taking over. I think this is going to be a bit difficult to debug further over discord as we keep changing hands and there are many threads to juggle. At this point, I think the best path forward will be to pick up investigation on this in a ticket, so I recommend writing in to https://support.stripe.com/contact/email to get further help on this. Once you've written in, can you share your account ID and let me know you've written in so I can pick up the support ticket?
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Do I have to explain all the case again?
And give as much info as possible with all the code parts I shared during the thread?
We can reference this discord thread, but it would be great if you could include a summary in the ticket with as much info as possible just to make things easy for folks investigating
Perfect, could you please leave this thread open so I can do it tomorrow? It’s because I need to contact my mate to get access to the account and right now it’s late where I live and he’ll probably be having dinner.
Unfortunately we archive threads automatically after about an hour of inactivity. This is to maintain the list of open threads we're working on as that list gets huge. If you post in the main channel, however, someone else can take it up. If you @ me then I can take a look as well
Okey, I'll leave this thread open on my computer then so I can do it tomorrow even if you are not available