Custom Website Integration

A developer's guide to integrating Flik payments directly into your website.

Download Postman Collection

Integration Steps

API Base URL

All API requests referenced in this guide should be made to the following base URL:

https://app.flik.co.nz

1. Get Your Credentials

Before you begin, ensure you have created a Payment Method in the Flik Portal and saved your Client ID and Client Secret.

If you haven't done this yet, please refer to the Creating a Payment Method guide.

2. Get an Access Token

To interact with the Flik API, you first need to obtain an access token. Make a POST request to the token endpoint with your credentials.

Endpoint: POST https://app.flik.co.nz/api/token

Body (application/x-www-form-urlencoded):

clientId=YOUR_CLIENT_ID&clientSecret=YOUR_CLIENT_SECRET

Response:

{
  "accessToken": "eyJhbGciOiJIUzUxMiIsIn...",
  "tokenType": "Bearer",
  "expiresIn": "5m"
}

3. Create a Transaction

Once you have the access token, you can create a transaction. This will generate a redirect URL for your customer.

Endpoint: POST https://app.flik.co.nz/api/transaction

Headers:

Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json

Body (JSON):

{
  "type": "single",
  "redirectUrl": "https://your-website.com/checkout/complete",
  "amount": {
    "currency": "NZD",
    "total": 10.00
  },
  "creditorReference": {
    "reference": "Order123",
    "particulars": "Optional",
    "code": "Optional"
  },
  "webhookUrl": "https://your-website.com/api/webhook"
}

Response:

{
  "redirectUrl": "https://app.flik.co.nz/transaction/..."
}

4. Redirect the User

Take the redirectUrl from the response in the previous step and redirect your customer's browser to that URL. They will complete the payment on the Flik hosted page.

5. Verify Payment

After the customer completes the payment, they will be redirected back to your redirectUrl. You should then verify the transaction status using the API.

Endpoint: GET https://app.flik.co.nz/api/transaction/{transactionId}

Response:

{
  "state": "Completed",
  "testMode": false,
  "total": 10.00,
  "name": "Customer Name",
  "date": "2023-10-27T00:00:00Z"
}

Check that state is Completed to confirm the payment was successful.