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.
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
| Parameter | Type | Description |
|---|---|---|
id | string | Filter by AccruPay payment method ID. |
transactionProvider | TRANSACTION_PROVIDER | Filter by provider enum. |
transactionProviderId | string | Filter by provider configuration ID. |
providerCode | string | Filter by provider-assigned payment method code. |
methodType | PAYMENT_METHOD | Filter by method type (e.g. PAYMENT_METHOD.CREDIT_CARD, PAYMENT_METHOD.ACH). |
initialTransactionId | string | Filter by the transaction that created this payment method. |
customerId | string | Filter by AccruPay customer ID. |
merchantInternalCustomerCode | string | Filter by your customer identifier. |
isDefault | boolean | Filter for default payment methods. |
hasProviderError | boolean | Filter for methods with or without provider sync errors. |
skip | number | Offset pagination: number of records to skip. |
take | number | Offset pagination: number of records to return. |
after | string | Cursor pagination: return records after this cursor. |
first | number | Cursor pagination: number of records after cursor. |
before | string | Cursor pagination: return records before this cursor. |
last | number | Cursor pagination: number of records before cursor. |
sorting | object | Sort 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.
getOne() only accepts merchantCustomerPaymentMethodId. There is no option to look up by providerCode or any other identifier — unlike transactions.getOne() which accepts multiple options.
| Parameter | Type | Required | Description |
|---|---|---|---|
merchantCustomerPaymentMethodId | string (CUID) | Yes | AccruPay 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.
| Parameter | Type | Required | Description |
|---|---|---|---|
merchantTransactionProviderId | string | Yes | Provider configuration ID (routes the sync request to the correct provider). |
providerCode | string | Yes | Provider-assigned payment method identifier. |
customer | MerchantCustomerSelector | No | Customer 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
| Field | Type | Description |
|---|---|---|
id | string | AccruPay payment method ID. |
customerId | string | AccruPay customer ID this method belongs to. |
initialTransactionId | string | null | ID of the transaction that created this payment method. |
isDefault | boolean | Whether this is the customer's default payment method. |
isEnabled | boolean | Whether this payment method is active and chargeable. |
expiresAt | DateTimeISO | null | Expiration date (for cards). |
status | string | Current status of the payment method. |
merchantInternalCustomerCode | string | null | Your customer identifier. |
methodType | PAYMENT_METHOD | Type of payment method (CREDIT_CARD, ACH, GENERIC, etc.). |
providerCode | string | Provider-assigned payment method identifier. |
providerCustomerCode | string | null | Provider-assigned customer identifier associated with this method. |
providerError | object | null | Provider error detail from the last sync attempt. |
providerLastSyncedAt | DateTimeISO | null | When the payment method was last synced with the provider. |
providerLastVerifiedAt | DateTimeISO | null | When the payment method was last verified as chargeable. |
providerStatus | string | null | Raw status string from the provider. |
transactionProviderId | string | Provider configuration ID associated with this method. |
billing* | string | Billing address fields stored with this payment method. |
createdAt | DateTimeISO | When the payment method was created. |
updatedAt | DateTimeISO | When the payment method was last updated. |
paymentMethodInfo union
The paymentMethodInfo field contains method-specific details. Its shape depends on methodType.
Credit card — MerchantCustomerPaymentMethodCreditCardInfo
| Field | Type | Description |
|---|---|---|
methodType | PAYMENT_METHOD | Always PAYMENT_METHOD.CREDIT_CARD. |
cardBrand | string | Card network (e.g. VISA, MASTERCARD, AMEX). |
cardNumberMasked | string | Masked card number (e.g. ************4242). |
expirationMonth | number | Expiration month (1–12). |
expirationYear | number | Four-digit expiration year. |
ACH — MerchantCustomerPaymentMethodAchInfo
| Field | Type | Description |
|---|---|---|
methodType | PAYMENT_METHOD | Always PAYMENT_METHOD.ACH. |
accountNumber | string | Bank account number (may be masked). |
bankName | string | null | Bank name, if resolved by the provider. |
routingNumber | string | Bank routing (ABA) number. |
secCode | string | null | NACHA Standard Entry Class code (CCD, WEB, TEL, etc.). |
Generic — MerchantCustomerPaymentMethodGenericInfo
| Field | Type | Description |
|---|---|---|
methodType | PAYMENT_METHOD | The 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);
}