Tokenisation Integration Guide
This guide walks you through implementing tokenisation via the Connected Payments iFrame — capture a card, create a token, and process payments using the token.
What you'll need:
configId- Your iFrame configuration IDuserName- Your Connected Payments username with transaction permissionssecretKey- Your shared secret key (for HMAC generation)- HTTPS-enabled website (for embedded iFrames)
Read first:
- Tokenisation Overview — what tokenisation is and how it works
- Embedded and Hosted Integration Guide — base iFrame setup
Code samples: Code samples within this document are provided for reference purposes only and are not intended for production use.
How it works
There are two main workflows for tokenisation with the iFrame. You can capture a card and create a token without charging (token-only), or capture a card, create a token, and charge in a single step (payment + token). Once a token exists, you can process future payments either through the iFrame or via the Submit Purchase API.
Summary:
- Customer loads the iFrame on your site
- Card details are captured securely — card data never touches your server
- A token is generated and returned to you via webhook or PostMessage
- You store the token against the customer in your system
- Future payments use the token instead of card details — via iFrame or API
Choose your approach
| Approach | When to use | How it works |
|---|---|---|
Token only (onlyTokenise=true) | Account sign-up, subscription onboarding, saving a card for later | Card is captured and tokenised — no payment occurs |
Payment + Token (tokenControl.token=true) | First purchase where you also want to save the card | Payment is processed and token is created in a single step |
Once the token is stored, choose how to process future payments:
| Method | When to use | Notes |
|---|---|---|
iFrame with cardToken | Customer-present scenarios (e.g. one-click checkout) | Stored card details are pre-populated; all fields except PAN are editable |
| Submit Purchase API | Server-initiated payments (e.g. recurring billing, subscriptions) | No customer interaction required — fully server-to-server |
Step 1: Generate HMAC signature
All iFrame requests require an HMAC SHA-256 signature generated server-side. The process is the same as in Step 1 of the Embedded and Hosted Integration Guide — the only difference is the parameters you include.
Server-side only — Never expose secretKey in client code.
Include all parameters before verifyMessage in the signature, in the exact order they appear in the URL - including tokenisation parameters such as onlyTokenise and tokenControl.*.
Optional parameters added after verifyMessage are not signed or verified.
Sign the URL-encoded values exactly as sent, including spaces and special characters.
- Token Only
- Payment + Token
For token-only flows, include onlyTokenise=true and any tokenControl.* parameters in the signed parameters.Node.js
PHP
Python
C#
For payment + token flows, include the payment amount (in dollars) and tokenControl.token=true in the signed parameters.Node.js
PHP
Python
C#
Step 2: Build the iFrame URL
Append the signed parameter string and HMAC to the iFrame endpoint. The tokenisation parameters (onlyTokenise=true or tokenControl.token=true) are already part of paramString from Step 1 - do not add parameters after signing.
- Token Only
- Payment + Token
const baseUrl =
"https://sandbox.connectedpayments.commbank.com.au/es-client-frontend/hosted";
const iframeUrl = `${baseUrl}?${paramString}&verifyMessage=${verifyMessage}`;
Your assembled URL will look like this for the Hosted implementation:
https://sandbox.connectedpayments.commbank.com.au/es-client-frontend/hosted?configId=5f06c5f5-d4cb-483b-b0b2-242f48516dc5&userName=merchant.iframes&txnType=1&merchReference=TOKEN-1234567890&amount=0&onlyTokenise=true&tokenControl.tokenFormat=F6L4AN&verifyMessage=abc123def456...
Your assembled URL will look like this for the Embedded implementation:
https://sandbox.connectedpayments.commbank.com.au/es-client-frontend/embedded?configId=5f06c5f5-d4cb-483b-b0b2-242f48516dc5&userName=merchant.iframes&txnType=1&merchReference=TOKEN-1234567890&amount=0&onlyTokenise=true&tokenControl.tokenFormat=F6L4AN&verifyMessage=abc123def456...
Setting onlyTokenise=true renders a card-capture-only page. No payment occurs regardless of any amount or txnType values passed alongside it.
Token creation checks the card number's length, check digit (Luhn) and expiry format only. The issuer is not contacted, so a successful token does not prove the card is valid or can be charged. 3DS is not available for token-only requests.
const baseUrl =
"https://sandbox.connectedpayments.commbank.com.au/es-client-frontend/hosted";
const iframeUrl = `${baseUrl}?${paramString}&verifyMessage=${verifyMessage}`;
Your assembled URL will look like this for the Hosted implementation:
https://sandbox.connectedpayments.commbank.com.au/es-client-frontend/hosted?configId=5f06c5f5-d4cb-483b-b0b2-242f48516dc5&userName=merchant.iframes&txnType=1&merchReference=ORDER-1234567890&amount=10.00&tokenControl.token=true&tokenControl.tokenFormat=F6L4AN&verifyMessage=abc123def456...
Your assembled URL will look like this for the Embedded implementation:
https://sandbox.connectedpayments.commbank.com.au/es-client-frontend/embedded?configId=5f06c5f5-d4cb-483b-b0b2-242f48516dc5&userName=merchant.iframes&txnType=1&merchReference=ORDER-1234567890&amount=10.00&tokenControl.token=true&tokenControl.tokenFormat=F6L4AN&verifyMessage=abc123def456...
The token is only created if the payment is approved. If the transaction is declined, no token is stored.
Step 3: Implement the iFrame
Choose how to display the card capture form to your customers.
- Embedded iFrame
- Hosted (Redirect)
<iframe
id="connectedpayments-iframe"
src="YOUR_GENERATED_URL"
width="100%"
height="600px"
frameborder="0"
allow="payment"
>
</iframe>
window.location.href = iframeUrl;
The customer is redirected to the Connected Payments hosted page and completes the card capture or payment.
Step 4: Receive the token
After the customer submits their card details, Connected Payments returns the token. How you receive it depends on your integration type.
- Webhook / Notifications
- PostMessages
Server-to-server webhooks are the recommended and most reliable way to receive tokens.View webhook implementation example
Configuration: Webhooks are configured in your iFrame config. Contact CommBank Support to set up.
For Embedded integration only
Listen for PostMessages from the iFrame to receive the token in real-time. Use for UI feedback — never as the authoritative source for token storage.View PostMessages implementation example
See also: PostMessages Guide
Response handling comparison
| Method | Use Case | Validation |
|---|---|---|
| Webhook | Authoritative token storage & payments | Custom header and/or IP allow-list |
| PostMessage | Real-time UI updates (embedded) | Origin check only |
Approach:
- Primary: Use webhooks for authoritative token storage and payment processing
- Secondary: Use PostMessages for immediate customer feedback
- Always: Authenticate webhooks using a custom header and/or IP allow-list. Notifications are not signed. See Validating incoming notifications
- Never: Store tokens based solely on PostMessages
Step 5: Use the token for future payments
Once you have a stored token, use it to charge the customer without them re-entering card details. You have two options:
- iFrame with Token
- Submit Purchase API
Process payment via iFrame using cardToken
Pass the stored cardToken as a URL parameter when building the iFrame URL. The stored card details are pre-populated in the payment form, with all fields except the PAN (card number) editable by the customer.
const crypto = require("crypto");
const params = {
configId: "5f06c5f5-d4cb-483b-b0b2-242f48516dc5",
userName: "merchant.iframes",
txnType: 1,
merchReference: `ORDER-${Date.now()}`,
amount: "29.99", // dollars, not cents
cardToken: "STORED_TOKEN_VALUE",
};
// cardToken must be included in paramString so it is covered by the HMAC signature
const paramString = new URLSearchParams(params).toString();
const verifyMessage = crypto
.createHmac("sha256", process.env.CONNECTED_PAYMENTS_SECRET_KEY)
.update(paramString)
.digest("hex");
const baseUrl =
"https://sandbox.connectedpayments.commbank.com.au/es-client-frontend/hosted";
const iframeUrl = `${baseUrl}?${paramString}&verifyMessage=${verifyMessage}`;
When to use: Customer-present scenarios like one-click checkout, subscription renewals with customer confirmation, or re-billing after a failed payment.
Process payment via the Submit Purchase API
Submit a server-to-server payment request using the stored cardToken in place of pan and cardExpiryDate. No customer interaction is required.
See: Submit a Purchase Request
curl -X POST https://sandbox.connectedpayments.commbank.com.au/paymentshub/api/v1/payments/purchase \
-H "Content-Type: application/json" \
-d '{
"userName": "your-username",
"password": "your-password",
"cardToken": "STORED_TOKEN_VALUE",
"merchReference": "SUB-RENEWAL-12345",
"amount": "2999",
"txnType": "1",
"requestorIp": "1.1.1.1",
"ecm": "31"
}'
Node.js
const axios = require("axios");
const response = await axios.post(
"https://sandbox.connectedpayments.commbank.com.au/paymentshub/api/v1/payments/purchase",
{
userName: process.env.ES_USERNAME,
password: process.env.ES_PASSWORD,
cardToken: "STORED_TOKEN_VALUE",
merchReference: `SUB-RENEWAL-${Date.now()}`,
amount: "2999",
txnType: "1",
requestorIp: "1.1.1.1",
ecm: "31",
},
{ headers: { "Content-Type": "application/json" } },
);
if (response.data.responseCode === "00") {
console.log("Payment successful:", response.data.txnReference);
} else {
console.log("Payment failed:", response.data.message);
}
PHP
$response = json_decode(file_get_contents('https://sandbox.connectedpayments.commbank.com.au/paymentshub/api/v1/payments/purchase', false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/json',
'content' => json_encode([
'userName' => getenv('ES_USERNAME'),
'password' => getenv('ES_PASSWORD'),
'cardToken' => 'STORED_TOKEN_VALUE',
'merchReference' => 'SUB-RENEWAL-' . time(),
'amount' => '2999',
'txnType' => '1',
'requestorIp' => '1.1.1.1',
'ecm' => '31'
])
]
])), true);
if ($response['responseCode'] === '00') {
echo 'Payment successful: ' . $response['txnReference'];
}
Python
import requests
import os
import time
response = requests.post(
'https://sandbox.connectedpayments.commbank.com.au/paymentshub/api/v1/payments/purchase',
json={
'userName': os.environ['ES_USERNAME'],
'password': os.environ['ES_PASSWORD'],
'cardToken': 'STORED_TOKEN_VALUE',
'merchReference': f'SUB-RENEWAL-{int(time.time())}',
'amount': '2999',
'txnType': '1',
'requestorIp': '1.1.1.1',
'ecm': '31'
},
headers={'Content-Type': 'application/json'}
)
result = response.json()
if result['responseCode'] == '00':
print(f"Payment successful: {result['txnReference']}")
When to use: Server-initiated payments like recurring billing, subscription renewals, scheduled payments, or any flow where the customer is not present.
For scheduled renewals, use a second ECM digit of 2 (e.g. 32). First and one-click charges use 31. See ECM values for stored-card charges. Recurring transactions must be pre-agreed with your acquiring bank — misuse can result in scheme penalties.
Complete examples
- Token Only + API Payment
- Payment + Token
View full Node.js implementation — Token only, then API payment
// server.js
const express = require("express");
const crypto = require("crypto");
const axios = require("axios");
const app = express();
const CONFIG = {
configId: "5f06c5f5-d4cb-483b-b0b2-242f48516dc5",
userName: "merchant.iframes",
secretKey: process.env.CONNECTED_PAYMENTS_SECRET_KEY,
apiUserName: process.env.ES_USERNAME,
apiPassword: process.env.ES_PASSWORD,
baseUrl: "https://sandbox.connectedpayments.commbank.com.au",
};
// --- Step 1: Generate token-only iFrame URL ---
function generateTokenOnlyUrl(customerRef) {
const params = {
configId: CONFIG.configId,
userName: CONFIG.userName,
txnType: 1,
merchReference: customerRef,
amount: 0,
onlyTokenise: true,
"tokenControl.tokenFormat": "F6L4AN",
};
// Sign every parameter placed before verifyMessage, in URL order
const paramString = new URLSearchParams(params).toString();
const verifyMessage = crypto
.createHmac("sha256", CONFIG.secretKey)
.update(paramString)
.digest("hex");
return `${CONFIG.baseUrl}/es-client-frontend/hosted?${paramString}&verifyMessage=${verifyMessage}`;
}
// Serve card capture page
app.get("/save-card/:customerId", (req, res) => {
const iframeUrl = generateTokenOnlyUrl(
`TOKEN-${req.params.customerId}-${Date.now()}`,
);
res.render("save-card", { iframeUrl });
});
// --- Step 2: Receive token via webhook ---
app.post("/webhook/token", express.json(), (req, res) => {
// Authenticate with the custom header configured on your notification rule
const received = Buffer.from(req.headers["x-notification-secret"] || "");
const expected = Buffer.from(process.env.NOTIFICATION_SECRET);
if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected)) {
return res.status(401).end();
}
const { cardToken, merchReference } = req.body;
if (cardToken) {
// Store token for future use
saveTokenForCustomer(merchReference, cardToken);
}
res.status(200).send("OK");
});
// --- Step 3: Charge using stored token via API ---
app.post("/charge/:customerId", express.json(), async (req, res) => {
const token = await getStoredToken(req.params.customerId);
const response = await axios.post(
`${CONFIG.baseUrl}/paymentshub/api/v1/payments/purchase`,
{
userName: CONFIG.apiUserName,
password: CONFIG.apiPassword,
cardToken: token,
merchReference: `ORDER-${req.params.customerId}-${Date.now()}`,
amount: String(req.body.amount),
txnType: "1",
requestorIp: req.ip,
ecm: "31",
},
{ headers: { "Content-Type": "application/json" } },
);
if (response.data.responseCode === "00") {
res.json({ success: true, txnReference: response.data.txnReference });
} else {
res.json({ success: false, message: response.data.message });
}
});
app.listen(3000);
View full Node.js implementation — Payment + token in one step
// server.js
const express = require("express");
const crypto = require("crypto");
const app = express();
const CONFIG = {
configId: "5f06c5f5-d4cb-483b-b0b2-242f48516dc5",
userName: "merchant.iframes",
secretKey: process.env.CONNECTED_PAYMENTS_SECRET_KEY,
baseUrl:
"https://sandbox.connectedpayments.commbank.com.au/es-client-frontend/hosted",
};
// --- Step 1: Generate payment + token iFrame URL ---
function generatePaymentWithTokenUrl(orderData) {
const params = {
configId: CONFIG.configId,
userName: CONFIG.userName,
txnType: 1,
merchReference: orderData.reference,
amount: orderData.amount,
"tokenControl.token": true,
"tokenControl.tokenFormat": "F6L4AN",
};
// Sign every parameter placed before verifyMessage, in URL order
const paramString = new URLSearchParams(params).toString();
const verifyMessage = crypto
.createHmac("sha256", CONFIG.secretKey)
.update(paramString)
.digest("hex");
return `${CONFIG.baseUrl}?${paramString}&verifyMessage=${verifyMessage}`;
}
// Serve checkout page
app.get("/checkout/:orderId", async (req, res) => {
const order = await getOrder(req.params.orderId);
const iframeUrl = generatePaymentWithTokenUrl({
reference: `ORDER-${order.id}-${Date.now()}`,
amount: order.total.toFixed(2), // dollars, e.g. "10.00"
});
res.render("checkout", { iframeUrl });
});
// --- Step 2: Receive payment result + token via webhook ---
app.post("/webhook", express.json(), (req, res) => {
// Authenticate with the custom header configured on your notification rule
const received = Buffer.from(req.headers["x-notification-secret"] || "");
const expected = Buffer.from(process.env.NOTIFICATION_SECRET);
if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected)) {
return res.status(401).end();
}
const { responseCode, merchReference, cardToken } = req.body;
if (responseCode === "00") {
fulfillOrder(merchReference);
if (cardToken) {
// Save token for future purchases
saveTokenForCustomer(merchReference, cardToken);
}
} else {
updateOrder(merchReference, "failed");
}
res.status(200).send("OK");
});
app.listen(3000);
Tokenisation parameters
The following parameters control tokenisation behaviour on the iFrame. Pass them as URL parameters alongside your standard payment parameters.
- Tokenisation Parameters
- Payment Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
onlyTokenise | Boolean | Render card-capture page only — no payment is processed | true |
tokenControl.token | Boolean | Generate a token for the card details provided | true |
tokenControl.tokenFormat | String | Token format to use; falls back to silo default if omitted | F6L4AN |
tokenControl.tokenUsageLimit | Integer | Number of uses before token is automatically destroyed; omit for a permanent token | 4 |
tokenControl.channel | String | Free-text reference stored alongside the token — useful for tracking which system or flow created it | Cust4433221 |
metadata | Object | Custom key-value pairs for your reference | {"CRN": "12345"} |
When onlyTokenise=true, payment parameters such as txnType, merchReference, and amount are not required. Whichever parameters you send - including onlyTokenise and any tokenControl.* parameters - must all be included in the HMAC signature.
| Parameter | Type | Description | Example |
|---|---|---|---|
configId | String | Your iFrame configuration ID | '5f06c5f5-d4cb-483b-b0b2-242f48516dc5' |
userName | String | Connected Payments username with transaction permissions | 'merchant.iframes' |
txnType | Integer | Transaction type | 1 |
merchReference | String | Unique transaction reference — duplicates will be rejected | 'ORDER-12345' |
amount | String | Amount in dollars with two decimal places (e.g. 10.00 = $10.00). Do not send cents | '10.00' |
verifyMessage | String | HMAC SHA-256 signature | 'abc123...' |
cardToken | String | Pre-existing token to use for payment instead of card entry | 'tokenABC' |
Token formats
Your merchant account has a default format configured at the silo level. You can override it per-request using the tokenControl.tokenFormat parameter.
| Format | Structure | Length | Example |
|---|---|---|---|
F6L4AN | First 6 + last 4 of PAN + 6 alphanumeric | 16 | 411111m9fb0d1111 |
F6L4A | First 6 + last 4 of PAN + 6 alpha | 16 | 411111jbkzWI1111 |
F6L4F | First 6 + last 4 of PAN + 6 numeric | 16 | 4111119890761111 |
ALPHANUMERIC08 | 8 alphanumeric characters | 8 | A5fG6sn4 |
16N | 16 numeric digits | 16 | 1234567890123456 |
For the full list of token formats, see Tokenisation Specifics.
Submit Purchase API reference
When using the Submit Purchase API with a stored token, include these fields in your request body:
| Field | Type | Required | Description |
|---|---|---|---|
userName | String | Yes | Connected Payments username |
password | String | Yes | Connected Payments password |
cardToken | String | Yes | The stored token (or alias) — replaces pan and cardExpiryDate |
merchReference | String | Yes | Unique merchant reference for this transaction |
amount | String | Yes | Amount in cents |
txnType | String | Yes | Transaction type (e.g. "1" for purchase) |
requestorIp | String | No | IP address of the cardholder or originating system |
ecm | String | No | Entry class mode — use "31" for internet, "32" for internet recurring |
currency | String | No | ISO-4217 currency code (defaults to AUD) |
metadata | Object | No | Custom key-value pairs for your reference |
CVC is not required for token-based payments. The token holds a reference to the card already stored in the silo.
For full API documentation, see Submit a Purchase Request.
Environments
| Environment | Hosted URL | Embedded URL | API Base URL |
|---|---|---|---|
| Sandbox | https://sandbox.connectedpayments.commbank.com.au/es-client-frontend/hosted | https://sandbox.connectedpayments.commbank.com.au/es-client-frontend/embedded | https://sandbox.connectedpayments.commbank.com.au |
| Production | https://connectedpayments.commbank.com.au/es-client-frontend/hosted | https://connectedpayments.commbank.com.au/es-client-frontend/embedded | https://connectedpayments.commbank.com.au |
Testing
Use the sandbox environment with test cards only. Never use real card numbers in test or development environments.
Verification steps:
- Generate a token-only iFrame URL and capture a test card
- Confirm the token is returned in your webhook
- Use the token to process a payment via the iFrame or Submit Purchase API
- Verify the payment result in your webhook
For full test details, see the Testing Guide.