Skip to content

AP2 Adapter (SEPA/BACS)

What is AP2?

AP2 (Account Payment Protocol v2) is an open banking standard for bank direct debit mandates — the mechanism behind SEPA Direct Debit (EU) and BACS Direct Debit (UK). AP2 mandates authorize recurring or one-time debits from a bank account.

Current state

The AP2 adapter wraps PQSafe envelopes around AP2 mandate objects. The envelope provides the ML-DSA-65 authorization layer; the mandate provides the bank routing details.

import { AP2 } from '@pqsafe/agent-pay'
// Build an AP2 mandate reference
const mandate: AP2.MandateReference = {
mandateId: 'MANDATE-001',
creditorId: 'DE98ZZZ09999999999',
debtorIBAN: 'GB29NWBK60161331926819',
scheme: 'SEPA_CORE',
}
// Wrap with a PQSafe envelope (stub — does not dispatch in production)
const wrapped = await AP2.wrapMandate(signedEnvelope, mandate, {
sandbox: true, // AP2_SANDBOX_MODE
})
console.log(wrapped.status) // 'sandbox_accepted'

Full implementation: Sprint 4

  • SEPA Direct Debit dispatch via Airwallex’s Open Banking API
  • BACS Direct Debit via Modulr
  • Mandate registration and cancellation lifecycle
  • Webhook for debit execution confirmation

Recipe: Wrap an AP2 Mandate