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',
express.raw({ type: 'application/json' }),
async (request, response) => {
console.log("in webhook");
let event = request.body;
// Replace this endpoint secret with your endpoint's unique secret
// 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
const endpointSecret = env.stripeWebhookSecret;
if (endpointSecret) {
console.log("endoint Secret", endpointSecret);
// Get the signature sent by Stripe
const signature = request.headers['stripe-signature'] || "";
console.log("signature", signature);
try {
event = stripe.webhooks.constructEvent(
request.body,
@ -82,7 +85,7 @@ paymentRouter.post("/create-checkout-session", async (req, res, next) => {
try {
const source = req.query.source;
const returnUrl = source === "dictionary"
? "https://dictionary.lingodcs.com/account"
? "https://dictionary.lingdocs.com/account"
: "https://account.lingdocs.com/user";
const price = req.body.priceId;
const session = await stripe.checkout.sessions.create({