Skip to main content

Payment Methods

Stored payment methods are saved payment credentials created through a previous payment or add-payment-method session. Once stored, they can be charged directly from your backend without requiring the customer to re-enter their payment details.

All operations on this page require the accrupay-api-secret header and must be called from your backend.


Payment method fields

The following fields are available on the CustomerPaymentMethod type.

FieldTypeDescription
idString!AccruPay payment method ID
merchantCustomerPaymentMethodIdString!Same as id — the canonical identifier for this payment method
providerCodeStringProvider-assigned reference for this payment method
customerIdString!AccruPay customer ID that owns this payment method
merchantInternalCustomerCodeStringYour own reference for the owning customer
paymentMethodPAYMENT_METHOD!Type of payment instrument (CARD, ACH, OTHER)
isActiveBoolean!Whether this payment method can be charged
createdAtDateTimeISO!When the payment method was stored
updatedAtDateTimeISO!When the record was last updated
paymentMethodInfoPaymentMethodInfoPayment-method-type-specific details (see union below)

paymentMethodInfo union

The paymentMethodInfo field returns a union type. Query with inline fragments to get type-specific fields.

fragment PaymentMethodInfoFields on CustomerPaymentMethod {
paymentMethodInfo {
... on CardPaymentMethodInfo {
cardBrand
cardLast4
cardExpMonth
cardExpYear
cardHolderName
}
... on AchPaymentMethodInfo {
achAccountLast4
achRoutingNumber
achAccountType
achBankName
achSecCode
}
... on OtherPaymentMethodInfo {
description
}
}
}

CardPaymentMethodInfo fields

FieldTypeDescription
cardBrandStringCard network (e.g. "Visa", "Mastercard", "Amex")
cardLast4StringLast four digits of the card number
cardExpMonthIntExpiration month (1–12)
cardExpYearIntExpiration year (4-digit)
cardHolderNameStringName on the card

AchPaymentMethodInfo fields

FieldTypeDescription
achAccountLast4StringLast four digits of the bank account number
achRoutingNumberStringBank routing number
achAccountTypeStringAccount type (e.g. "checking", "savings")
achBankNameStringName of the bank
achSecCodeTRANSACTION_ACH_SECCODEACH Standard Entry Class code

OtherPaymentMethodInfo fields

FieldTypeDescription
descriptionStringHuman-readable description of the payment method

merchantApiCustomerPaymentMethods — list payment methods

Returns a paginated list of stored payment methods for your merchant account.

Query

query ListPaymentMethods(
$take: Int
$skip: Int
$after: String
$first: Int
$customerId: String
$merchantInternalCustomerCode: String
$paymentMethod: PAYMENT_METHOD
$isActive: Boolean
) {
merchantApiCustomerPaymentMethods(
take: $take
skip: $skip
after: $after
first: $first
customerId: $customerId
merchantInternalCustomerCode: $merchantInternalCustomerCode
paymentMethod: $paymentMethod
isActive: $isActive
) {
edges {
node {
id
merchantCustomerPaymentMethodId
providerCode
customerId
merchantInternalCustomerCode
paymentMethod
isActive
createdAt
paymentMethodInfo {
... on CardPaymentMethodInfo {
cardBrand
cardLast4
cardExpMonth
cardExpYear
}
... on AchPaymentMethodInfo {
achAccountLast4
achBankName
achAccountType
}
... on OtherPaymentMethodInfo {
description
}
}
}
cursor
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
totalCount
}
}

curl example

curl -X POST https://api.pay.accru.co/graphql \
-H "Content-Type: application/json" \
-H "accrupay-api-secret: YOUR_SECRET" \
-d '{
"query": "query ListPaymentMethods($merchantInternalCustomerCode: String, $isActive: Boolean) { merchantApiCustomerPaymentMethods(merchantInternalCustomerCode: $merchantInternalCustomerCode, isActive: $isActive) { edges { node { id paymentMethod isActive paymentMethodInfo { ... on CardPaymentMethodInfo { cardBrand cardLast4 cardExpMonth cardExpYear } } } } totalCount } }",
"variables": { "merchantInternalCustomerCode": "customer-456", "isActive": true }
}'

