Skip to main content

Customers

A customer record in AccruPay links your internal customer identifier to AccruPay's customer UUID. Customer records are created lazily — AccruPay creates one the first time you reference a merchantInternalCustomerCode in a transaction or payment plan.

You can also create or resolve customer records explicitly using the operations below.


merchantApiCustomerResolve

Look up a customer against a configured provider. Returns a non-null MerchantCustomer — the operation throws if no matching customer is found (it does not return null).

query ResolveCustomer(
$selector: MerchantCustomerSelector!
$merchantTransactionProviderId: String
) {
merchantApiCustomerResolve(
selector: $selector
merchantTransactionProviderId: $merchantTransactionProviderId
) {
id
merchantInternalCustomerCode
firstName
lastName
email
phone
createdAt
updatedAt
}
}

Arguments

ArgumentTypeRequiredDescription
selectorMerchantCustomerSelectorYesCustomer lookup input
merchantTransactionProviderIdStringNoTarget a specific configured provider by its internal ID. Required if you have multiple providers.
transactionProviderTRANSACTION_PROVIDERNoSelect provider by enum. Alternative to merchantTransactionProviderId.

MerchantCustomerSelector fields

FieldTypeRequiredDescription
merchantInternalCustomerCodeStringYesYour internal identifier for the customer
idStringNoAccruPay customer ID
providerCodeStringNoCustomer code on the transaction provider
resolutionStrategyCUSTOMER_RESOLUTION_STRATEGYNoHow to resolve the customer: AUTO, MATCH_OR_CREATE, MATCH_OR_FAIL, STRICT. See Enums.

Example variables

{
"selector": {
"merchantInternalCustomerCode": "customer-123"
}
}

merchantApiCustomerCreate

Explicitly create a customer record. Use this when you want to register a customer before their first transaction.

mutation CreateCustomer(
$data: MerchantCustomerCreateSchema!
$merchantTransactionProviderId: String
) {
merchantApiCustomerCreate(
data: $data
merchantTransactionProviderId: $merchantTransactionProviderId
) {
id
merchantInternalCustomerCode
firstName
lastName
email
phone
createdAt
updatedAt
}
}

Arguments

ArgumentTypeRequiredDescription
dataMerchantCustomerCreateSchemaYesCustomer data
merchantTransactionProviderIdStringNoTarget a specific configured provider by its internal ID. Required if you have multiple providers.
transactionProviderTRANSACTION_PROVIDERNoSelect provider by enum. Alternative to merchantTransactionProviderId.

MerchantCustomerCreateSchema fields

FieldTypeRequiredDescription
merchantInternalCustomerCodeStringNoYour customer identifier — should be stable and unique within your merchant account
firstNameStringNoCustomer first name
lastNameStringNoCustomer last name
emailStringNoCustomer email address
phoneStringNoCustomer phone number
addressLine1StringNoStreet address line 1
addressLine2StringNoStreet address line 2
addressCityStringNoCity
addressStateStringNoState or province
addressPostalCodeStringNoPostal / ZIP code
addressCountryStringNoISO 3166-1 alpha-2 country code

Example

mutation {
merchantApiCustomerCreate(
data: {
merchantInternalCustomerCode: "customer-123"
firstName: "Jane"
lastName: "Smith"
email: "jane@example.com"
}
) {
id
merchantInternalCustomerCode
}
}

Customer return shape

Both operations return the same customer object.

FieldTypeDescription
idStringAccruPay customer UUID
merchantInternalCustomerCodeStringYour customer identifier
firstNameStringFirst name; null if not set
lastNameStringLast name; null if not set
emailStringEmail; null if not set
phoneStringPhone; null if not set
createdAtDateTimeISORecord creation timestamp
updatedAtDateTimeISOLast update timestamp

Notes

  • merchantInternalCustomerCode is your source-of-truth link between AccruPay and your own database. Choose a stable identifier such as your database primary key or UUID — do not use mutable values like email addresses.
  • Payment methods and payment plans are associated with customers via merchantInternalCustomerCode. A customer record is automatically created the first time that code appears in a transaction.
  • If you call merchantApiCustomerCreate with a code that already exists, the API fails with a business-rule error (a namespaced @domain/REASON AppError key in extensions.code). See Errors.