> ## Documentation Index
> Fetch the complete documentation index at: https://dodopayments-mintlify-external-integration-datafast-autosen.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Code Integration Tutorial

> This tutorial demonstrates integrating Dodo Payments into a Next.js app using the Node.js SDK for One-Time and Subscription Products. It utilizes the Dodo Next.js Minimal Boilerplate and covers essential steps to get started efficiently.

## Prerequisites

Before you begin, make sure you have:

* [Created a Dodo Payments account](/quickstart)
* [Obtained your API keys](/api-reference/introduction#authentication)
* Basic knowledge of Next.js and React
* Node.js installed (v14 or higher)

## Boilerplate Setup

Clone our Next.js boilerplate to get started quickly:

```bash theme={null}
git clone https://github.com/dodopayments/dodo-nextjs-minimal-boilerplate
cd dodo-nextjs-minimal-boilerplate
npm install
```

<Note>
  The boilerplate includes all necessary dependencies and basic setup for Dodo Payments integration.
</Note>

## Integration Options

Choose your integration path:

<CardGroup cols={2}>
  <Card title="One-Time Payments" icon="credit-card" href="#one-time-payment-product-integration">
    Process single payments
  </Card>

  <Card title="Subscriptions" icon="repeat" href="#subscription-payment-product-integration">
    Handle recurring payments
  </Card>
</CardGroup>

## One-Time Payment Product Integration

Learn how to implement one-time payments in your application:

<iframe className="w-full aspect-video rounded-md" src="https://www.youtube.com/embed/3igzmVkVDbY" title="One-Time Payment Integration | Dodo Payments" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

### Key Steps

<Steps>
  1. [Initialize the SDK](/developer-resources/dodo-payments-sdks#initialization)
  2. [Create a product](/api-reference/products/post-products)
  3. [Generate a payment link](/api-reference/payments/post-payments)
  4. [Handle webhooks](/developer-resources/webhooks/intents/payment)
</Steps>

## Subscription Payment Product Integration

Learn how to implement subscription payments:

<iframe className="w-full aspect-video rounded-md" src="https://www.youtube.com/embed/rj62ral2rek" title="Subscription Integration | Dodo Payments" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

### Key Steps

<Steps>
  1. [Initialize the SDK](/developer-resources/dodo-payments-sdks#initialization)
  2. [Create a subscription product](/api-reference/products/post-products)
  3. [Create a subscription](/api-reference/subscriptions/post-subscriptions)
  4. [Handle subscription webhooks](/developer-resources/webhooks/intents/subscription)
</Steps>

## Webhook Integration

Set up webhooks to handle asynchronous events:

```typescript theme={null}
import { verifyWebhookSignature } from '@dodopayments/node';

export default async function handler(req, res) {
  const signature = req.headers['dodo-signature'];
  const payload = req.body;
  
  try {
    verifyWebhookSignature({
      payload,
      signature,
      secret: process.env.WEBHOOK_SECRET
    });
    
    // Handle webhook event
    switch (payload.type) {
      case 'payment.succeeded':
        // Handle successful payment
        break;
      case 'subscription.created':
        // Handle new subscription
        break;
      // ... handle other events
    }
    
    res.status(200).json({ received: true });
  } catch (err) {
    res.status(400).json({ error: 'Invalid signature' });
  }
}
```

## Testing

Before going live:

1. Use [test API keys](/miscellaneous/test-mode-vs-live-mode)
2. Test with [test card numbers](/miscellaneous/testing-process)
3. Verify webhook handling
4. Test error scenarios

## Common Integration Issues

* [Handling failed payments](/api-reference/technical-faqs#failed-payments)
* [Webhook timeouts](/api-reference/technical-faqs#webhook-timeouts)
* [Authentication errors](/api-reference/technical-faqs#authentication-errors)

## Next Steps

<CardGroup cols={2}>
  <Card title="API Reference" icon="code" href="/api-reference/payments/get-payments">
    Explore all available endpoints
  </Card>

  <Card title="SDKs" icon="box" href="/developer-resources/dodo-payments-sdks">
    View SDK documentation
  </Card>

  <Card title="Webhooks" icon="bell" href="/developer-resources/webhooks/intents/webhook-events-guide">
    Learn about webhook events
  </Card>

  <Card title="Testing" icon="vial" href="/miscellaneous/testing-process">
    Test your integration
  </Card>
</CardGroup>

## Need Help?

* Join our [Developer Community](https://community.dodopayments.com)
* Check our [Technical FAQs](/api-reference/technical-faqs)
* Contact [Developer Support](/miscellaneous/help-support)
