Skip to main content

Sessions

Client transaction sessions drive the payment UI flow. Your backend creates a session, passes its token to the frontend, and the customer completes the payment or adds a payment method using the provider's hosted UI. Once the customer is done, your backend verifies the session to get the final result.

AccruPay supports three session flows:

  • Payment session — charge a payment method
  • Add-payment-method session — store a payment method without charging
  • Authorization session — authorize (reserve) funds without capturing

Session fields

The following fields are returned by session queries and mutations.

FieldTypeDescription
idString!AccruPay session ID
tokenString!Short-lived token passed to the frontend/React SDK
providerCodeStringProvider-assigned session reference
statusCLIENT_TRANSACTION_SESSION_STATUS!Current session status
kindCLIENT_TRANSACTION_SESSION_KIND!Whether the session was started from CLIENT or SERVER context
merchantInternalTransactionCodeStringYour own reference code for this session
transactionIdStringID of the resulting transaction once verified
merchantTransactionProviderIdStringID of the merchant-provider configuration used
createdAtDateTimeISO!When the session was created
updatedAtDateTimeISO!When the session was last updated
expiresAtDateTimeISOWhen the session will expire

merchantApiClientTransactionSessions — list sessions

Returns a paginated list of client transaction sessions.

Query

query ListSessions(
$take: Int
$skip: Int
$after: String
$first: Int
$status: CLIENT_TRANSACTION_SESSION_STATUS
$merchantInternalTransactionCode: String
) {
merchantApiClientTransactionSessions(
take: $take
skip: $skip
after: $after
first: $first
status: $status
merchantInternalTransactionCode: $merchantInternalTransactionCode
) {
edges {
node {
id
token
status
kind
merchantInternalTransactionCode
createdAt
expiresAt
}
cursor
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
totalCount
}
}

Filter parameters

ParameterTypeDescription
takeIntPage size for offset pagination
skipIntOffset for offset pagination
firstIntPage size for cursor pagination (forward)
afterStringCursor for forward pagination
statusCLIENT_TRANSACTION_SESSION_STATUSFilter by session status
merchantInternalTransactionCodeStringFilter by your transaction reference

merchantApiClientTransactionSession — get one session

Fetch a single session by ID or by your internal transaction code.

Query

query GetSession(
$id: String
$merchantInternalTransactionCode: String
) {
merchantApiClientTransactionSession(
id: $id
merchantInternalTransactionCode: $merchantInternalTransactionCode
) {
id
token
providerCode
status
kind
merchantInternalTransactionCode
transactionId
merchantTransactionProviderId
createdAt
updatedAt
expiresAt
}
}

Identifiers

ParameterTypeDescription
idStringAccruPay session ID
merchantInternalTransactionCodeStringYour own transaction reference code

merchantApiClientTransactionSessionBaseConfig — fetch provider config

Returns the provider configuration needed to initialize a payment session on the frontend. Call this from your backend after starting a session and pass the result to your frontend.

Query

query GetSessionBaseConfig($id: String, $merchantInternalTransactionCode: String) {
merchantApiClientTransactionSessionBaseConfig(
id: $id
merchantInternalTransactionCode: $merchantInternalTransactionCode
) {
id
providerData
}
}
ParameterTypeDescription
idStringAccruPay session ID
merchantInternalTransactionCodeStringYour own transaction reference code

Payment session mutations

merchantApiClientTransactionPaymentSessionStartV2 — start a payment session

Creates a new client payment session. Returns a session with a token to pass to the frontend.

Mutation

mutation StartPaymentSession(
$transactionProvider: TRANSACTION_PROVIDER!
$data: MerchantApiClientTransactionPaymentSessionStartSchema!
) {
merchantApiClientTransactionPaymentSessionStartV2(
transactionProvider: $transactionProvider
data: $data
) {
id
token
providerCode
status
merchantInternalTransactionCode
expiresAt
}
}

Variables

{
"transactionProvider": "YOUR_PROVIDER",
"data": {
"amount": 10000,
"currency": "USD",
"merchantInternalTransactionCode": "order-001",
"merchantInternalCustomerCode": "customer-456",
"storePaymentMethod": false,
"billing": {
"billingFirstName": "Jane",
"billingLastName": "Smith",
"billingEmail": "jane@example.com",
"billingPhone": "+15555550100",
"billingAddress": "123 Main St",
"billingCity": "New York",
"billingState": "NY",
"billingZip": "10001",
"billingAddressCountry": "US"
}
}
}

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 StartPaymentSession($transactionProvider: TRANSACTION_PROVIDER!, $data: MerchantApiClientTransactionPaymentSessionStartSchema!) { merchantApiClientTransactionPaymentSessionStartV2(transactionProvider: $transactionProvider, data: $data) { id token providerCode status expiresAt } }",
"variables": {
"transactionProvider": "YOUR_PROVIDER",
"data": {
"amount": 10000,
"currency": "USD",
"merchantInternalTransactionCode": "order-001",
"merchantInternalCustomerCode": "customer-456",
"storePaymentMethod": false,
"billing": {
"billingFirstName": "Jane",
"billingLastName": "Smith",
"billingEmail": "jane@example.com",
"billingAddressCountry": "US"
}
}
}
}'

Input schema

