#Webhooks not capturing on cloudflare.

1 messages · Page 1 of 1 (latest)

bold narwhal
#

I am trying to deploy a code on cloudflare pages and see if webhooks are able to capture and send it back to the cloudfare pages but failing.

Does anyone have dodopayment payment gateway with webhook implemented in it and hosted on clouflare ?
I am looking for subscription payment gateway.

delicate briarBOT
#

To implement a Dodo Payments subscription payment gateway with webhooks on Cloudflare Pages, follow these steps:

  1. Set Up Environment Variables:

    • Ensure you have your DODO_PAYMENTS_API_KEY and DODO_PAYMENTS_WEBHOOK_SECRET stored securely. Do not expose these keys in your client-side code or public repositories. Use environment variables in your deployment environment.
  2. Create a Subscription:

    • Use the Dodo Payments API to create a subscription. Here's an example of how to do this using Node.js:

      import DodoPayments from 'dodopayments';
      
      const client = new DodoPayments({
        bearerToken: process.env.DODO_PAYMENTS_API_KEY,
      });
      
      async function createSubscription() {
        const subscription = await client.subscriptions.create({
          billing: {
            city: 'city',
            country: 'IN',
            state: 'state',
            street: 'street',
            zipcode: 89789,
          },
          customer: {
            email: '[email protected]',
            name: 'John Doe',
          },
          product_id: 'product_id',
          payment_link: true,
          return_url: 'https://yourdomain.com/success',
          quantity: 1,
        });
      
        console.log(subscription.subscription_id);
      }
      
      createSubscription();
      
  3. Implement Webhooks:

    • Set up an endpoint to handle webhook events from Dodo Payments. This will allow your application to react to events like successful payments, refunds, or subscription changes. Here is an example using Node.js:

      import { Webhook } from "standardwebhooks";
      import { headers } from "next/headers";
      
      const webhook = new Webhook(process.env.DODO_PAYMENTS_WEBHOOK_SECRET);
      
      export async function POST(request) {
        const headersList = headers();
        const rawBody = await request.text();
#

const webhookHeaders = {
"webhook-id": headersList.get("webhook-id") || "",
"webhook-signature": headersList.get("webhook-signature") || "",
"webhook-timestamp": headersList.get("webhook-timestamp") || "",
};

   await webhook.verify(rawBody, webhookHeaders);
   const payload = JSON.parse(rawBody);
   
   // Process the payload according to your business logic
 }
 ```
  1. Configure Webhook on Dodo Dashboard:

    • In your Dodo Payments dashboard, navigate to Settings > Webhooks and create a new webhook endpoint. Enter the URL where your application is hosted and select the events you want to listen to, such as subscription.active, subscription.failed, etc.
  2. Deploy on Cloudflare Pages:

    • Deploy your application to Cloudflare Pages, ensuring that the webhook URL is publicly accessible and can receive POST requests.
  3. Testing:

    • Test the integration using test mode. You can simulate webhook events and verify that your application processes them correctly.

By following these steps, you should be able to successfully implement and test a subscription payment gateway with webhooks on Cloudflare Pages using Dodo Payments.

Helpful Links

Dodo Payments Documentation

The Dodo Payments API provides comprehensive endpoints for payment processing, subscription management, and digital product delivery. Our RESTful API follows industry standards with detailed responses for all operations.

Dodo Payments Documentation

This section provides an overview of the process to create a webhook for your Dodo Payments account.

Dodo Payments Documentation

This guide will help you integrate the Dodo Payments Subscription Product into your website.

bold narwhal
#

Ngrok is wotking but clouflare is not working

burnt heath