Skip to main content

Payment Methods

Payment methods represent stored cards or bank accounts for a customer. They are created during checkout (when storePaymentMethod: true) or via add-payment-method sessions.

note

getOne() only accepts merchantCustomerPaymentMethodId. Unlike transaction queries, there are no alternative identifiers (no providerCode, no internal code shorthand).


paymentMethods.getMany()

Returns a paginated list of stored payment methods matching the provided filters.

Filter parameters

ParameterTypeDescription
idstringFilter by AccruPay payment method ID.
transactionProviderTRANSACTION_PROVIDERFilter by provider enum.
transactionProviderIdstringFilter by provider configuration ID.
providerCodestringFilter by provider-assigned payment method code.
methodTypePAYMENT_METHODFilter by method type (e.g. PAYMENT_METHOD.CREDIT_CARD, PAYMENT_METHOD.ACH).
initialTransactionIdstringFilter by the transaction that created this payment method.
customerIdstringFilter by AccruPay customer ID.
merchantInternalCustomerCodestringFilter by your customer identifier.
isDefaultbooleanFilter for default payment methods.
hasProviderErrorbooleanFilter for methods with or without provider sync errors.
skipnumberOffset pagination: number of records to skip.
takenumberOffset pagination: number of records to return.
afterstringCursor pagination: return records after this cursor.
firstnumberCursor pagination: number of records after cursor.
beforestringCursor pagination: return records before this cursor.
lastnumberCursor pagination: number of records before cursor.
sortingobjectSort configuration object.
import AccruPay, { PAYMENT_METHOD } from '@accrupay/node';

const sdk = new AccruPay({ apiSecret: process.env.ACCRUPAY_API_SECRET! });

const { data } = await sdk.paymentMethods.getMany({
merchantInternalCustomerCode: 'customer-abc',
methodType: PAYMENT_METHOD.CREDIT_CARD,
isDefault: true,
take: 10,
});

paymentMethods.getOne()

Returns a single payment method by its AccruPay ID.

note

getOne() only accepts merchantCustomerPaymentMethodId. There is no option to look up by providerCode or any other identifier — unlike transactions.getOne() which accepts multiple options.

ParameterTypeRequiredDescription
merchantCustomerPaymentMethodIdstring (CUID)YesAccruPay payment method ID.
const method = await sdk.paymentMethods.getOne({
merchantCustomerPaymentMethodId: 'cm1abc123def456ghi789jkl',
});

console.log(method.methodType, method.status);

Returns: MerchantCustomerPaymentMethod


paymentMethods.syncOne()

Pulls the latest state from the provider and updates the payment method record. All three parameters are required.

ParameterTypeRequiredDescription
merchantTransactionProviderIdstringYesProvider configuration ID (routes the sync request to the correct provider).
providerCodestringYesProvider-assigned payment method identifier.
customerMerchantCustomerSelectorNoCustomer selector, e.g. { merchantInternalCustomerCode: 'customer-abc' }.
const synced = await sdk.paymentMethods.syncOne({
merchantTransactionProviderId: process.env.ACCRUPAY_PROVIDER_ID!,
providerCode: 'provider-pm-code-xyz',
customer: {
merchantInternalCustomerCode: 'customer-abc',
},
});

console.log(synced.status, synced.providerLastSyncedAt);

Returns: MerchantCustomerPaymentMethod


Payment method return shape

All payment method methods return a MerchantCustomerPaymentMethod object.

Core fields

FieldTypeDescription
idstringAccruPay payment method ID.
customerIdstringAccruPay customer ID this method belongs to.
initialTransactionIdstring | nullID of the transaction that created this payment method.
isDefaultbooleanWhether this is the customer's default payment method.
isEnabledbooleanWhether this payment method is active and chargeable.
expiresAtDateTimeISO | nullExpiration date (for cards).
statusstringCurrent status of the payment method.
merchantInternalCustomerCodestring | nullYour customer identifier.
methodTypePAYMENT_METHODType of payment method (CREDIT_CARD, ACH, GENERIC, etc.).
providerCodestringProvider-assigned payment method identifier.
providerCustomerCodestring | nullProvider-assigned customer identifier associated with this method.
providerErrorobject | nullProvider error detail from the last sync attempt.
providerLastSyncedAtDateTimeISO | nullWhen the payment method was last synced with the provider.
providerLastVerifiedAtDateTimeISO | nullWhen the payment method was last verified as chargeable.
providerStatusstring | nullRaw status string from the provider.
transactionProviderIdstringProvider configuration ID associated with this method.
billing*stringBilling address fields stored with this payment method.
createdAtDateTimeISOWhen the payment method was created.
updatedAtDateTimeISOWhen the payment method was last updated.

paymentMethodInfo union

The paymentMethodInfo field contains method-specific details. Its shape depends on methodType.

Credit card — MerchantCustomerPaymentMethodCreditCardInfo

FieldTypeDescription
methodTypePAYMENT_METHODAlways PAYMENT_METHOD.CREDIT_CARD.
cardBrandstringCard network (e.g. VISA, MASTERCARD, AMEX).
cardNumberMaskedstringMasked card number (e.g. ************4242).
expirationMonthnumberExpiration month (1–12).
expirationYearnumberFour-digit expiration year.

ACH — MerchantCustomerPaymentMethodAchInfo

FieldTypeDescription
methodTypePAYMENT_METHODAlways PAYMENT_METHOD.ACH.
accountNumberstringBank account number (may be masked).
bankNamestring | nullBank name, if resolved by the provider.
routingNumberstringBank routing (ABA) number.
secCodestring | nullNACHA Standard Entry Class code (CCD, WEB, TEL, etc.).

Generic — MerchantCustomerPaymentMethodGenericInfo

FieldTypeDescription
methodTypePAYMENT_METHODThe specific method type for this generic entry.

Used for provider-specific payment methods that don't map to card or ACH (e.g. digital wallets, provider-native methods).

Discriminating the union

const method = await sdk.paymentMethods.getOne({
merchantCustomerPaymentMethodId: 'cm1abc123def456ghi789jkl',
});

const info = method.paymentMethodInfo;

if (info.methodType === PAYMENT_METHOD.CREDIT_CARD) {
// info is MerchantCustomerPaymentMethodCreditCardInfo
console.log(info.cardBrand, info.cardNumberMasked);
console.log(`Expires: ${info.expirationMonth}/${info.expirationYear}`);
} else if (info.methodType === PAYMENT_METHOD.ACH) {
// info is MerchantCustomerPaymentMethodAchInfo
console.log(info.accountNumber, info.routingNumber, info.bankName);
} else {
// info is MerchantCustomerPaymentMethodGenericInfo
console.log(info.methodType);
}