#elias_unexpected
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/1354549115278594280
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello there
Hmmm it is very possible that this metadata field was added recently to Payment Links so it simply hasn't been added to the types yet.
Let me check on that, but yeah you are probably best off ignoring it for now.
here is the full code: ```js
type InstaPayLink = {
listing: { title: string; id: Types.ObjectId };
receivers: { user: string; percentage: number }[];
amount: number;
currency: string;
};
export const createInstaPayLink = async (instaPay: InstaPayLink) => {
const users = await User.find({
_id: { $in: instaPay.receivers.map((r) => r.user) },
});
if (users.length !== instaPay.receivers.length) {
throw Error('Could not find all users');
}
if (users.some((user) => !user.canSell)) {
throw Error('One or more users cannot receive payments');
}
splitPaymentCheck({ receivers: instaPay.receivers });
// Create a product for this payment
const product = await stripe.products.create({
name: instaPay.listing.title,
metadata: {
listingId: instaPay.listing.id.toString(),
},
});
const unit_amount = convertAmount(instaPay.amount, instaPay.currency);
// Create a price for the product
const price = await stripe.prices.create({
product: product.id,
unit_amount,
currency: instaPay.currency,
});
// Instead of a checkout session, create a Payment Link
const paymentLink = await stripe.paymentLinks.create({
line_items: [
{
price: price.id,
quantity: 1,
},
],
after_completion: {
type: 'redirect',
redirect: {
url: ${process.env.FRONTEND_URL!}/chat,
},
},
payment_intent_data: {
metadata: {
receivers: JSON.stringify(instaPay.receivers),
isMessage: 'false',
refrence: JSON.stringify({
id: instaPay.listing.id,
ref: ChatRefrence.LISTING,
} as initialRefrence),
},
},
});
console.log(paymentLink);
return paymentLink.url;
};```
i can test with just ignoring it, give me two sec
Hmmm actually I do see it: https://github.com/stripe/stripe-node/blob/master/types/PaymentLinks.d.ts#L510
Should just have a Stripe.Metadata type
What version of the SDK are you using?
๐