#prodigiousGhost
1 messages Β· Page 1 of 1 (latest)
Ah yeah could be. Can you share how you're deep linking and handling return urls?
Under URL types i have this
I have tried a few different variations, but not sure
// MARK: FIREBASE GOOGLE SIGN IN & STRIPE
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
print("AppDelegate - ", url)
let stripeHandled = StripeAPI.handleURLCallback(with: url)
if (stripeHandled) {
return true
} else {
// This was not a Stripe url β handle the URL normally as you would
// Firebase google sign in
return GIDSignIn.sharedInstance.handle(url)
}
}
within this, I also handle login via google, so please ignore that code
hello! just stepping in, give me a sec to read
sure
what is the returnURL you're setting on PaymentSheet.Configuration() instance? I assume you're using that
referring to the part here: https://stripe.com/docs/payments/accept-a-payment?platform=ios&ui=payment-sheet#ios-set-up-return-url
let me have a look in my own sample project
Thank you
ok sorry that took a while, Xcode had to install components cause ofcourse lol
try this, lets say your return URL is mygoodapp
set that as both identifier and URL Scheme in the screenshot above
then, just in a Safari window, enter the URL mygoodapp and press enter
I expect that should redirect back to your app
good!
now try the same in your code, with returnURL as "mygoodapp://stripe-redirect"
i should leave the identifier and url type as mygoodapp, and just change the returnUrl in code ?
try with hardcoding mygoodapp first, just to make sure things work first
then we can generalize later once we have confidence
1/ can you share the URL scheme screenshot again
2/ can you share your PaymentSheet code snippet?
ok now there is no error, but nothing happens, even when I manually tap the return to merchant button
I'm confused, what changed between this repro and the last one? what would result in 2 diff results?
the first one was my bad, I didnt run the project properly lol
the second one is the outcome of the code changes you requested
gotcha
is it supposed to have this behaviour ?
is the user expected to close the tab manually ?
no deep linking works
my sample app is really outdated so asking a colleague who is on a recent version of PaymentSheet
No worries
I was wondering, separately, are we required to use the address element when collecting a customer shipping address? Is it ok if we pass in the shipping address to the api manually, and only collect the billing address (if need be) via paymentSheet?
yes you can collect your own shipping address and pass it on to the PaymentIntent
Ok, that's good
Hello! The fact that it's saying it's not a valid URL indicates the app isn't indicating it will handle that URL scheme. Is this in the simulator or on device? If it's the simulator can you try removing the app and reinstalling it, and also try a simulator restart?
This is on the simulator. I will try those things now
Hi, it does the same thing
when i manually copy and paste the link into safari, it does switch back to the app. But the app remains on the screenshot as shown above. I still have to manually close the window
Oh, maybe I misunderstood. I thought you were getting the "address is invalid" error?
Yeah, that's been sorted now
I think it was hmunoz, recommended to change the Id and URL to the same
Okay, so you go through the payment flow, authentication is required, you complete that, then you land on the "return to merchant" screen and need to manually go back rather than it being automatic?
yes, right now it is manual
is that how it supposed to be ?
clicking on the blue button does not do anything either
No, if the return URL is set up properly it should be automatic.
What else can I do ?
I'm looking through Apple's docs to make sure we're not missing anything; maybe look on your end as well and see if anything jumps out? https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app
Can you share a screenshot of your current URL types from Xcode? I think you changed it since the screenshot above.
Sorry, I don't really know how the url types work, so not sure if it contains sensitive info
Hm, can you try using a reverse DNS string for the identifier instead of just mygoodapp?
Hm. So, to clarify, going to Safari and typing in mygoodapp:// switches to your app?
yes, although now it is the reverse domain
The reverse domain?
To clarify, the identifier (not the URL Schemes) are what should use a reverse DNS string (like com.example.mygoodapp).
What should be the URL scheme ?
Just mygoodapp
Oh right, let me try that then
Would this "mygoodapp://stripe-redirect" be the returnUrl ?
Yes.
Same thing
I can see that when i copy and paste the url into safari, it does take me back to the app. But does not close the page in the screenshot
Setting up the return URL and the custom URL scheme should make the return part automatic. I do not know why it's not working for you. Have you tried on an actual device? Any difference there?
I currently don't have access to an actual, device, I will try shortly
Hey, same thing on a physical device
Hi there. Rubeus had to step away
Can you summarize what you're currently blocked on?
The authentication window does not auto-dismiss even though deeplinks seem to be working. I have tested this on both simulator and physical device, same result on both
Thank you
Can you share a screen recording of what's exactly happening currently? Want to make sure I understand
Currently as in after all the changes Rubeus suggested
Ok sure
Can you give me some time please, I just stepped away from the computer π
No worries
Thank you, looking at this on our end.
Hello again! So in that flow, can you look in the web developer console and see if there are any warnings or errors?
You can use Safari to open dev tools for a web view in the simulator.
If you're not familiar with that approach I can give you specific instructions.
Nothing's being logged
Nothing at all?
maybe i'm not doing it properly? I went to safari on my desktop and opened dev tools for the simulator
You went to the Develop menu in Safari and selected the simulator context, correct? It should highlight in the simulator when you hover over the right one.
Yes
Hm. Try this: open the dev tools when you're on the Stripe page with the two Complete for Fail Authentication buttons. Go to the Network tab, make sure Preserve Log is checked, then proceed through the flow and see if anything interesting appears in the results.
You can use the little trash can icon in the top right of that tab to clear the results before you start if you want to start from a blank slate.
Yep, that's normal. Nothing about an attempt to hit mygoodapp://stripe-redirect though?
After you get to the return to merchant page?
no, nothing :/
And there's nothing in the filter box, right?
The field that says "Filter Full URL" in my screenshot?
this is correct right ?
nothing
Yep, that looks fine.
Is there any output in the Console tab, or is it just blank?
blank
Can you give me the Setup/Payment Intent ID you're using? Maybe it will yield a clue.
Looks like that one has only been created, can you go through the payment flow so I can see what it looks like after confirmation?
Ah, right, sorry, I just meant the transaction flow.
Like all the way to the return to merchant page.
No, succeed.
That looks completely normal, and the correct return_url is being used: https://dashboard.stripe.com/test/logs/req_3DX3C8iIDljJNH
yup
π€
Does anything interesting pop up in the Network or Console tab when you tap on the return to merchant button?
Yep.
just wanted to make sure
cool
if it's ok with you, can i come back in 20 mins? gonna grab dinner quick, its past midnight now
Yep, that's fine.
thank you
While you're gone I'm going to share screenshots and whatnot of the example app's configuration and code that's working on my end...
sure
Code: configuration.returnURL = "payments-example://stripe-redirect"
This example app uses a SceneDelegate to handle URLs:
Wait...
You shared this code earlier:
// MARK: FIREBASE GOOGLE SIGN IN & STRIPE
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
print("AppDelegate - ", url)
let stripeHandled = StripeAPI.handleURLCallback(with: url)
if (stripeHandled) {
return true
} else {
// This was not a Stripe url β handle the URL normally as you would
// Firebase google sign in
return GIDSignIn.sharedInstance.handle(url)
}
}
Is that print("AppDelegate - ", url) firing? If so, what does it print out?
I will check this
You can do either. Really it's about where you want your URL handler code to reside.
Here's the documentation for the UISceneDelegate method the sample app I'm using is using: https://developer.apple.com/documentation/uikit/uiscenedelegate/3238059-scene
Iβm using both to handle urls
There's, ummm....
This looks like a good blog post about it: https://blogs.halodoc.io/deep-linking-using-url-scheme-in-ios/
Are you handling Stripe URLs in both places?
Yes
With StripeAPI.handleURLCallback() I mean?
Yeah
Can you add logging to both places and see which (or if either) is called?
Hmmmmmmm.
What if you invoke the app from Safari by typing in mygoodapp://test?
nothing
Uh... π
Search your entire codebase for instances of OpenURLOptionsKey and openURLContexts and open url and see if there are any other places where this could be handled.
Also search for AppDelegate and SceneDelegate and make sure there aren't ones floating around without URL handlers.
ooo
so i found another method within scenedelegate
but... it should still print out the url as i have a print statement there
Hm.
Maybe it's some really strange build artifact bug? In Xcode if you go to the Product menu and choose Clean Build Folder... and then do a fresh, clean build does that get any of those print calls to work?
Also, just thinking of anything else it could possibly be, are other print() calls working? Is your app logging other stuff in the debugger?
Anything in the filter field in the debugger?
Maybe also delete it from the simulator?
Just to rule out any possible artifacts there.
OMG
but its cos i messed up bad
π
I mean, I wasn't celebrating you messing up to be clear. π
What happened?
In the scene delegate, I was using the continue UserActivity method and not the openURLContext even though i was using that method within the AppDelegate
yeah
Ah, yep, that one not being called for a URL makes sense.
but it should have worked because i was checkign to make sure the activity was of type safaribrowsing
But hey, I'm just glad it's working!
It works for my google sign in code
I don't think the user activity method gets called when it's a Safari View Controller within your own app.
Not 100% sure though.
Happy to help!
I would never have even looked twice, it was only when you shared your sample SceneDelegate code i saw the mistake I made
Also, I have some questions regarding how to move forward for the use case of my app. Is this the best place to ask ?
Yep, shoot!
The app we are making at the moment allows users to buy and sell items on a marketplace. You can also bid for items too. When purchasing, we require them to select a payment method, then choose shipping and if need be, add any coupons etc. The issue is due to their shipping address changing, or them adding a coupon code the price may change, So if we were using the paymentSheetFlowController to select payment, how can we confirm if there isn't any price attached ?
i am not sure if that makes sense
Additionally, can a customer also be a Connect customer? We have to use Connect accounts for sellers and handling payouts
I was following along until that last part... is the core issue that you have a Payment Intent with an amount already set, you use that to initialize the Payment Sheet, but then you need to change the amount based on other information provided?
No, Customers are separate from Connect accounts. Customers are objects that live inside a Stripe Account and represent people paying that account.
I see
Sorry, I am using a setupIntent
to display the payment-sheet to the user, they select a method
So with Setup Intents there's never an amount or price attached.
You would need to use a Payment Intent if you want to collect payment.
That's using a Payment Intent. See in the code where it says paymentIntentClientSecret?
Let's take a step back from the specifics though. Can you describe your ideal payment flow?
sure
Or, rather, your ideal payment method collection and payment flows, if they're separate?
so when buying, users select their payment method, then shipping and essentially buy
however, if they are bidding, we should be able to store their payment method, and charge them at a later date if the seller agrees with their bid
Okay, so if you want to collect payment and save the payment method at the same time you should use a Payment Intent and this guide: https://stripe.com/docs/payments/save-during-payment?platform=ios&ui=payment-sheet
Users can also sell items, I believe we will have to use Connect accounts for this, they choose the item they want to sell, choose their payout method, then list the item. If the item sells, the funds from the buyer should come to us first. The seller has to ship their items to our warehouse, then at which point if the item is as it should be, we will release the sellers portion of the sale to them
If you only want to collect payment info for later use, without taking a payment, the guide you're following now is the correct one.
That's correct, yep, Connect is required for what you want to do.
So this guide I am using, should be perhaps used when accessign the user's account details in the app right ? where they can view current payment methods and add new ones
Yeah.
Ok, is it possible to update the paymentIntent ?
once i create a paymentIntent for lets say 100USD
then the user adds a coupon, i can updated the paymentIntent to 90USD, without having to make the user select a payment method again right ?
Kinda, but not really. The flow is create Payment Intent for specific amount > use client secret to show Payment Sheet > customer pays that amount. You can't practically change the amount after the Payment Sheet is displayed.
You should do all of the stuff that determines the amount first, then create the Payment Intent for the final amount, then show the Payment Sheet.
So address selection, coupons, etc... all of that should happen before you create the Payment Intent.
There is a beta where you can create the Payment Intent after showing the Payment Sheet, if you want to request access: https://stripe.com/docs/payments/accept-a-payment-deferred?platform=mobile
Damn, sounds like exactly what i need
Probably. π
Well, thank you for your help, quite literally spent hours on this issue
It feels good to go to bed with this sorted lol
Hope you have a great day/night
Happy to help! Sorry it took so long, but glad we got there in the end!
You too! Good luck with the rest of your integration!
No worries, its done now and thats all that matters