#simsim_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1261281001762455654
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
You should be listening to checkout.session.completed events which will include custom fields data: https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-custom_fields
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
const stripe = require('stripe')('YOUR_STRIPE_SECRET_KEY'); // Replace with your Stripe secret key
const axios = require('axios');
const bodyParser = require('body-parser');
const app = express();
const discordWebhookUrl = 'YOUR_DISCORD_WEBHOOK_URL'; // Replace with your Discord webhook URL
app.use(bodyParser.json());
app.post('/webhook', async (req, res) => {
const event = req.body;
// Handle the event
switch (event.type) {
case 'payment_intent.succeeded':
const paymentIntent = event.data.object;
// Extract custom fields from metadata
const donorName = paymentIntent.metadata.donorName || 'Anonymous';
const customField = paymentIntent.metadata.customField || 'No custom field data';
// Construct the message
const message = `${donorName} just donated and here is custom field data: ${customField}`;
// Send the message to Discord
try {
await axios.post(discordWebhookUrl, {
content: message
});
res.status(200).send('Success');
} catch (error) {
console.error('Error sending message to Discord:', error);
res.status(500).send('Error');
}
break;
default:
// Unexpected event type
return res.status(400).end();
}
res.json({ received: true });
});
app.listen(3000, () => {
console.log('Server is running on port 3000');
});```
how this shoult look like?
When you say 'custom fields' what exactly are you using? Can you share one of these evt_xxx IDs you're processing?
Because your code references metadata but you mean the custom fields collected on the Payment Link payment page, right?
yes its all about payment link
case 'checkout.session.completed':
const checkoutSession = event.data.object;
// Extract custom fields from metadata
const donorName = checkoutSession.custom_fields[0][text].value || 'Anonymous';
const customField = checkoutSession.custom_fields[1][text].value || 'No custom field data';
// Construct the message
const message = `${donorName} just donated and here is custom field data: ${customField}`;
// Send the message to Discord
try {
await axios.post(discordWebhookUrl, {
content: message
});
res.status(200).send('Success');
} catch (error) {
console.error('Error sending message to Discord:', error);
res.status(500).send('Error');
}
break;
Something like that should work really
ohh, thanks, i hve been strugeling like two days to get data from custom field and send this to discord message in channel ๐ฆ
Let me know if that works
i will
Make sure your webhook is configured to listen for checkout.session.completed events