diag webhook

This commit is contained in:
adueck 2022-10-15 20:52:39 +05:00
parent be40d2b3b7
commit 6d103986b7
1 changed files with 4 additions and 1 deletions

View File

@ -14,6 +14,7 @@ paymentRouter.post(
'/webhook', '/webhook',
express.raw({ type: 'application/json' }), express.raw({ type: 'application/json' }),
async (request, response) => { async (request, response) => {
console.log("in webhook");
let event = request.body; let event = request.body;
// Replace this endpoint secret with your endpoint's unique secret // Replace this endpoint secret with your endpoint's unique secret
// If you are testing with the CLI, find the secret by running 'stripe listen' // If you are testing with the CLI, find the secret by running 'stripe listen'
@ -23,8 +24,10 @@ paymentRouter.post(
// Otherwise use the basic event deserialized with JSON.parse // Otherwise use the basic event deserialized with JSON.parse
const endpointSecret = env.stripeWebhookSecret; const endpointSecret = env.stripeWebhookSecret;
if (endpointSecret) { if (endpointSecret) {
console.log("endoint Secret", endpointSecret);
// Get the signature sent by Stripe // Get the signature sent by Stripe
const signature = request.headers['stripe-signature'] || ""; const signature = request.headers['stripe-signature'] || "";
console.log("signature", signature);
try { try {
event = stripe.webhooks.constructEvent( event = stripe.webhooks.constructEvent(
request.body, request.body,
@ -82,7 +85,7 @@ paymentRouter.post("/create-checkout-session", async (req, res, next) => {
try { try {
const source = req.query.source; const source = req.query.source;
const returnUrl = source === "dictionary" const returnUrl = source === "dictionary"
? "https://dictionary.lingodcs.com/account" ? "https://dictionary.lingdocs.com/account"
: "https://account.lingdocs.com/user"; : "https://account.lingdocs.com/user";
const price = req.body.priceId; const price = req.body.priceId;
const session = await stripe.checkout.sessions.create({ const session = await stripe.checkout.sessions.create({