# Virtual Terminal

> Accept in-person payments in Ghana with Virtual Terminal, with no dedicated hardware.

Virtual Terminal transforms a mobile phone into a point-of-sale system, enabling businesses to accept payments without dedicated POS hardware. By connecting a WhatsApp-enabled phone to your Virtual Terminals, you can instantly set up a payment point that supports MoMo, Cards, Apple Pay and USSD payments.

![Virtual Terminal poster](/gh/payments/in-person/images/vt-poster-gh.png)

## Create the Virtual Terminal

1. Create a Virtual Terminal with a `name` and up to five WhatsApp-enabled phone numbers as `destinations`. Include the country code in each phone number, for example `+233244123456`.
2. Keep the `code` (for example `VT_L837PT5K`) and the payment details returned in the response. You'll need the code to match incoming payments and the payment details to share with customers.

<code-tabs>
<template v-slot:curl="">

```bash
curl https://api.paystack.co/virtual_terminal \
  -H "Authorization: Bearer YOUR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Sales Point #1",
    "destinations": [
      { 
        "target": "+233244123456" 
      }
    ]
  }' \
  -X POST
```

</template>

<template v-slot:nodejs="">

```js
const response = await fetch('https://api.paystack.co/virtual_terminal', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer YOUR_SECRET_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Sales Point #1',
    destinations: [
      { 
        target: '+233244123456' 
      }
    ]
  })
})

const terminal = await response.json()
console.log(terminal)
```

</template>
</code-tabs>

Paystack creates a dedicated USSD code for the terminal and returns it in `paymentMethods`:

```json
{
  "status": true,
  "message": "Virtual Terminal created",
  "data": {
    "id": 26677,
    "name": "Sales Point #1",
    "code": "VT_L837PT5K",
    "paymentMethods": [
      {
        "type": "mobile_money_ussd",
        "account_number": "*415*1548#"
      }
    ],
    "active": true,
    "destinations": [
      { 
        "target": "233244123456", 
        "type": "whatsapp", 
        "name": null 
      }
    ],
    "currency": "GHS"
  }
}
```

<callout title="Poster Customisation" type="info">

Use the USSD code returned in `account_number` from `paymentMethods` to create custom posters for Momo transactions.

</callout>

## Choose how customers will pay

1. Use the Paystack-generated poster when you want customers to scan a QR code and open the terminal's payment page. Checkout on this page supports cards, bank transfer, and mobile money.
2. Use the dedicated payment details returned for the market when you want customers to pay directly with local payment rails, without opening a checkout page.

## Share the payment surface

1. From the Terminals tab in your Paystack Dashboard, select the Virtual Terminal, open its details, and download the poster.
2. Display the poster somewhere customers can easily scan it.
3. Also share the USSD code returned in `paymentMethods`. Customers can dial it directly to pay without scanning the poster.

## Accept the payment

1. The customer opens the payment page by scanning the poster's QR code, or pays directly with the dedicated payment details.
2. They complete the payment with whichever method is available at checkout for that market: card, bank transfer, or mobile money.

## Monitor notifications

1. Watch the registered WhatsApp numbers. They receive a confirmation when the terminal is created, and a notification with the amount and timestamp for every successful payment.
2. Listen for `charge.success` on your webhook URL.
3. Match the payment to the correct terminal using `data.metadata.virtual_terminal`, or by checking that `data.source.source` is `virtual_terminal`.

```js
import crypto from 'crypto'
import express from 'express'

const app = express()
app.use(express.json())

app.post('/api/paystack/webhook', (req, res) => {
  const signature = req.headers['x-paystack-signature']
  const hash = crypto
    .createHmac('sha512', 'YOUR_SECRET_KEY')
    .update(JSON.stringify(req.body))
    .digest('hex')

  if (hash !== signature) {
    return res.sendStatus(401)
  }

  const { event, data } = req.body

  if (event === 'charge.success' && data.source?.source === 'virtual_terminal') {
    const terminalCode = data.metadata?.virtual_terminal?.code
    console.log('Virtual Terminal payment confirmed:', terminalCode, data.amount)
    // mark the payment point's order as paid
  }

  return res.sendStatus(200)
})
```

## Expand usage when needed

1. Add more Virtual Terminals for extra payment points.
2. Use the same flow for small storefronts, mobile vendors, delivery businesses collecting payment on delivery, and temporary or seasonal payment locations.

This flow works well when you need a payment point fast and don't want to depend on dedicated hardware.