FieldTypeRequiredDescription
amountBigInt!YesPayment amount in minor currency units
currencyCURRENCY!YesISO 4217 currency code
merchantInternalTransactionCodeString!YesYour unique reference for this transaction
merchantInternalCustomerCodeStringNoYour reference for the customer
storePaymentMethodBooleanNoWhether to store the payment method for future use
customerPaymentMethodIdStringNoCharge an existing stored payment method
billing.billingFirstNameStringNoBilling first name
billing.billingLastNameStringNoBilling last name
billing.billingEmailStringNoBilling email
billing.billingPhoneStringNoBilling phone number
billing.billingAddressStringNoBilling street address
billing.billingCityStringNoBilling city
billing.billingStateStringNoBilling state or region
billing.billingZipStringNoBilling postal code
billing.billingAddressCountryCOUNTRY_ISO_2NoBilling country

merchantApiClientTransactionPaymentSessionVerify — verify a payment session

Verifies a completed payment session and returns the resulting transaction. Call this from your backend after the customer completes the payment UI.

Mutation

mutation VerifyPaymentSession(
$id: String
$token: String
$providerCode: String
$merchantInternalTransactionCode: String
) {
merchantApiClientTransactionPaymentSessionVerify(
id: $id
token: $token
providerCode: $providerCode
merchantInternalTransactionCode: $merchantInternalTransactionCode
) {
id
status
action
amount
currency
paymentMethod
providerCode
errorCode
errorMessage
createdAt
updatedAt
}
}

Identifiers

ParameterTypeDescription
idStringAccruPay session ID
tokenStringSession token (from the start mutation response)
providerCodeStringProvider-assigned session reference
merchantInternalTransactionCodeStringYour own transaction reference code
warning

merchantApiClientTransactionPaymentSessionVerify returns a Transaction, not a session. After calling this mutation, check the transaction's status field to determine whether the payment succeeded.


Add-payment-method session mutations

Use these to store a payment method without charging it.

merchantApiClientTransactionAddPaymentMethodSessionStart

mutation StartAddPaymentMethodSession(
$transactionProvider: TRANSACTION_PROVIDER!
$data: MerchantApiClientTransactionAddPaymentMethodSessionStartSchema!
) {
merchantApiClientTransactionAddPaymentMethodSessionStart(
transactionProvider: $transactionProvider
data: $data
) {
id
token
providerCode
status
merchantInternalTransactionCode
expiresAt
}
}

Input schema

FieldTypeRequiredDescription
currencyCURRENCY!YesCurrency for the session
merchantInternalTransactionCodeString!YesYour unique reference for this operation
merchantInternalCustomerCodeStringNoYour reference for the customer
billing.billingFirstNameStringNoBilling first name
billing.billingLastNameStringNoBilling last name
billing.billingEmailStringNoBilling email
billing.billingAddressCountryCOUNTRY_ISO_2NoBilling country

merchantApiClientTransactionAddPaymentMethodSessionVerify

mutation VerifyAddPaymentMethodSession(
$id: String
$token: String
$providerCode: String
$merchantInternalTransactionCode: String
) {
merchantApiClientTransactionAddPaymentMethodSessionVerify(
id: $id
token: $token
providerCode: $providerCode
merchantInternalTransactionCode: $merchantInternalTransactionCode
) {
id
status
action
providerCode
createdAt
updatedAt
}
}

Identifiers are the same four as the payment session verify mutation. Returns a Transaction with action: ADD_PAYMENT_METHOD.

warning

As with payment session verify, this returns a Transaction — not a payment method object. To retrieve the stored payment method, query merchantApiCustomerPaymentMethods filtered by merchantInternalCustomerCode after a successful verify.


Authorization session mutations

Use these to authorize (reserve) funds without capturing them immediately.

merchantApiClientTransactionAuthorizationSessionStart

mutation StartAuthorizationSession(
$transactionProvider: TRANSACTION_PROVIDER!
$data: MerchantApiClientTransactionAuthorizationSessionStartSchema!
) {
merchantApiClientTransactionAuthorizationSessionStart(
transactionProvider: $transactionProvider
data: $data
) {
id
token
providerCode
status
merchantInternalTransactionCode
expiresAt
}
}

The input schema is the same as the payment session start schema. amount and currency are required.

merchantApiClientTransactionAuthorizationSessionVerify

mutation VerifyAuthorizationSession(
$id: String
$token: String
$providerCode: String
$merchantInternalTransactionCode: String
) {
merchantApiClientTransactionAuthorizationSessionVerify(
id: $id
token: $token
providerCode: $providerCode
merchantInternalTransactionCode: $merchantInternalTransactionCode
) {
id
status
action
amount
currency
providerCode
createdAt
updatedAt
}
}

Returns a Transaction with action: AUTHORIZATION. Capture the authorized amount with a separate settle/capture operation.

warning

Authorization sessions return a Transaction on verify, not a session. Check status to confirm the authorization was successful before proceeding to capture.


Client Public API

These operations do not require the accrupay-api-secret header. They are used by the React SDK and frontend code to read session data without exposing your secret.

clientPublicTransactionSession — get session by token

query GetPublicSession($merchantPublicId: String!, $token: String!) {
clientPublicTransactionSession(
merchantPublicId: $merchantPublicId
token: $token
) {
id
token
status
kind
expiresAt
}
}
ParameterTypeRequiredDescription
merchantPublicIdString!YesYour merchant public ID (safe for frontend use)
tokenString!YesSession token from the start mutation

clientPublicTransactionSessionBaseConfig — get provider config

Returns the provider-specific configuration needed to initialize the payment UI. The React SDK calls this automatically.

query GetPublicSessionBaseConfig($merchantPublicId: String!, $token: String!) {
clientPublicTransactionSessionBaseConfig(
merchantPublicId: $merchantPublicId
token: $token
) {
id
providerData
}
}
note

These Client Public API queries use merchantPublicId instead of the accrupay-api-secret header. The public ID is safe to embed in browser code. Never expose your API secret to the frontend.