21 January 2019
Composable Commerce
HTTP API
Enhancement
GraphQLPayments

You can now access payments and related information using the GraphQL schema.

  • [GraphQL API] Added the following types to the GraphQL schema: Payment, PaymentMethodInfo, PaymentQueryResult, PaymentStatus, Transaction, TransactionState, TransactionType.
  • [GraphQL API] Changed the Query type:
    • Added the payments field to the Query type.
    • Added the payment field to the Query type.
  • [GraphQL API] Changed the PaymentInfo type:
    • Added the payments field to the PaymentInfo type.

Introduced the following changes to the GraphQL schema (in SDL format):

extend type Query {
  payment(
    "Queries with specified ID"
    id: String,

    "Queries with specified key"
    key: String): Payment
  payments(where: String, sort: [String!], limit: Int, offset: Int): PaymentQueryResult!
}

extend type PaymentInfo {
  payments: [Payment!]!
}

"""
Payments hold information about the current state of receiving and/or refunding money.
[documentation](/http-api-projects-payments)
"""
type Payment implements Versioned {
  key: String
  customerRef: Reference
  customer: Customer
  anonymousId: String
  interfaceId: String
  amountPlanned: Money!
  paymentMethodInfo: PaymentMethodInfo!
  paymentStatus: PaymentStatus!
  transactions: [Transaction!]!
  interfaceInteractionsRaw(
    """
    The names of the custom fields to include.

    If neither `includeNames` nor `excludeNames` are provided, then all custom fields are returned.
    """
    includeNames: [String!],

    """
    The names of the custom fields to exclude.

    If neither `includeNames` nor `excludeNames` are provided, then all custom fields are returned.
    """
    excludeNames: [String!]): [[RawCustomField!]!]!

  "This field contains non-typed data. Consider using `customFields` as a typed alternative."
  customFieldsRaw(
    """
    The names of the custom fields to include.

    If neither `includeNames` nor `excludeNames` are provided, then all custom fields are returned.
    """
    includeNames: [String!],

    """
    The names of the custom fields to exclude.

    If neither `includeNames` nor `excludeNames` are provided, then all custom fields are returned.
    """
    excludeNames: [String!]): [RawCustomField!]

  "This field would contain type data"
  customFields: Type
  id: String!
  version: Long!
  createdAt: DateTime!
  lastModifiedAt: DateTime!
  createdBy: Initiator
  lastModifiedBy: Initiator
}

type PaymentMethodInfo {
  paymentInterface: String
  method: String
  name(
    "String is defined for different locales. This argument specifies the desired locale."
    locale: Locale,

    "List of languages the client is able to understand, and which locale variant is preferred."
    acceptLanguage: [Locale!]): String
  nameAllLocales: [LocalizedString!]
}

type PaymentQueryResult {
  offset: Int!
  count: Int!
  total: Long!
  results: [Payment!]!
}

type PaymentStatus {
  interfaceCode: String
  interfaceText: String
  stateRef: Reference
  state: State
}

type Transaction {
  id: String!
  timestamp: DateTime
  type: TransactionType
  amount: Money!
  interactionId: String
  state: TransactionState!
}

enum TransactionState {
  Failure
  Success
  Pending
  Initial
}

enum TransactionType {
  Chargeback
  Refund
  Charge
  CancelAuthorization
  Authorization
}