> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.transxact.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.transxact.io/_mcp/server.

# Quickstart

Signup only asks for an email address and your business name, with no
documents and no waiting. You get a Test mode API key straight away, and Test
mode simulates payments: no M-PAiSA or MyCash wallet is charged and no real
money moves, so you can build and test your whole integration before anyone
checks your documents. Live mode opens once your Verification is approved:
your company registration, TIN and TIN card photo, your directors and owners,
and a few details about what you sell. It's reviewed in the background.

## Building with an AI agent?

Give your coding agent [Integrate with an AI agent](/guides/integrate-with-an-ai-agent),
one linear recipe from install to Live mode. It can also read the whole site:

* [`docs.transxact.io/llms.txt`](https://docs.transxact.io/llms.txt) indexes
  every page, and adding `.md` to any page's URL returns it as Markdown.
* The docs MCP server lets the agent search these docs itself. In Claude Code:

  ```bash
  claude mcp add --transport http transxact-docs https://docs.transxact.io/_mcp/server
  ```

  Other MCP clients, such as Cursor, take the same URL.

## 1. Get a Test mode key

[Sign up](https://transxact.io/signup) and choose the Business account. Your
Test mode key (`sk_test_...`) is shown on the next screen, once. Copy it then:
we keep only a hash, and the dashboard shows just its last characters. If you
lose it, **Roll key** on the dashboard revokes it and gives you a new one.

Keep the key on your server. It never belongs in a browser or a mobile app
(see [Mobile integration](/guides/mobile-integration)).

## 2. Create a Checkout Session

```bash
curl https://api.transxact.io/v1/checkout-sessions \
  -X POST \
  -H "Authorization: Bearer sk_test_..." \
  -H "Idempotency-Key: a1b2c3d4-order-9912" \
  -H "Content-Type: application/json" \
  -d '{ "amount": 5000, "currency": "FJD" }'
```

It answers `201` with the Checkout Session:

```json
{
  "id": "cs_3f9c2b1a",
  "status": "pending",
  "amount": 5000,
  "currency": "FJD",
  "hostedUrl": "https://transxact.io/c/cs_3f9c2b1a",
  "metadata": {},
  "expiresAt": 1717086400000
}
```

`amount` is in FJD cents and must be under FJD 5,000.00 (at most `499999`), in
Test mode and Live mode alike. A larger amount returns `400 invalid_request`.

The `Idempotency-Key` header is required. If your server times out and retries
the create call, the same key replays the original response instead of
creating a second Checkout Session for the same customer. Replayed responses
are stored for \~24h. Use something tied to the order, like its id.

Prefer a library? Install an SDK and make the same call from its client:

```bash
npm install @transxact/node          # Node and TypeScript
composer require transxact/transxact # PHP
```

The client sends your key as `Authorization: Bearer` and calls
`https://api.transxact.io` unless you point it elsewhere. In Node:

```typescript
import { TransxactApiClient } from "@transxact/node";

const client = new TransxactApiClient({ token: "sk_test_..." });

const session = await client.checkoutSessions.create({
  idempotencyKey: "a1b2c3d4-order-9912",
  amount: 5000,
  currency: "FJD",
});
```

In PHP:

```php
<?php

use Transxact\TransxactClient;
use Transxact\CheckoutSessions\Requests\CreateCheckoutSessionRequest;

$client = new TransxactClient(token: 'sk_test_...');

$session = $client->checkoutSessions->create(
    new CreateCheckoutSessionRequest([
        'idempotencyKey' => 'a1b2c3d4-order-9912',
        'amount' => 5000,
        'currency' => 'FJD',
    ]),
);
```

Both return the Checkout Session above, so `session.hostedUrl` (Node) or
`$session->hostedUrl` (PHP) is where you send your customer next. Each client
also has `retrieve` and `cancel` under `checkoutSessions`, taking the
session's id.

### Request

POST [https://api.transxact.io/v1/checkout-sessions](https://api.transxact.io/v1/checkout-sessions)

```curl
curl -X POST https://api.transxact.io/v1/checkout-sessions \
     -H "idempotency-key: a1b2c3d4-order-9912" \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{}'
```

```typescript
import { TransxactApiClient } from "@transxact/node";

async function main() {
    const client = new TransxactApiClient({
        token: "YOUR_TOKEN_HERE",
    });
    await client.checkoutSessions.create({
        idempotencyKey: "a1b2c3d4-order-9912",
    });
}
main();

```

```php
<?php

namespace Example;

use Transxact\TransxactClient;
use Transxact\CheckoutSessions\Requests\CreateCheckoutSessionRequest;

$client = new TransxactClient(
    token: 'YOUR_TOKEN_HERE',
);
$client->checkoutSessions->create(
    new CreateCheckoutSessionRequest([
        'idempotencyKey' => 'a1b2c3d4-order-9912',
    ]),
);

```

```python
import requests

url = "https://api.transxact.io/v1/checkout-sessions"

payload = {}
headers = {
    "idempotency-key": "a1b2c3d4-order-9912",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.transxact.io/v1/checkout-sessions"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("idempotency-key", "a1b2c3d4-order-9912")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.transxact.io/v1/checkout-sessions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["idempotency-key"] = 'a1b2c3d4-order-9912'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.transxact.io/v1/checkout-sessions")
  .header("idempotency-key", "a1b2c3d4-order-9912")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.transxact.io/v1/checkout-sessions");
var request = new RestRequest(Method.POST);
request.AddHeader("idempotency-key", "a1b2c3d4-order-9912");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "idempotency-key": "a1b2c3d4-order-9912",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.transxact.io/v1/checkout-sessions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

## 3. Send your customer to `hostedUrl`

Redirect your customer to the session's `hostedUrl`. That page offers every
way to pay, takes the payment, and handles each wallet's own steps, so you
build one integration, not one per wallet.

To bring your customer back afterwards, add `successUrl` and `cancelUrl` to
the create call (both optional, HTTPS only):

```json
{
  "amount": 5000,
  "currency": "FJD",
  "successUrl": "https://shop.example/orders/9912/thanks",
  "cancelUrl": "https://shop.example/cart"
}
```

Once the payment succeeds, the hosted page returns them to `successUrl`. If
they cancel, or the payment doesn't go through, it offers a way back to
`cancelUrl`. Both arrive with `?session_id=cs_...` appended. Anyone can open
a URL, so use `session_id` to look the Checkout Session up
(`GET /v1/checkout-sessions/{id}`) or wait for the webhook before fulfilling
the order.

To match a session to your own order without keeping a mapping, add
`"metadata": { "orderId": "9912" }`. You can send up to 20 string pairs. They
come back on retrieve and in every webhook, and are never shown to your
customer.

A Checkout Session expires 24 hours after you create it. To change that, set
`expiresAt` to a Unix-milliseconds time between 30 minutes and 24 hours
ahead. Once a session expires it can't be paid, and it moves to `cancelled`
with a `checkout_session.cancelled` webhook. To withdraw a session before
then, call `POST /v1/checkout-sessions/{id}/cancel`. That returns
`payment_in_progress` if your customer has already started paying.

## 4. Pay it yourself in Test mode

Open the `hostedUrl` and pay as your customer would. The page is marked as a
test payment, and in place of each wallet's own steps it shows a practice
version:

* **M-PAiSA:** a practice screen with the amount. **Approve payment** makes
  the session `succeeded`; **Decline payment** makes it `failed`.
* **MyCash:** enter any 7-digit Fiji mobile number, such as `7123456`. No text
  is sent: the page shows the test code, `123456`. A wrong code is refused so
  you can try again, and the right one makes the session `succeeded`.

Everything after that runs as it does for a real payment: the webhook is sent,
the fee is taken, the session shows on your dashboard, and your customer is
returned to `successUrl`.

## 5. Listen for the webhook

Transxact tells your server the outcome with a webhook, so you don't have to
poll. Add your endpoint's URL in the **Webhooks** section of the dashboard.
Every event looks like this, with the Checkout Session as it now stands:

```json
{
  "id": "evt_9c1e4b7a2d0f4e6b8a1c3d5e7f9a0b2c",
  "type": "checkout_session.succeeded",
  "data": {
    "object": {
      "id": "cs_3f9c2b1a",
      "status": "succeeded",
      "amount": 5000,
      "currency": "FJD",
      "hostedUrl": "https://transxact.io/c/cs_3f9c2b1a",
      "metadata": { "orderId": "9912" },
      "expiresAt": 1717086400000
    }
  }
}
```

The types are `checkout_session.succeeded`, `checkout_session.failed` and
`checkout_session.cancelled`. Check the signature before trusting one: see
[Verifying webhooks](/guides/verifying-webhooks).

**Developing on your own machine?** Webhook endpoints must be public
`https://` URLs, so `localhost` can't receive them directly. Run a tunnel
(such as `cloudflared tunnel --url http://localhost:3000` or
`ngrok http 3000`) and add its `https://` address as an endpoint. The
dashboard's **Send test** button sends a signed `webhook.test` event there, so
you can check your endpoint before paying anything.

## 6. Go live

Send your Verification from the dashboard whenever you're ready. It's reviewed
in the background, with no blocking step or sales call, and you can keep
building in Test mode meanwhile. Once it's approved, the dashboard offers
**Create Live mode key**. Swap `sk_test_...` for `sk_live_...` and nothing
else changes. See [Test vs Live mode](/guides/test-vs-live-mode).