Skip to main content

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

ParameterTypeRequiredDescription
merchantTransactionProviderIdstringNoTarget a specific configured provider by its internal ID.
transactionProviderTRANSACTION_PROVIDERNoSelect provider by enum. One of merchantTransactionProviderId or transactionProvider is typically required if you have multiple providers.
data.merchantCustomerPaymentMethodIdstring (CUID)YesID of the stored payment method to charge.
data.merchantInternalTransactionCodestringYesYour idempotency key for this transaction. Must be unique per charge attempt.
data.amountbigintYesAmount in the smallest currency unit (cents for USD). Use BigInt literals: 1000n = $10.00.
data.currencyCURRENCYYesISO 4217 currency code, e.g. CURRENCY.USD.
data.billingBillingDataSchemaYesBilling address and contact fields. See Billing fields.
data.merchantInternalCustomerCodestringNoDeprecated. 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

ParameterTypeRequiredDescription
merchantTransactionProviderIdstringNoTarget a specific configured provider by its internal ID.
transactionProviderTRANSACTION_PROVIDERNoSelect provider by enum.
data.merchantInternalTransactionCodestringYesYour unique idempotency key for this transaction.
data.amountbigintYesAmount in smallest currency unit.
data.currencyCURRENCYYesISO 4217 currency code.
data.billingBillingDataSchemaYesBilling address and contact fields.
data.storePaymentMethodbooleanYesWhether to save the bank account for future charges.
data.customerobjectNoCustomer selector (e.g. { merchantInternalCustomerCode: '...' }).
data.ach.accountNumberstringYesBank account number.
data.ach.routingNumberstringYesBank routing (ABA) number.
data.ach.secCode'CCD' | 'WEB' | 'TEL' | 'UNKNOWN'NoNACHA Standard Entry Class code. Defaults to provider behavior if omitted.
data.ach.entityTypeENTITY_TYPENoWhether the account holder is an individual or business.

SEC codes

CodeUse case
CCDCorporate credit or debit — business-to-business payments.
WEBInternet-initiated — consumer payments authorized online.
TELTelephone-initiated — consumer payments authorized by phone.
UNKNOWNSEC code is not known or not applicable.
note

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

ParameterTypeRequiredDescription
merchantTransactionProviderIdstringNoTarget a specific configured provider by its internal ID.
transactionProviderTRANSACTION_PROVIDERNoSelect provider by enum.
data.merchantCustomerPaymentMethodIdstring (CUID)YesID of the stored payment method to authorize.
data.merchantInternalTransactionCodestringYesYour unique idempotency key for this authorization.
data.amountbigintYesAmount to authorize in smallest currency unit.
data.currencyCURRENCYYesISO 4217 currency code.
data.billingBillingDataSchemaYesBilling 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.

note

Server sessions do not have a client token. Unlike client sessions, you cannot verify by token — only by id, merchantInternalTransactionCode, or providerCode.

Parameters

ParameterTypeRequiredDescription
idstringNoSession ID returned from start().
merchantInternalTransactionCodestringNoYour transaction code used when starting the session.
providerCodestringNoProvider-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.

FieldTypeDescription
billingFirstNamestringCardholder first name.
billingLastNamestringCardholder last name.
billingEmailstringBilling email address.
billingPhonestringBilling phone number.
billingAddressLine1stringStreet address line 1.
billingAddressLine2stringStreet address line 2.
billingAddressCitystringCity.
billingAddressStatestringState or region.
billingAddressPostalCodestringPostal code.
billingAddressCountryCOUNTRY_ISO_2ISO 3166-1 alpha-2 country code.