Filter parameters

ParameterTypeDescription
takeIntPage size for offset pagination
skipIntOffset for offset pagination
firstIntPage size for cursor pagination (forward)
afterStringCursor for forward pagination
customerIdStringFilter by AccruPay customer ID
merchantInternalCustomerCodeStringFilter by your own customer reference code
paymentMethodPAYMENT_METHODFilter by payment method type (CARD, ACH, OTHER)
isActiveBooleanFilter to only active (chargeable) methods
tip

Always filter by isActive: true when presenting saved payment methods to a customer. Inactive methods cannot be charged.


merchantApiCustomerPaymentMethod — get one payment method

Fetch a single stored payment method by its ID.

Query

query GetPaymentMethod($merchantCustomerPaymentMethodId: String!) {
merchantApiCustomerPaymentMethod(
merchantCustomerPaymentMethodId: $merchantCustomerPaymentMethodId
) {
id
merchantCustomerPaymentMethodId
providerCode
customerId
merchantInternalCustomerCode
paymentMethod
isActive
createdAt
updatedAt
paymentMethodInfo {
... on CardPaymentMethodInfo {
cardBrand
cardLast4
cardExpMonth
cardExpYear
cardHolderName
}
... on AchPaymentMethodInfo {
achAccountLast4
achRoutingNumber
achAccountType
achBankName
achSecCode
}
... on OtherPaymentMethodInfo {
description
}
}
}
}

Parameters

ParameterTypeRequiredDescription
merchantCustomerPaymentMethodIdString!YesAccruPay payment method ID
note

Unlike transactions, payment methods have only one lookup identifier: merchantCustomerPaymentMethodId. Use merchantApiCustomerPaymentMethods with a filter if you need to look up by customer code.


merchantApiCustomerPaymentMethodSyncOne — sync a payment method

Fetches the latest state of a stored payment method from the provider and updates AccruPay's record. Use this when you suspect the local state is stale.

Mutation

mutation SyncPaymentMethod(
$merchantTransactionProviderId: String!
$providerCode: String!
$customer: MerchantCustomerSelector
) {
merchantApiCustomerPaymentMethodSyncOne(
merchantTransactionProviderId: $merchantTransactionProviderId
providerCode: $providerCode
customer: $customer
) {
id
merchantCustomerPaymentMethodId
providerCode
paymentMethod
isActive
updatedAt
paymentMethodInfo {
... on CardPaymentMethodInfo {
cardBrand
cardLast4
cardExpMonth
cardExpYear
}
... on AchPaymentMethodInfo {
achAccountLast4
achBankName
}
... on OtherPaymentMethodInfo {
description
}
}
}
}

curl example

curl -X POST https://api.pay.accru.co/graphql \
-H "Content-Type: application/json" \
-H "accrupay-api-secret: YOUR_SECRET" \
-d '{
"query": "mutation SyncPaymentMethod($merchantTransactionProviderId: String!, $providerCode: String!, $customer: MerchantCustomerSelector) { merchantApiCustomerPaymentMethodSyncOne(merchantTransactionProviderId: $merchantTransactionProviderId, providerCode: $providerCode, customer: $customer) { id isActive updatedAt } }",
"variables": {
"merchantTransactionProviderId": "provider-config-id",
"providerCode": "pm_provider_ref_123",
"customer": { "merchantInternalCustomerCode": "customer-456" }
}
}'

Parameters

ParameterTypeRequiredDescription
merchantTransactionProviderIdString!YesID of the merchant-provider configuration to sync against
providerCodeString!YesProvider-assigned reference for this payment method
customerMerchantCustomerSelectorNoCustomer selector to scope the lookup

MerchantCustomerSelector fields

FieldTypeDescription
customerIdStringAccruPay customer ID
merchantInternalCustomerCodeStringYour own customer reference code
danger

Syncing a payment method will overwrite its local state with whatever the provider returns. If the provider marks the method as invalid or expired, isActive will be set to false after sync.