Using Claude with NaafiPay
Claude is an AI assistant from Anthropic that is particularly good at reading long documents, following precise instructions, and writing production-quality code. When you give Claude your NaafiPay API documentation as context, it can generate complete, working integrations on the first try — including the small details like idempotency keys, webhook verification, and error handling that ad-hoc AI prompts usually skip. This page explains how to feed Claude the right context and gives you four ready-to-paste prompt templates for the most common integration tasks.
Why context matters
Without context, an AI assistant has to guess what your payment API looks like. That usually produces code that uses Stripe field names, the wrong authentication header, or a non-existent endpoint. By pasting the relevant docs page into your conversation before asking for code, you remove the guesswork — Claude works from the same spec you do and produces code that matches the real API on the first try.
Setting up the conversation
Open a new Claude conversation, paste the full text of the API page you care about (for example, the Verify Payment page), then ask your question. If you are integrating end-to-end, paste the API Overview page, the Create Checkout page, the Verify Payment page, and the Webhooks page — Claude can hold all four in context at once.
Prompt template 1 — Create a checkout
1Here is the NaafiPay Create Checkout endpoint:2[paste the full Create Checkout page]3 4Using my Node.js + TypeScript Express backend, write a POST /checkout route that:5- Accepts { orderId, amount, customerName, customerEmail } from the request body6- Calls NaafiPay /api/public/v1/payments with the API key from process.env.NAAFIPAY_KEY7- Returns the checkout_url to the client as JSON8- Includes full error handling and TypeScript types9- Does not use any npm package other than the built-in fetch10 11Show the complete file, including imports.Prompt template 2 — Verify payment
1Here is the NaafiPay Verify Payment endpoint:2[paste the full Verify Payment page]3 4I have a Next.js App Router success page at app/thank-you/page.tsx that receives5?invoice_id as a search param. Write the server component that:6- Calls /api/public/v1/verify-payment server-side with the invoice_id7- Renders a success UI if status is "completed"8- Renders a "payment not yet confirmed" UI for "pending"9- Renders an error UI for "failed" or "cancelled"10- Never imports the API key into a client component11 12Provide the complete page.tsx.Prompt template 3 — Handle webhooks
1Here is the NaafiPay Webhooks page:2[paste the full Webhooks page]3 4Write a Python Flask route that:5- Accepts POST /webhooks/naafipay6- Verifies the x-paygate-signature-v2 HMAC and the 5-minute replay window7- For event "payment.completed", marks the order with metadata.order_id as paid8 in a Postgres database (use the orders table with columns id, status, paid_at)9- Returns 200 for handled events and 401 for invalid signatures10- Uses psycopg2 and reads the signing secret from env NAAFIPAY_WEBHOOK_SECRET11 12Provide the complete file.Prompt template 4 — Full payment flow
1Here are the NaafiPay docs:2[paste API Overview, Create Checkout, Verify Payment, Webhooks pages]3 4I run a Bangladeshi digital course platform. Write a complete payment flow in5PHP (Laravel 11) that:61. Has a buy button that POSTs to /buy/{course} and redirects to the NaafiPay7 checkout_url82. Has a /payment/success route that verifies the payment and grants course9 access only if completed103. Has a /webhooks/naafipay route that revokes access on payment.cancelled and11 grants access on payment.completed (idempotently)124. Uses Laravel's HTTP client and the User and Course Eloquent models13 14Show migrations, routes, controllers, and the env variables I need.