Paypal checkout doesn't send PAYMENT.SALE.COMPLETED on purchase to my webhook
karlito1501
New Community Member
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
May-23-2024
04:25 AM
I'm trying to create a webhook to listen for paypal checkout purchases.
When user purchases some item paypal is supposed to send data to my server (all I need is an email)
I had created a nodejs webhook POST request using express.js and it does receive data only from webhook simulator multiple times, even when I only clicked it once (https://developer.paypal.com/dashboard/webhooksSimulator)
Here's my source code:
app.post('/paypal-webhook', (req, res) => {
console.log('Webhook event received')
const rawBody = JSON.stringify(req.body);
console.log(rawBody)
const signature = req.headers['paypal-transmission-sig'];
console.log(req.body)
const verified = crypto.createHmac('sha256', paypalWebhookSecret)
.update(rawBody)
.digest('hex');
if (signature === verified) {
const event = req.body;
// Check if the event is a payment sale completed event
if (event.event_type === 'PAYMENT.SALE.COMPLETED') {
console.log('Payment sale completed:', event);
// Your course fulfillment logic here
}
res.status(200).send('Webhook received successfully.');
} else {
console.error('Webhook verification failed.');
res.status(403).send('Unauthorized');
}
});
0 REPLIES 0

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- Is it possible to make payments in RON (Romanian Leu) through PayPal? in REST APIs
- No way to contact company and I want a refund! Please help. in PayPal Reporting
- Auto Return feature for digital products without using woocommerce? in PayPal Payments Standard
- Payments Refunded Automatically After Successful Transactions - PayPal Business Account Issue in REST APIs
- p is not a function error using the example downloaded from Paypal in SDKs