#manic-pixie-dream-bananarchist_api
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/1263305437256614001
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there, just to clarify on your inquiry. You said your server didn't receive checkout session ID in the return_url? https://divvyhomes.com/up/subscribe/return?session_id={CHECKOUT_SESSION_ID}
Can you share with me the relevant code?
when stripe redirects to our server on checkout session completion, no session_id is included
return_url: `${chipServerConfig.environmentBaseUrl[process.env.NODE_ENV]}${getRouteUrl({
to: '/subscribe/return',
query: { session_id: '{CHECKOUT_SESSION_ID}' },
})}`,
looking at the event i linked above, this is what the return url is set to "return_url": "https://divvyhomes.com/up/subscribe/return?session_id={CHECKOUT_SESSION_ID}",
however looking at our server request logs, no session_id parameter is included
Ok, give me some time to investigate
Can you share with me the complete code of getRouteUrl function?
import { isNil, omitBy } from 'lodash';
import { stringify } from 'qs';
import type { Route } from '@app/chip/client/types/route';
import { chipBasePathname } from 'src/chip/client/constants';
export const getRouteUrl = ({ to, query: rawQuery }: Route): string => {
const query = omitBy(rawQuery, isNil);
const queryParams = Object.keys(query).length > 0 ? stringify(query) : undefined;
const path = !isNil(queryParams) ? `${to}?${queryParams}` : to;
return decodeURIComponent(`/${chipBasePathname}${path}`);
};
Wait, is this how you construct the successUrl ?
I need the code where you extract the session ID from return_url
oh yeah this is the construction
Ah, I know the problem
You should set {CHECKOUT_SESSION_ID} on success_url, not return_url
is this a regression?
we haven't changed any of this code in months
seems like the API changed
the documentation says this
If you’ve integrated with an embedded payment form, you can’t use the success_url parameter. You must use return_url. Learn more about customizing redirect behavior for integrations with the embedded form.
we're using the embedded form
Sorry, I didn't notice you are using embedded form, and yes you can set {CHECKOUT_SESSION_ID} on return_url
this is the query parsing code, fwiw
const querySchema = z.object({
session_id: z.string(),
});
export const getServerSideProps: GetServerSideProps = async ({ req, res, query: rawQuery }) => {
const session = await getServerSession(req, res, authOptions);
const userId = session?.user.id;
if (isNil(userId)) {
throw makeChipError('Unauthorized');
}
const query = querySchema.safeParse(rawQuery);
if (!query.success) {
throw makeChipError('Invalid query', {
info: {
userId,
},
});
}
...
})
and what's inside getServerSession ?
but i verified the parsing works successfully by just manually inputting a url
i.e. https://divvyhomes.com/up/subscribe/return?session_id=1234
our server picks this up, which means the only way this could happen is if the session_id is just not included
getServerSession is a next js module function
it just sets some cookies
Ok, I just tested my embedded checkout integration and I can't reproduce the problem
but our server logs show the error that's thrown from this
const query = querySchema.safeParse(rawQuery);
if (!query.success) {
throw makeChipError('Invalid query', {
info: {
userId,
},
});
}
Is there a public URL that I can visit to test your integration in test mode?
there is not
Can you set up one?
not really, the checkout session code is heavily dependent on account creation steps that happen prior
does it need to be in test mode?
you can create an account and go through the onboarding flow to get to the checkout session page
but it won't be in test mode
Yes, I can't make real payments so I can only test in test mode.
we could probably make it so that when you get to the session page, you can manually add a ?mode=test query parameter that will use test mode
what specifically are you trying to verify though? is there a way i can just do it for you?
we have internal credit cards that we use for testing this stuff
Or can you create a checkout session that doesn't require payment (i.e., use coupon or trial)
this isn't something i can do immediately
but if there's a way i can just do this for you, you can tell me what it is you're looking for
I'd just want to see if the browser address bar contains the checkout session ID after being redirected to https://divvyhomes.com/up/subscribe/return?session_id=cs_live_xxx
Let's help make your dream of homeownership a reality. Work towards improving your credit score, savings, and homebuyer knowledge with tips and tools built just for you - all packaged up in a step-by-step action plan to help you stay on track.
i'll go through the steps and screen record it
okay sorry for the false alarm
it's getting stripped on our end
didn't notice this the first time i went through
but there's some layer somewhere in our infra that's redirecting without the query param 😦
I see, looks like you can continue troubleshooting from there.
yep. thanks for the help