#shiva - Android redirect
1 messages ยท Page 1 of 1 (latest)
Hi dear
Are you able to help me on this ?
I am more than happy to share you my code snippets that i have right now
it works perfectly fine for iOS
with deep linking
Taking a look here
I'm seeing this: https://docs.expo.dev/versions/latest/sdk/stripe/#common-issues for Expo browser pop-up not redirecting. Can you confirm if you're following this snippet?
let me chekc
daer i have the urlScheme in my stripe init
and yes im following this snippet because it works well or android
stripe is not closing the browser after payement completion/failure
its just hanigng there with the button return to merchant
should it be urlScheme={'suriwebwinkel://'} or urlScheme={'suriwebwinkel'}
in my app.json i have
"expo": {
"scheme": "suriwebwinkel"}
Are you able to provide more details here? What are you using within the app? Please provide us steps to try to reproduce so we can further investigate what the issue might be.
I am using react native stripe-sdk
in my root app i have <StripeProvider publishableKey>
and i followed this doc
so iOS wasnt working until i implemented step 5
w for android the payments are getting processed, but the issue is that the user swill still see the blank screen thats indicating return to merchant
Hi @pale sigil taking over for @willow valve. Give me a few minutes to get up to speed
Sure
Are you able to provide steps and all the relevant code to reproduce this behavior on our end?
do you need any code snippet?
Maybe, but first: are you using Expo Go, or creating a standalone app? Are you following along with anything re.linkingfor Expo specifically? (e.g. https://docs.expo.dev/guides/linking/)
I don't know a lot about Expo, but it seems to have different instructions for each different approach.
Sure
I am using this for deeplink:
https://reactnavigation.org/docs/5.x/getting-started
For testing I export the APK file to run a standalone app
also yesterday I got this info from Synthrider (Stripe Developer)
It's not needed on android, that platform allows us to handle the necessary piece automatically
this extra setup step is iOS only
(your video showed iOS which is part of what guided me to this)
It's not needed on android, that platform allows us to handle the necessary piece automatically
this extra setup step is iOS only
(your video showed iOS which is part of what guided me to this)
Right, but iOS you said is working now, so you're specifically debugging the redirect on Android specifically, correct?
correct
because i already published iOS to app store
and there its working as expected
in Internal use of android, my testers are complaining about the redirect not happening after succesfull/failed payments
Got it. I think it would be helpful if we had all the relevant code you're using (including the Expo snippets) to try and either repro or simply get a better understanding of how everything is intermingled.
Also a Payment Intent ID for one of the payments that failed to redirect properly
Sure
Payment id: pi_3KtcJAH8w5UYmCB01pZoa4Tl
So for my expo app:
-
Added the scheme --> suriwebwinkel
-
const prefix = Linking.createURL("/");
const linking = {
prefixes: [prefix],
config: {
screens: {
Drawer: "home"
}
}
};
<NavigationContainer linking={linking}>
<Screens />
</NavigationContainer> -
Now in return url of stripe im passing
const returnUrl = Linking.createURL();
returnURL: returnUrl+'home' ,
Those are the steps
Step 2 lives in my App.js
Can you also provide your Stripe code?
P.S. Thanks for working with me on this. I know the back-and-forth can become cumbersome
Thats perfectly fine
Sure
const useStripePayment = ({ navigation }) => {
const { initPaymentSheet, presentPaymentSheet, handleURLCallback } = useStripe();
const [active, setActive] = useState(false);
const [loading, setLoading] = useState(false);
const [userInfo, setUserInfo] = useState({});
const handleDeepLink = useCallback(
async (url) => {
console.log(url)
if (url && url.includes('home')) {
await handleURLCallback(url);
}
},
[handleURLCallback]
);
const getUrlAsync = async () => {
const initialUrl = await Linking.getInitialURL();
handleDeepLink(initialUrl);
};
useEffect(()=>{
getUrlAsync();
const deepLinkListener = Linking.addEventListener(
'url',
(event) => {
handleDeepLink(event.url);
}
);
return () => deepLinkListener.remove();
},[handleDeepLink])
const initializePaymentSheet = async (cSecret, name, email) => {
const billingDetails = {
name: name
};
const returnUrl = Linking.createURL();
const { error } = await initPaymentSheet({
paymentIntentClientSecret: cSecret,
defaultBillingDetails: billingDetails,
primaryButtonColor: "#16162E",
customFlow: false,
merchantDisplayName: "Suriwebwinkel B.V.",
returnURL: returnUrl+'home' ,
style:'automatic'
});
if (!error) {
setLoading(true);
}
};
const openPaymentSheet = async () => {
const { error } = await presentPaymentSheet();
setLoading(false);
if (error) {
Toast.show({
type: "error",
text1: 'Betaling mislukt, neem contact met ons op',
});
} else {
Toast.show({
type: "success",
text1: "Betaling voltooid, Grangtangi!",
});
}
};
const startPaymentHandler = async () => {
setLoading(true);
await openPaymentSheet();
};
const handleSubmit = async ({ totalCartPrice, orderId }) => {
const userInfoString = await AsyncStorage.getItem("userInfo");
const token = JSON.parse(userInfoString);
let cSecret;
try {
const res = await getUsercSecret({ totalCartPrice, orderId, token });
if (res?.status === 200) {
cSecret = res?.data.client_secret.client_secret;
setUserInfo({
cSecret,
orderId: orderId,
name: token.name,
email: token.email,
});
if (cSecret) {
await initializePaymentSheet(cSecret, token.name, token.email);
setActive(true);
}
}
} catch (err) {
console.log(err);
}
};
entry function is handleSubmit and then i get the paymentIntent from my server
which I then call initializePaymentSheet to initialize the sheet
if the initialization is done I open the payment sheet which has the return Url as you can see
Please let me know if you need clarity on any other points
or need more code snippets
Do you have a successful iOS Payment Intent ID I can look at to compare on a theory I have?
Thanks. Taking a look now
Sure
Okay, so your code at:
const returnUrl = Linking.createURL();
const { error } = await initPaymentSheet({
paymentIntentClientSecret: cSecret,
defaultBillingDetails: billingDetails,
primaryButtonColor: "#16162E",
customFlow: false,
merchantDisplayName: "Suriwebwinkel B.V.",
returnURL: returnUrl+'home' ,
style:'automatic'
});
if (!error) {
setLoading(true);
}
};
Whatever is happening with returnUrl on iOS is rendering the right format of
appname://thing, but on Android it is doing something odd and making it a format
stripesdk://payment_return_url/nl.suriw<redacted> where stripesdk is wrong, it needs to be suriwebwinkel.
As a next step, can you log out returnUrl+'home' in both iOS and Android (before you call initPaymentSheet() and see why it returns a different string each time.
Also, try hard-coding returnURL: "suriwebwinkel://home",
in your initPaymentsheet() call and see if that works on Android
Hey @pale sigil, @zealous rampart needed to step away but I'm here to help.
I'll catch up while you give the above a try
Cool
i just hardcoded it
waiting for build to be completed
so that i can test it in the emulator ok?
Please bare with me
really appreciate your help
You are using Expo right? So you must be on a pretty early version of our RN SDK
exactly im running on "@stripe/stripe-react-native": "^0.2.3",
I did hard code it
to
suriwebwinkel://
but still no luck
returnURL: "suriwebwinkel://home" ,
Can you provide the PaymentIntent ID for that test?
Hmm yeah okay that ended up using the same return_url in the PI confirmation request. You can see this in your Dashboard here: https://dashboard.stripe.com/test/logs/req_YQj7fW6OHzXR2I
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
it looks like the return url is still set to:
"return_url": "stripesdk://payment_return_url/nl.suriwebwinkel.suriwebdev",
๐
So I think this is the bug that was fixed in 0.4.0: https://github.com/stripe/stripe-react-native/blob/f33a7268b1b801e51875d32a8227d0534d28c1fa/CHANGELOG.md#040
in ios:
"redirect_to_url": {
"return_url": "suriwebwinkel://home",
Right
and im running on a later version than 0.4.0
Yeah Expo is limiting here ๐ฆ
Yep exactly
We are working on releasing compatibility with newer Expo versions
But I don't have a timeline for that
oh so that means i have to ship my code like this to production ?
You either ship like that and wait for the new Stripe RN and Expo update release when you can update to a newer version of Stripe RN and Expo, or you don't use Expo and you use a newer version of the current Stripe RN SDK.
Not the best options, I know
hahah not using expo means start the whole project afresh
๐ฆ
Yea i think for now i dont have any option then to wait, but you know what
i really appreciate you helping me this fast and identified it right away
I was also on an email with Rubeus who. mentioned the same but i did not really understand him but he pointed out to the same fix and i was like but im using a newer version right ahah
I'm glad we could help figure it out โ sorry there isn't a better solution at the moment.
So on more question, remember there is a screen where there is a button mentione "return to merchant"
is there a way i can change that? I know thats a screen hosted by stripe but just trying to make sure
if yes i could atleast add the information in there to close the tab.
That text and that screen isn't editable
GOt it
You have a great one
thank you very much for the support. I wish I knew this earlier
that we could ask developers questions on discord
rather then calling in
because that is soo hard to explain over there
Well if anything pops up in the future don't hesitate to come back here!
sure
also
how will i get the update regarding this issue with expo
and stripe
whther
it gets resolved.
Good question. You could add a custom "watch" to the Stripe React Native Repo (https://github.com/stripe/stripe-react-native) for releases
Then you will get an email when new releases happen
And that should include information about when the RN SDK and Expo update happens