# How to integrate Redirect Checkout

> Initialize a transaction, redirect to Paystack Checkout, and verify the result on return.

For the product overview, see [Checkout](/payments/online/checkout).

<callout type="warning">

Confirm that your server can complete a TLSv1.2 connection to Paystack's servers. Most up-to-date software handles this automatically. If you receive SSL errors, contact your hosting provider.

</callout>

## Initialize the transaction on your backend

Create the transaction from your server and include a callback URL.

```js
const https = require('https')

const params = JSON.stringify({
  email: 'customer@email.com',
  amount: '20000',
  callback_url: 'https://hello.pstk.xyz/callback',
  metadata: {
    cancel_action: 'https://your-cancel-url.com'
  }
})

const options = {
  hostname: 'api.paystack.co',
  port: 443,
  path: '/transaction/initialize',
  method: 'POST',
  headers: {
    Authorization: 'Bearer YOUR_SECRET_KEY',
    'Content-Type': 'application/json'
  }
}

const req = https.request(options, (res) => {
  let data = ''

  res.on('data', (chunk) => {
    data += chunk
  })

  res.on('end', () => {
    console.log(JSON.parse(data))
  })
})

req.write(params)
req.end()
```

A successful initialization returns `authorization_url`, `access_code`, and `reference`.

## Redirect the customer to `authorization_url`

After initialization, send the customer to the hosted Checkout page.

```js
app.post('/pay', async (req, res) => {
  const response = await initializeTransaction(req.body)
  res.redirect(response.data.authorization_url)
})
```

Use your own unique transaction reference if you generate one internally.

## Handle the callback

When the customer completes the flow, Paystack redirects them back to your callback URL with the transaction reference in the query string.

```js
app.get('/callback', (req, res) => {
  const { reference } = req.query
  res.redirect(`/payment-status?reference=${reference}`)
})
```

A visited callback URL only means the customer returned to your app. It does not confirm success.

## Verify the transaction from your server

Verify the returned reference before fulfilment.

```bash
curl https://api.paystack.co/transaction/verify/:reference \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-X GET
```

The verify response contains the transaction status and the amount charged. Fulfil the order only when `data.status` is `success` and the amount matches the transaction you created.

## Handle webhook confirmation

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.

Keep the verify call for callback handling and reconciliation.
