Skip to content

Submit Merchant Charges

The submitMerchantCharges mutation allows merchants to submit a list of charges to be billed. This mutation is essential for merchants who need to report various charges, such as taxes or usage fees, that should appear on their client’ invoices.

mutation submitMerchantCharges($input: SubmitMerchantChargesInput!) {
submitMerchantCharges(input: $input)
}
  • Returns: Boolean! — A boolean value indicating whether the submission was successful.

The SubmitMerchantChargesInput object contains all the necessary information to submit merchant charges.

  • merchantId (ID!): The unique identifier for the merchant. Could be a UUID (legacy provider ID) or an xid (merchant ID).
  • accountId (ID!): The unique identifier for the account associated with the charges.
  • billedAt (Date!): The date when the charges are billed.
  • charges ([MerchantChargeInput!]!): A list of charges that the merchant is submitting. Each charge must conform to the MerchantChargeInput type.

Represents a single charge submitted by the merchant.

  • amount (Int!): The amount for the charge, expressed as an integer.
  • referenceId (ID!): A unique identifier for the charge on the merchant’s side. This ensures that the charge can be tracked and matched with the merchant’s records.
  • type (MerchantChargeType!): The type of charge, which can be either TAX or USAGE.
  • name (String!): A short description of the charge, which is displayed on the invoice.
  • description (String): An optional description of the charge, providing more context or details.
  • startedAt (Date!): The date when the charge started.
  • endedAt (Date): Optionally, when the charge ended.
  • details (MerchantChargeDetailsInput!): Detailed information about the charge, which varies based on the type of charge. This field can represent either subscription-related or one-time product charges.

Contains detailed information about the charge.

  • id (ID!): The unique identifier associated with this charge. When the charge is related to a subscription, this field should be set to the Subscription ID. When the charge is related to a one-time product purchase, this field should be set to the ID of a Product Option.
  • context (MerchantChargeContext!): The context of the charge, set to SUBSCRIPTION to indicate this is a subscription charge or set to ONE_TIME to indicate this is a one-time product purchase.

Defines the type of the charge.

  • TAX: Represents a tax-related charge.
  • USAGE: Represents a charge based on usage, such as metered services.

Indicates the context of the charge.

  • SUBSCRIPTION: Indicates that the charge is related to a subscription.
  • ONE_TIME: Indicates that the charge is for a one-time product purchase.

Below is an example of how to use the submitMerchantCharges mutation, including sample JSON data for a Voice Service.

mutation SubmitMerchantCharges($input: SubmitMerchantChargesInput!) {
submitMerchantCharges(input: $input)
}
{
"input": {
"merchantId": "merchant-uuid-or-xid",
"accountId": "account-uuid",
"billedAt": "2023-10-01",
"charges": [
{
"amount": 5000,
"referenceId": "call-charge-001",
"type": "USAGE",
"name": "International Call Charges",
"description": "Calls made to international numbers in September",
"startedAt": "2023-09-01",
"endedAt": "2023-09-30",
"details": {
"id": "subscription-uuid",
"context": "SUBSCRIPTION"
}
},
{
"amount": 1200,
"referenceId": "tax-charge-001",
"type": "TAX",
"name": "Regulatory Tax",
"description": "Government regulatory tax for VoIP services",
"startedAt": "2023-09-01",
"details": {
"id": "subscription-uuid",
"context": "SUBSCRIPTION"
}
}
]
}
}
  • merchantId: Replace "merchant-uuid-or-xid" with the merchant’s unique identifier.
  • accountId: Replace "account-uuid" with the account’s unique identifier.
  • billedAt: The date when the charges are billed (format: YYYY-MM-DD).
  • charges: An array of charge objects.
    • First Charge (USAGE type):
      • amount: 5000 (the charge amount in cents).
      • referenceId: "call-charge-001" (unique charge identifier).
      • type: "USAGE".
      • name: "International Call Charges".
      • description: "Calls made to international numbers in September".
      • startedAt: "2023-09-01".
      • endedAt: "2023-09-30".
      • details:
        • id: "service-subscription-uuid" (associated subscription ID).
        • context: "SUBSCRIPTION".
    • Second Charge (TAX type):
      • amount: 1200 (the charge amount in cents).
      • referenceId: "tax-charge-001".
      • type: "TAX".
      • name: "Regulatory Tax".
      • description: "Government regulatory tax for VoIP services".
      • startedAt: "2023-09-01".
      • endedAt: Not provided (optional).
      • details:
        • id: "subscription" (associated subscription ID).
        • context: "SUBSCRIPTION".
{
"data": {
"submitMerchantCharges": true
}
}
  • A response of true indicates that the charges were submitted successfully.
  • Date Fields: All date fields should be in the format YYYY-MM-DD.
  • Amount Field: The amount should be an integer representing the smallest currency unit (e.g., cents for USD).
  • Reference IDs: Ensure that merchantId, accountId, and details.id are unique and correctly correspond to existing records.
  • Enum Values: The type and context fields must match one of the defined enum values exactly ("TAX", "USAGE", "SUBSCRIPTION", "ONE_TIME").
  • Optional Fields: The description and endedAt fields are optional and can be omitted if not applicable.

If there’s an error during the mutation (e.g., invalid input, missing required fields), the response will include error details:

{
"errors": [
{
"message": "Invalid merchantId provided.",
"locations": [{ "line": 2, "column": 3 }],
"path": ["submitMerchantCharges"]
}
],
"data": {
"submitMerchantCharges": null
}
}
  • Check the errors array for details about what went wrong.