# Build your first checkout

> Initialize a transaction, open the Paystack Popup, verify the payment, and handle webhooks.

Use this tutorial to build a simple one-time checkout with Paystack Popup. Your server initializes the transaction, your frontend opens the checkout, and your server verifies and fulfills the payment.

<callout type="danger" title="Secure your account">

Never use your Paystack secret key in frontend code. Initialize transactions, verify payments, and validate webhook signatures on your server only.

</callout>

## 1. Prerequisites

Before you start, get your test keys, prepare a server, and expose a public webhook URL.

- A Paystack test public key and secret key
- Your test webhook signing secret (`whsec_...`)
- A server that can call the Paystack API
- A public `POST` webhook URL for Paystack events
- A trusted amount stored on your server for the order you want to charge

In this tutorial, the order amount is **5000  = 500000 **.

<localized-snippet src="payments/get-started/env-vars">



</localized-snippet>

<callout type="info" title="Testing locally">

Your webhook URL must be publicly reachable over HTTPS. To receive webhooks on your local machine, expose your server through a tunnel such as ngrok. See [Webhooks](/developer-tools/integration/webhooks).

</callout>

## 2. Initialize a transaction

Create the transaction on your server with the customer's email and the amount in <localized-value page-key="markets" path="subunit">



</localized-value>

, then return the `authorization_url` and `access_code` to your frontend.

<localized-snippet src="payments/get-started/initialize-transaction">



</localized-snippet>

<callout type="warning">

Do not calculate the final amount on the frontend. Look up the order on your server and send the trusted amount to Paystack.

</callout>

## 3. Open the checkout

Call your initialize endpoint from the frontend, then open Paystack Popup with the returned `access_code`.

<localized-snippet src="payments/get-started/open-checkout">



</localized-snippet>

## 4. Verify the payment

After checkout, verify the transaction on your server with the transaction reference and only treat it as paid when `data.status` is `success` and the amount matches your order.

<localized-snippet src="payments/get-started/verify-payment">



</localized-snippet>

<callout type="danger">

Do not deliver value just because the customer returned to your app. Always verify the transaction on your server first.

</callout>

## 5. Handle it with a webhook

Use the `charge.success` webhook as your primary signal to fulfill orders, grant access, or update your database. The customer can close the page before your callback runs, but the webhook still arrives.

Add your webhook URL on the [Paystack Dashboard](https://dashboard.paystack.com/v2/developers/api-configuration), and [verify the signature](/developer-tools/integration/webhooks#verify-webhook-signatures) on every event with your webhook signing secret.

Then confirm the event, status, and amount before you deliver value.

<localized-snippet src="payments/get-started/webhook-handler">



</localized-snippet>

<callout type="info">

Use the raw request body to compute the webhook signature. If your framework parses JSON before you hash the payload, the signature check can fail.

</callout>

## 6. Test it

Run your app, start a checkout, and complete the test payment with Paystack's successful test card.

<localized-snippet src="payments/get-started/test-card">



</localized-snippet>

Use this flow in test mode first: initialize the transaction, open the popup, verify the reference on your server, and confirm that your webhook receives `charge.success` before you ship live.
