Skip to main content

Customers

SDK stub — use GraphQL directly

The @accrupay/node customers service currently exports GraphQL fragments only. There are no query functions available on accrupay.customers.*. Use the GraphQL API directly with a raw GraphQL client until full SDK support is added.

Concepts

Resolve a customer

Resolves a customer record against a configured provider. merchantApiCustomerResolve is a query and returns a non-null MerchantCustomer (it throws if no match is found — it does not return null).

Selector type

type MerchantCustomerSelector = {
merchantInternalCustomerCode: string; // required
id?: string; // AccruPay customer ID
providerCode?: string; // customer code on the transaction provider
resolutionStrategy?: CUSTOMER_RESOLUTION_STRATEGY;
};

The operation also requires a provider — pass merchantTransactionProviderId or transactionProvider.

Equivalent GraphQL operation (send directly via your HTTP client):

query MerchantApiCustomerResolve(
$selector: MerchantCustomerSelector!
$merchantTransactionProviderId: String
) {
merchantApiCustomerResolve(
selector: $selector
merchantTransactionProviderId: $merchantTransactionProviderId
) {
id
merchantInternalCustomerCode
providerCode
email
firstName
lastName
}
}
// Variables
{
selector: {
merchantInternalCustomerCode: 'customer-123',
},
merchantTransactionProviderId: 'provider-id',
}

Create a customer with a provider

Creates the customer record in AccruPay and registers it with the connected payment provider.

mutation MerchantApiCustomerCreate(
$data: MerchantCustomerCreateSchema!
$merchantTransactionProviderId: String
) {
merchantApiCustomerCreate(
data: $data
merchantTransactionProviderId: $merchantTransactionProviderId
) {
id
merchantInternalCustomerCode
providerCode
providerStatus
}
}
// Variables
{
data: {
merchantInternalCustomerCode: 'customer-123',
email: 'user@example.com',
firstName: 'Jane',
lastName: 'Doe',
phone: '+15550001234',
addressLine1: '123 Main St',
addressCity: 'Austin',
addressState: 'TX',
addressPostalCode: '78701',
addressCountry: 'US',
},
merchantTransactionProviderId: 'provider-id',
}

Customer fields

Returned by GraphQL operations as MerchantCustomerBaseFragment.

FieldTypeDescription
idstringAccruPay customer ID.
merchantInternalCustomerCodestring | nullYour stable customer identifier.
emailstring | nullCustomer email address.
firstNamestring | nullFirst name.
lastNamestring | nullLast name.
phonestring | nullPhone number.
addressLine1string | nullStreet address line 1.
addressLine2string | nullStreet address line 2.
addressCitystring | nullCity.
addressStatestring | nullState or province.
addressPostalCodestring | nullPostal / ZIP code.
addressCountrystring | nullISO 3166-1 alpha-2 country code.
providerCodestringProvider's customer identifier.
providerErrorstring | nullLast provider error, if any.
providerLastSyncedAtstring | nullISO timestamp of last sync.
providerLastVerifiedAtstringISO timestamp of last verification.
providerStatusCUSTOMER_STATUSCustomer status enum: ENABLED, DISABLED, ERROR, UNKNOWN.
transactionProviderIdstringAssociated transaction provider.
createdAtstringISO creation timestamp.
updatedAtstringISO last-update timestamp.