add funds referer url
This commit is contained in:
parent
0996e1faa7
commit
8d521bb703
|
@ -37,7 +37,8 @@ export const createCheckoutSession = functions
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const referrer = req.headers.referer || 'https://mantic.markets'
|
const referrer =
|
||||||
|
req.query.referer || req.headers.referer || 'https://mantic.markets'
|
||||||
|
|
||||||
const session = await stripe.checkout.sessions.create({
|
const session = await stripe.checkout.sessions.create({
|
||||||
metadata: {
|
metadata: {
|
||||||
|
@ -54,8 +55,8 @@ export const createCheckoutSession = functions
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
mode: 'payment',
|
mode: 'payment',
|
||||||
success_url: `${referrer}/?funding-success`,
|
success_url: `${referrer}?funding-success`,
|
||||||
cancel_url: `${referrer}/?funding-failiure`,
|
cancel_url: `${referrer}?funding-failiure`,
|
||||||
})
|
})
|
||||||
|
|
||||||
res.redirect(303, session.url || '')
|
res.redirect(303, session.url || '')
|
||||||
|
|
|
@ -52,7 +52,11 @@ export function AddFundsButton() {
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
action={checkoutURL(user?.id || '', amountSelected)}
|
action={checkoutURL(
|
||||||
|
user?.id || '',
|
||||||
|
amountSelected,
|
||||||
|
window.location.href
|
||||||
|
)}
|
||||||
method="POST"
|
method="POST"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
export const checkoutURL = (userId: string, manticDollarQuantity: number) => {
|
export const checkoutURL = (
|
||||||
|
userId: string,
|
||||||
|
manticDollarQuantity: number,
|
||||||
|
referer = ''
|
||||||
|
) => {
|
||||||
const endpoint =
|
const endpoint =
|
||||||
'https://us-central1-mantic-markets.cloudfunctions.net/createCheckoutSession'
|
'https://us-central1-mantic-markets.cloudfunctions.net/createCheckoutSession'
|
||||||
return `${endpoint}?userId=${userId}&manticDollarQuantity=${manticDollarQuantity}`
|
|
||||||
|
return `${endpoint}?userId=${userId}&manticDollarQuantity=${manticDollarQuantity}&referer=${referer}`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user