add funds referer url
This commit is contained in:
parent
0996e1faa7
commit
8d521bb703
|
@ -37,7 +37,8 @@ export const createCheckoutSession = functions
|
|||
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({
|
||||
metadata: {
|
||||
|
@ -54,8 +55,8 @@ export const createCheckoutSession = functions
|
|||
},
|
||||
],
|
||||
mode: 'payment',
|
||||
success_url: `${referrer}/?funding-success`,
|
||||
cancel_url: `${referrer}/?funding-failiure`,
|
||||
success_url: `${referrer}?funding-success`,
|
||||
cancel_url: `${referrer}?funding-failiure`,
|
||||
})
|
||||
|
||||
res.redirect(303, session.url || '')
|
||||
|
|
|
@ -52,7 +52,11 @@ export function AddFundsButton() {
|
|||
</label>
|
||||
|
||||
<form
|
||||
action={checkoutURL(user?.id || '', amountSelected)}
|
||||
action={checkoutURL(
|
||||
user?.id || '',
|
||||
amountSelected,
|
||||
window.location.href
|
||||
)}
|
||||
method="POST"
|
||||
>
|
||||
<button
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
export const checkoutURL = (userId: string, manticDollarQuantity: number) => {
|
||||
export const checkoutURL = (
|
||||
userId: string,
|
||||
manticDollarQuantity: number,
|
||||
referer = ''
|
||||
) => {
|
||||
const endpoint =
|
||||
'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