Integrating Variable and Multiple Payments
ShaBaas Pay exposes REST endpoints on Australia's New Payments Platform (NPP) for single-order Variable PayTo (VARI/ADHO) agreements, disposable Business PayID collections, transaction-level split settlement, idempotent multi-order initiation, and full or partial refunds up to AUD $1,000 per transaction.
For Product & Finance Teams: Looking for a non-technical overview of payment flows, settlement models, fees, and limits? Read Managing Variable and Multiple Payments (Business Overview).
1. Environments & Authentication
All credentials, merchant API keys, and Bearer tokens must be stored and used exclusively on your backend server—never expose them in browser or mobile clients.
| Environment | Base URL | Purpose |
|---|---|---|
| Sandbox | https://dev-api.shabaas.com | Testing, QA, and sandbox agreement/payment simulation |
| Production | https://api.shabaas.com | Live merchant traffic (requires onboarding and KYC/KYB approval) |
- PayTo & Refund APIs (
/api/public/*): Exchange your merchant API key for a 24-hour Bearer token viaPOST /api/public/authorization. Your merchant API key remains valid until revoked or rotated. - Business PayID APIs (
/api/v1/collections/payid*): Pass your merchant API key directly in theAuthorizationheader.
POST https://dev-api.shabaas.com/api/public/authorization
Content-Type: application/json
{
"api_key": "REPLACE_WITH_MERCHANT_API_KEY"
}2. Variable PayTo Integration Workflow
Use single-use Variable PayTo when the final order total is unknown at checkout (for example, open orders or hospitality tabs) and may be finalised at or below an authorised ceiling.
sequenceDiagram
participant App as Merchant Backend
participant API as ShaBaas Pay API
participant Bank as Customer Banking App
App->>API: POST /api/public/authorization<br/>(API Key)
API-->>App: 200 OK (24h Bearer Token)
App->>API: POST /api/public/payment_agreement<br/>(VARI, ADHO, max 300.00, count 1)
API-->>Bank: Present PayTo agreement<br/>for approval
Bank-->>API: Customer authorises agreement
API-->>App: Webhook: payment_agreement active
alt Final total <= 300.00 (e.g. 145.00)
App->>API: POST /api/public/payment_initiation<br/>(Idempotency-Key, last_payment: true)
API-->>App: 200 OK (acsc -> settled: true)
else Final total > 300.00 (e.g. 350.00)
App->>API: PATCH /api/public/payment_agreement/bilateral
Bank-->>API: Customer re-authorises<br/>amended limit
App->>API: POST /api/public/payment_initiation<br/>(Idempotency-Key, last_payment: true)
else Order cancelled before collection
App->>API: DELETE /api/public/payment_agreement/cancel<br/>(?id=AGREEMENT_ID)
endStep 1 — Create Variable PayTo Agreement
Call POST /api/public/payment_agreement with agreement_type: "VARI", frequency: "ADHO", and number_of_transactions_permitted: 1. Confirm agreement authorisation via the payment_agreement webhook or GET /api/public/payment_agreement before initiating payment.
{
"payment_agreement": {
"name": "Example Customer",
"type": "email",
"pay_id": "sample@shabaas.com",
"agreement_type": "VARI",
"maximum_amount": "300.00",
"frequency": "ADHO",
"number_of_transactions_permitted": 1
}
}Step 2 — Finalise & Collect Payment
Once the final order amount is known, call POST /api/public/payment_initiation with a unique Idempotency-Key header and last_payment: true so the single-use agreement closes automatically upon successful collection (no separate cancellation call required). Note that amount accepts a decimal string such as "145.00" (recommended for precision) or a number.
POST https://dev-api.shabaas.com/api/public/payment_initiation
Authorization: Bearer REPLACE_WITH_BEARER_TOKEN
Idempotency-Key: order-1042-final-capture-01
Content-Type: application/json
{
"payment_initiation": {
"payment_agreement_id": "3652PA20260408123221550",
"amount": "145.00",
"merchant_reference": "order-1042",
"last_payment": true,
"notes": "Order 1042 final total"
}
}Step 3 — Confirm Completion
Combine payment_initiation webhooks with GET /api/public/payment_initiation?id=PAYMENT_ID to confirm terminal status. Remember: an authorised PayTo maximum does not reserve customer funds and does not guarantee debit success.
Amendments & Cancellations
- Final total at or below max (e.g.
$300 → $50): Initiate collection directly for"50.00"; no amendment needed. - Final total exceeds max (e.g.
$300 → $350): CallPATCH /api/public/payment_agreement/bilateraland wait for customer re-authorisation before collecting. - Order cancelled before collection: Call
DELETE /api/public/payment_agreement/cancel?id=AGREEMENT_IDto close the unused agreement.
3. Business PayID Integration Workflow
For fixed-price orders where no PayTo agreement is required, generate a disposable, amount-specific Business PayID. See B2B PayID Collections, POST /api/v1/collections/payid, and GET /api/v1/collections/payid/status.
sequenceDiagram
participant App as Merchant Backend
participant API as ShaBaas Pay API
participant Customer as Customer Banking App
App->>API: POST /api/v1/collections/payid<br/>(API Key, amount: 85.00)
API-->>App: 200 OK (PayID alias + expiry)
App-->>App: Persist PayID alias &<br/>expiry against order ID
App-->>Customer: Display PayID alias &<br/>exact amount ($85.00)
Customer->>API: Pay exact $85.00 to PayID via NPP
API-->>App: Webhook: PayID received<br/>(PayID retires)
App->>API: GET /api/v1/collections/payid/status<br/>(?payid=ALIAS&expected_amount=85.00)
API-->>App: 200 OK (Verified paid & exact amount)Step 1 — Generate Disposable Business PayID
Pass your Merchant API Key directly in the Authorization header. Persist the returned PayID alias and expiry against your internal order ID.
POST https://dev-api.shabaas.com/api/v1/collections/payid
Authorization: REPLACE_WITH_MERCHANT_API_KEY
Content-Type: application/json
{
"amount": 85.00
}Step 2 — Verify Payment Receipt
Before fulfilling the order, verify the payment status and exact received amount using GET /api/v1/collections/payid/status. The disposable PayID automatically retires upon exact receipt.
GET https://dev-api.shabaas.com/api/v1/collections/payid/status?payid=ENCODED_ALIAS&expected_amount=85.00
Authorization: REPLACE_WITH_MERCHANT_API_KEY4. Split Settlement (Bookkeeper API)
To split a collected PayTo payment between an approved destination bank account and your business ledger at the transaction level, use the Bookkeeper API parameters on POST /api/public/payment_initiation.
{
"payment_initiation": {
"payment_agreement_id": "3652PA20260408123221550",
"amount": "100.00",
"last_payment": true,
"split_percentage_fee": 20,
"notes": "Order 1045 split settlement"
},
"destination": {
"bsb": "123456",
"account_number": "12345678"
}
}| Field | Type | Description |
|---|---|---|
payment_initiation.amount | string / number | Total payment amount (e.g. "100.00"). |
payment_initiation.last_payment | boolean | Set true to auto-close a single-use agreement on collection. |
payment_initiation.split_percentage_fee | number / string | Percentage retained in the business ledger (e.g. 20 retains $20.00 and pays out $80.00 before fees). |
payment_initiation.notes | string | Optional transaction note (max 140 chars). |
destination.bsb | string | 6-digit BSB of the approved destination bank account (1 destination account per request). |
destination.account_number | string | Account number of the approved destination bank account. |
Settlement schedules, minimum retained ledger balances, and approved destination accounts are configured by ShaBaas Pay support.
5. Multiple Independent Payments, Idempotency & Limits
Every POST /api/public/payment_initiation and POST /api/public/payment_initiation/refund request should carry a client-generated Idempotency-Key header:
- Format:
16–128characters matching^[A-Za-z0-9._:-]{16,128}$. - Persistence: Store the key alongside the exact request payload and
merchant_referencebefore sending.
| Scenario | Order ID | Idempotency-Key | Amount | Outcome |
|---|---|---|---|---|
| First order | Order 1042 | order-1042-pay-01 | "20.00" | New payment created (200 OK) |
| Second independent order | Order 1043 | order-1043-pay-01 | "20.00" | Separate new payment created (200 OK) |
| Network timeout retry | Order 1042 | order-1042-pay-01 | "20.00" | Safely deduplicated; returns original outcome |
Idempotency Handling Matrix
| Condition | Required Action |
|---|---|
| New independent payment | Generate a fresh unique Idempotency-Key (16–128 chars) and merchant_reference. |
| Network timeout | Retry with the exact same Idempotency-Key and identical JSON body. |
Uncertain outcome (202 / R805) | Poll GET /api/public/payment_initiation?id=PAYMENT_ID or wait Retry-After (5s) and resend the same key and body. |
| Confirmed failed payment | Generate a new Idempotency-Key if retrying after resolving the underlying failure. |
HTTP 409 Conflict | The key was already used with a different request body; inspect your stored record and use a new key for a new payment. |
Transaction Limit Enforcement: Enforce the AUD $1,000 platform cap (or your lower approved account limit) on single PayTo/PayID payments and PayTo agreement maximum_amount. Idempotency keys are strictly for duplicate prevention on retries. For higher transaction amounts exceeding the AUD $1,000 PayTo/PayID limit, use ShaBaas Pay's card payment rails powered by eWAY, a Global Payments company (see Get Checkout Link, Get Pay Link, and Get External Checkout URL).
6. Full and Partial Refunds
Before initiating a refund via POST /api/public/payment_initiation/refund, verify that the payment has reached status: "acsc" AND settled: true via webhook or GET /api/public/payment_initiation. Never use fixed wait timers.
sequenceDiagram
participant App as Merchant Backend
participant API as ShaBaas Pay API
API-->>App: Webhook: status "acsc", settled: true
App->>API: POST /api/public/payment_initiation/refund<br/>(Required Idempotency-Key)
alt Immediate completion
API-->>App: 200 OK (refund.status: "Ok",<br/>status: "return_complete")
else In progress
API-->>App: 200 OK (refund.status: "Pending",<br/>status: "return_in_progress")
App->>API: GET /api/public/payment_initiation<br/>(?id=PAYMENT_ID)
API-->>App: Reconciled terminal refund status
else Rejected
API-->>App: 422 / Failed<br/>(retry only with new Idempotency-Key)
endIdempotency-Key is required on POST /api/public/payment_initiation/refund. Repeating the same key on the same payment returns the original refund without paying twice; a second partial refund requires a new Idempotency-Key.
POST https://dev-api.shabaas.com/api/public/payment_initiation/refund
Authorization: Bearer REPLACE_WITH_BEARER_TOKEN
Idempotency-Key: refund-order-1042-part-01
Content-Type: application/json
{
"payment_initiation": {
"payment_initiation_id": "12345PI1714316400",
"amount": "15.00",
"notes": "Partial refund for unavailable item"
}
}| Refund Status | Meaning | Reconciliation Action |
|---|---|---|
Ok | Refund paid (status: "return_complete") | Mark refunded amount in your ledger. |
Pending | Refund accepted and processing (status: "return_in_progress") | Reconcile via GET /api/public/payment_initiation?id=PAYMENT_ID or refund webhook. |
Failed | Scheme or validation rejection | Inspect failure_code/message; retry only with a new Idempotency-Key. |
7. Webhooks & Reconciliation
Configure HTTPS webhook receivers in both sandbox and production. See Webhook Notification Management for full event schemas and POST /api/public/webhooks for registration.
| Notification Category | Purpose |
|---|---|
| Payment agreement | Agreement approval, pause, amendment, or cancellation updates |
| Payment initiation | Payment acceptance (accp), clearing (acsc), rejection (rjct), and ledger settlement (settled: true) |
| Business PayID | Inbound NPP payment receipt for a disposable PayID |
| Refund | Refund completion or failure updates |
| Payout | Outbound ledger-to-bank settlement status updates |
{
"payment_initiation_id": "12345PI1714316400",
"status": "acsc",
"settled": true,
"transfer": "transfer_not_started",
"created_at": "2026-04-28T13:45:00.000Z"
}status: "acsc": Funds have cleared from the customer's bank (collection complete).settled: true: Funds have settled into your ShaBaas Pay business ledger (now eligible for refund).transfer: "transfer_not_started": Onward payout from the business ledger to your nominated bank account has not yet started (separate step).
Webhook Best Practices Checklist
- Validate the registered
auth_keyin theAuthorizationheader on every incoming webhook. - Deduplicate repeated webhook deliveries and handle out-of-order events idempotently.
- Reconcile uncertain states (
202,R805, orPendingrefunds) viaGET /api/public/payment_initiation?id=PAYMENT_ID. - Confirm exact refund callback payload fields in sandbox during integration.
- Keep API keys, Bearer tokens, and webhook
auth_keysecrets out of client apps, logs, and support tickets.
8. Sandbox Integration Readiness Checklist
- Create and authorise a Variable PayTo (
VARI/ADHO) agreement in sandbox. - Collect a final amount below the maximum with
last_payment: true. - Verify automatic agreement closure after successful collection.
- Test bilateral agreement amendment (
PATCH /api/public/payment_agreement/bilateral) and customer re-authorisation when total exceeds max. - Cancel an unused PayTo agreement before collection (
DELETE /api/public/payment_agreement/cancel). - Generate a disposable Business PayID (
POST /api/v1/collections/payid) and verify exact-amount receipt (GET /api/v1/collections/payid/status). - Process two independent payments with identical dollar amounts (
$20.00) using distinctIdempotency-Keyvalues. - Simulate a network timeout retry with the same
Idempotency-Keyand confirm deduplication. - Validate split settlement (
split_percentage_fee+destination) against an approved destination account. - Wait for
status: "acsc"andsettled: true, then process both a partial refund and a full remainder refund. - Verify webhook
Authorizationheader validation, deduplication, and status API reconciliation. - Validate enforcement of the AUD $1,000 transaction limit and graceful handling of declined/failed payments.
9. Build with an AI Coding Assistant
Copy this complete prompt into your AI coding assistant to scaffold a production-safe ShaBaas Pay integration:
Implement ShaBaas Pay single-order Variable PayTo, disposable Business PayID, split settlement, idempotent multi-order initiation, refunds, and webhook reconciliation in my backend application.
1. Environments & Auth:
- Sandbox base URL: https://dev-api.shabaas.com | Production base URL: https://api.shabaas.com
- Store SHABAAS_API_KEY and webhook auth_key in server-side environment variables only.
- For PayTo and Refund endpoints (/api/public/*), exchange SHABAAS_API_KEY at POST /api/public/authorization for a 24-hour Bearer token and cache/refresh it before expiry.
- For Business PayID endpoints (/api/v1/collections/payid*), pass SHABAAS_API_KEY directly in the Authorization header.
2. Variable PayTo Flow:
- Create single-use agreements via POST /api/public/payment_agreement with agreement_type: "VARI", frequency: "ADHO", number_of_transactions_permitted: 1, and maximum_amount (<= 1000.00 AUD).
- Wait for active status via payment_agreement webhook or GET /api/public/payment_agreement.
- Collect final amount via POST /api/public/payment_initiation with last_payment: true and a persistent Idempotency-Key.
- If final amount > maximum_amount, call PATCH /api/public/payment_agreement/bilateral and wait for re-authorisation.
- If cancelled before collection, call DELETE /api/public/payment_agreement/cancel?id=AGREEMENT_ID.
3. Business PayID Flow:
- Call POST /api/v1/collections/payid with {"amount": 85.00} and persist the returned PayID alias and expiry against the internal order ID.
- Verify receipt via GET /api/v1/collections/payid/status?payid=ENCODED_ALIAS&expected_amount=85.00 before fulfilling.
4. Split Settlement (Bookkeeper API):
- Support optional split_percentage_fee and destination {bsb, account_number} on POST /api/public/payment_initiation.
5. Idempotency & Limits:
- Enforce AUD $1,000 single-transaction/agreement limit for PayTo and Business PayID.
- Generate 16-128 char Idempotency-Key values (A-Z, a-z, 0-9, . _ : -) per independent payment/refund attempt, persist key + body before sending, reuse on timeout/202, and never reuse across different orders.
- For higher transaction amounts above the AUD $1,000 limit, route the payment through ShaBaas Pay's card payment rails powered by eWAY, a Global Payments company (using the documented Checkout / Card APIs: /api/post_api-get-url, /api/post_api-get-business-pay-link, /api/post_api-get-external-url) instead of splitting PayTo or PayID requests.
6. Refunds:
- Only refund after confirming status == "acsc" and settled == true (never fixed sleep timers).
- Call POST /api/public/payment_initiation/refund with a required unique Idempotency-Key header, payment_initiation_id, amount (string), and notes. Reconcile Pending refunds via GET /api/public/payment_initiation?id=PAYMENT_ID.
7. Webhooks & Reconciliation:
- Validate the Authorization header against the environment's registered auth_key, deduplicate repeated events, handle out-of-order delivery, and reconcile uncertain states via GET status endpoints.
8. Deliverables:
- Provide database schema/migrations for agreements, orders, idempotency keys, and webhook events, service modules, webhook handler, and unit/integration tests with mocked HTTP responses.10. Developer Resources & Related Guides
| Resource | Link |
|---|---|
| Business Overview | Managing Variable and Multiple Payments |
| Quickstart | Your first sandbox payment |
| Auth Token | Generate Bearer Token (POST /api/public/authorization) |
| Payment Agreements | Create · Show · Bilateral Amend · Cancel |
| Payment Initiation & Refunds | Initiate Payment · Show Status · Status Values · Refund Payment |
| Business PayID & Split Settlement | B2B PayID Collections · Create PayID · PayID Status · Bookkeeper API |
| Card & Hosted Checkout (eWAY) | Get Checkout Link · Get Pay Link · Get External Checkout URL |
| Webhooks | Webhook Notification Management · Register Webhook · Get Webhook |
| Error Codes & Rules | General Error Codes · Agreement Error Codes · Payment Error Codes · PayTo Frequency · Sandbox Agreements |
11. Frequently Asked Questions
Is Idempotency-Key required for POST /api/public/payment_initiation/refund?
Yes. POST /api/public/payment_initiation/refund requires a client-generated Idempotency-Key header (for example, a UUID). Sending the same key again returns the original refund without paying twice, while a second partial refund or retry after failure requires a new key.
When is a payment eligible for a refund?
A payment is eligible for a full or partial refund only after it reaches status: "acsc" and settled: true. A payment with acsc and settled: false has not yet settled into the business ledger and cannot be refunded.
How should amount be formatted in POST /api/public/payment_initiation?
The OpenAPI schema accepts both string and number, but formatting amount as a two-decimal string (such as "145.00") is recommended for exact currency precision.
What is the difference between PayTo auth and Business PayID auth?
PayTo endpoints (/api/public/*) require exchanging your merchant API key at POST /api/public/authorization for a 24-hour Bearer token, whereas Business PayID endpoints (/api/v1/collections/payid*) accept your merchant API key directly in the Authorization header.