Server Transactions
Use these APIs when your backend initiates payments directly — no frontend or React SDK required. All calls are authenticated with your API secret and never exposed to the client.
Two patterns are covered here:
- Stored card charge — charge a card you already stored for a customer
- ACH initiation — debit a bank account directly from your server
- Server authorization — place a hold on a stored card, capture later
Stored Card Charge
transactions.payments.paymentMethod.charge()
Charges a previously stored payment method. The customer must have a stored card or bank account (merchantCustomerPaymentMethodId).
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
merchantTransactionProviderId | string | No | Target a specific configured provider by its internal ID. |
transactionProvider | TRANSACTION_PROVIDER | No | Select provider by enum. One of merchantTransactionProviderId or transactionProvider is typically required if you have multiple providers. |
data.merchantCustomerPaymentMethodId | string (CUID) | Yes | ID of the stored payment method to charge. |
data.merchantInternalTransactionCode | string | Yes | Your idempotency key for this transaction. Must be unique per charge attempt. |
data.amount | bigint | Yes | Amount in the smallest currency unit (cents for USD). Use BigInt literals: 1000n = $10.00. |
data.currency | CURRENCY | Yes | ISO 4217 currency code, e.g. CURRENCY.USD. |
data.billing | BillingDataSchema | Yes | Billing address and contact fields. See Billing fields. |
data.merchantInternalCustomerCode | string | No | Deprecated. Use data.customer instead. |
Returns: MerchantTransaction — see Transaction Operations.
Code example
import AccruPay, {
CURRENCY,
COUNTRY_ISO_2,
} from '@accrupay/node';
const sdk = new AccruPay({ apiSecret: process.env.ACCRUPAY_API_SECRET! });
const transaction = await sdk.transactions.payments.paymentMethod.charge({
merchantTransactionProviderId: process.env.ACCRUPAY_PROVIDER_ID,
data: {
merchantCustomerPaymentMethodId: 'cm1abc123def456ghi789jkl',
merchantInternalTransactionCode: 'order-9876-charge',
amount: 4999n, // $49.99
currency: CURRENCY.USD,
billing: {
billingFirstName: 'Jane',
billingLastName: 'Smith',
billingEmail: 'jane@example.com',
billingAddressCountry: COUNTRY_ISO_2.US,
},
},
});
console.log(transaction.id, transaction.status);
ACH Initiation
transactions.payments.ach.initiate()
Initiates a bank account debit from your server. The customer provides their account and routing numbers. ACH transactions are asynchronous — the returned status is typically PENDING and transitions to SUCCEEDED or FAILED after bank settlement.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
merchantTransactionProviderId | string | No | Target a specific configured provider by its internal ID. |
transactionProvider | TRANSACTION_PROVIDER | No | Select provider by enum. |
data.merchantInternalTransactionCode | string | Yes | Your unique idempotency key for this transaction. |
data.amount | bigint | Yes | Amount in smallest currency unit. |
data.currency | CURRENCY | Yes | ISO 4217 currency code. |
data.billing | BillingDataSchema | Yes | Billing address and contact fields. |
data.storePaymentMethod | boolean | Yes | Whether to save the bank account for future charges. |
data.customer | object | No | Customer selector (e.g. { merchantInternalCustomerCode: '...' }). |
data.ach.accountNumber | string | Yes | Bank account number. |
data.ach.routingNumber | string | Yes | Bank routing (ABA) number. |
data.ach.secCode | 'CCD' | 'WEB' | 'TEL' | 'UNKNOWN' | No | NACHA Standard Entry Class code. Defaults to provider behavior if omitted. |
data.ach.entityType | ENTITY_TYPE | No | Whether the account holder is an individual or business. |
SEC codes
| Code | Use case |
|---|---|
CCD | Corporate credit or debit — business-to-business payments. |
WEB | Internet-initiated — consumer payments authorized online. |
TEL | Telephone-initiated — consumer payments authorized by phone. |
UNKNOWN | SEC code is not known or not applicable. |
ACH transactions settle asynchronously through the banking network. The response status is typically PENDING at the time of return. Use webhooks or transactions.syncOne() to detect final settlement.
Returns: MerchantTransaction — see Transaction Operations.
Code example
import AccruPay, {
CURRENCY,
COUNTRY_ISO_2,
ENTITY_TYPE,
} from '@accrupay/node';
const sdk = new AccruPay({ apiSecret: process.env.ACCRUPAY_API_SECRET! });
const transaction = await sdk.transactions.payments.ach.initiate({
merchantTransactionProviderId: process.env.ACCRUPAY_PROVIDER_ID,
data: {
merchantInternalTransactionCode: 'ach-order-1234',
amount: 25000n, // $250.00
currency: CURRENCY.USD,
storePaymentMethod: true,
customer: {
merchantInternalCustomerCode: 'customer-abc',
},
billing: {
billingFirstName: 'John',
billingLastName: 'Doe',
billingEmail: 'john@example.com',
billingAddressCountry: COUNTRY_ISO_2.US,
},
ach: {
accountNumber: '1234567890',
routingNumber: '021000021',
secCode: 'WEB',
entityType: ENTITY_TYPE.INDIVIDUAL,
},
},
});
// status is likely PENDING — poll or use webhooks
console.log(transaction.id, transaction.status);
Server Authorization
A server authorization places a hold on a stored payment method without capturing funds. Use this when you need to confirm availability now and capture later (e.g. after fulfillment).
serverSessions.authorizations.paymentMethod.start()
Starts an authorization hold on a stored payment method.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
merchantTransactionProviderId | string | No | Target a specific configured provider by its internal ID. |
transactionProvider | TRANSACTION_PROVIDER | No | Select provider by enum. |
data.merchantCustomerPaymentMethodId | string (CUID) | Yes | ID of the stored payment method to authorize. |
data.merchantInternalTransactionCode | string | Yes | Your unique idempotency key for this authorization. |
data.amount | bigint | Yes | Amount to authorize in smallest currency unit. |
data.currency | CURRENCY | Yes | ISO 4217 currency code. |
data.billing | BillingDataSchema | Yes | Billing address and contact fields. |
Returns: Session context object containing customer, paymentMethod, session, transactionProvider, and transactions.
serverSessions.authorizations.paymentMethod.verify()
Retrieves the current state of a server authorization session.
Server sessions do not have a client token. Unlike client sessions, you cannot verify by token — only by id, merchantInternalTransactionCode, or providerCode.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | No | Session ID returned from start(). |
merchantInternalTransactionCode | string | No | Your transaction code used when starting the session. |
providerCode | string | No | Provider-assigned session identifier. |
At least one identifier must be provided. Returns: Session context object (same shape as start()).
Code example
import AccruPay, {
CURRENCY,
COUNTRY_ISO_2,
} from '@accrupay/node';
const sdk = new AccruPay({ apiSecret: process.env.ACCRUPAY_API_SECRET! });
// 1. Place the hold
const authSession = await sdk.serverSessions.authorizations.paymentMethod.start({
merchantTransactionProviderId: process.env.ACCRUPAY_PROVIDER_ID,
data: {
merchantCustomerPaymentMethodId: 'cm1abc123def456ghi789jkl',
merchantInternalTransactionCode: 'order-5555-auth',
amount: 10000n, // $100.00
currency: CURRENCY.USD,
billing: {
billingFirstName: 'Jane',
billingLastName: 'Smith',
billingEmail: 'jane@example.com',
billingAddressCountry: COUNTRY_ISO_2.US,
},
},
});
console.log(authSession.session.id, authSession.transactions);
// 2. Later — verify the authorization state
const verified = await sdk.serverSessions.authorizations.paymentMethod.verify({
merchantInternalTransactionCode: 'order-5555-auth',
});
// 3. Capture or void — see Transaction Operations
To capture or void after authorization, use transactions.authorizations.settle() and transactions.authorizations.void() — documented in Transaction Operations.
Billing fields
BillingDataSchema — all fields are optional unless your provider requires them.
| Field | Type | Description |
|---|---|---|
billingFirstName | string | Cardholder first name. |
billingLastName | string | Cardholder last name. |
billingEmail | string | Billing email address. |
billingPhone | string | Billing phone number. |
billingAddressLine1 | string | Street address line 1. |
billingAddressLine2 | string | Street address line 2. |
billingAddressCity | string | City. |
billingAddressState | string | State or region. |
billingAddressPostalCode | string | Postal code. |
billingAddressCountry | COUNTRY_ISO_2 | ISO 3166-1 alpha-2 country code. |