Skip to content
ShaBaas Pay / Docs
Technical Guides

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.

EnvironmentBase URLPurpose
Sandboxhttps://dev-api.shabaas.comTesting, QA, and sandbox agreement/payment simulation
Productionhttps://api.shabaas.comLive merchant traffic (requires onboarding and KYC/KYB approval)
  • PayTo & Refund APIs (/api/public/*): Exchange your merchant API key for a 24-hour Bearer token via POST /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 the Authorization header.
POST/api/public/authorization
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)
    end
Sequence diagram of the Variable PayTo integration flow: Backend authenticates via POST /api/public/authorization, creates a VARI/ADHO agreement with maximum_amount 300.00, waits for customer approval via webhook or GET status, then either collects with last_payment true, amends bilaterally if the total exceeds 300.00, or cancels an unused agreement.

Step 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.

POST/api/public/payment_agreement
{
  "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/api/public/payment_initiation
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

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)
Sequence diagram for disposable Business PayID collection: Merchant backend calls POST /api/v1/collections/payid with amount 85.00, displays the returned PayID alias to the customer, customer pays via NPP, and backend verifies receipt via GET /api/v1/collections/payid/status before fulfilling the order.

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/api/v1/collections/payid
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/api/v1/collections/payid/status
GET https://dev-api.shabaas.com/api/v1/collections/payid/status?payid=ENCODED_ALIAS&expected_amount=85.00
Authorization: REPLACE_WITH_MERCHANT_API_KEY

4. 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.

POST/api/public/payment_initiation (Split Settlement)
{
  "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"
  }
}
FieldTypeDescription
payment_initiation.amountstring / numberTotal payment amount (e.g. "100.00").
payment_initiation.last_paymentbooleanSet true to auto-close a single-use agreement on collection.
payment_initiation.split_percentage_feenumber / stringPercentage retained in the business ledger (e.g. 20 retains $20.00 and pays out $80.00 before fees).
payment_initiation.notesstringOptional transaction note (max 140 chars).
destination.bsbstring6-digit BSB of the approved destination bank account (1 destination account per request).
destination.account_numberstringAccount 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–128 characters matching ^[A-Za-z0-9._:-]{16,128}$.
  • Persistence: Store the key alongside the exact request payload and merchant_reference before sending.
ScenarioOrder IDIdempotency-KeyAmountOutcome
First orderOrder 1042order-1042-pay-01"20.00"New payment created (200 OK)
Second independent orderOrder 1043order-1043-pay-01"20.00"Separate new payment created (200 OK)
Network timeout retryOrder 1042order-1042-pay-01"20.00"Safely deduplicated; returns original outcome

Idempotency Handling Matrix

ConditionRequired Action
New independent paymentGenerate a fresh unique Idempotency-Key (16–128 chars) and merchant_reference.
Network timeoutRetry 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 paymentGenerate a new Idempotency-Key if retrying after resolving the underlying failure.
HTTP 409 ConflictThe 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)
    end
Sequence diagram for full and partial refunds: Merchant backend confirms status acsc and settled true via webhook or status API, sends POST /api/public/payment_initiation/refund with a required unique Idempotency-Key header, and reconciles Ok, Pending, or Failed outcomes via GET /api/public/payment_initiation.

Idempotency-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/api/public/payment_initiation/refund
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 StatusMeaningReconciliation Action
OkRefund paid (status: "return_complete")Mark refunded amount in your ledger.
PendingRefund accepted and processing (status: "return_in_progress")Reconcile via GET /api/public/payment_initiation?id=PAYMENT_ID or refund webhook.
FailedScheme or validation rejectionInspect 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 CategoryPurpose
Payment agreementAgreement approval, pause, amendment, or cancellation updates
Payment initiationPayment acceptance (accp), clearing (acsc), rejection (rjct), and ledger settlement (settled: true)
Business PayIDInbound NPP payment receipt for a disposable PayID
RefundRefund completion or failure updates
PayoutOutbound ledger-to-bank settlement status updates
JSONWebhook Payload — Payment Initiation Settled
{
  "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_key in the Authorization header on every incoming webhook.
  • Deduplicate repeated webhook deliveries and handle out-of-order events idempotently.
  • Reconcile uncertain states (202, R805, or Pending refunds) via GET /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_key secrets out of client apps, logs, and support tickets.

8. Sandbox Integration Readiness Checklist

  1. Create and authorise a Variable PayTo (VARI/ADHO) agreement in sandbox.
  2. Collect a final amount below the maximum with last_payment: true.
  3. Verify automatic agreement closure after successful collection.
  4. Test bilateral agreement amendment (PATCH /api/public/payment_agreement/bilateral) and customer re-authorisation when total exceeds max.
  5. Cancel an unused PayTo agreement before collection (DELETE /api/public/payment_agreement/cancel).
  6. Generate a disposable Business PayID (POST /api/v1/collections/payid) and verify exact-amount receipt (GET /api/v1/collections/payid/status).
  7. Process two independent payments with identical dollar amounts ($20.00) using distinct Idempotency-Key values.
  8. Simulate a network timeout retry with the same Idempotency-Key and confirm deduplication.
  9. Validate split settlement (split_percentage_fee + destination) against an approved destination account.
  10. Wait for status: "acsc" and settled: true, then process both a partial refund and a full remainder refund.
  11. Verify webhook Authorization header validation, deduplication, and status API reconciliation.
  12. 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:

PROMPTAI Coding Assistant Integration Prompt
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

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.

← Back to API Reference