const customer = await atoa.customer.create({
fullName: "Ada Lovelace",
email: "[email protected]", // email or phone required
});
const contract = await atoa.contract.create({
type: "COLLECT",
name: "Monthly membership",
atoaCustomerId: customer.id,
limits: {
maxPerPayment: 50.00,
periodLimits: [{ amount: 100.00, period: "MONTH" }],
validTo: "2026-12-31T23:59:59Z",
},
});
console.log(contract.authorizationUrl); // customer links a method + approves the caps here
await atoa.contract.awaitActive(contract.contractId); // → ACTIVE
const charge = await atoa.payment.collect({
contractId: contract.contractId,
atoaCustomerId: customer.id,
amount: { amount: 20.00 },
orderId: "membership-jan",
});
// charge.nextAction — the customer approves before it settles (next section)