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 Definition
Section titled “Mutation Definition”mutation submitMerchantCharges($input: SubmitMerchantChargesInput!) { submitMerchantCharges(input: $input)}- Returns:
Boolean!— A boolean value indicating whether the submission was successful.
Input Type: SubmitMerchantChargesInput
Section titled “Input Type: SubmitMerchantChargesInput”The SubmitMerchantChargesInput object contains all the necessary information to submit merchant charges.
Fields
Section titled “Fields”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 theMerchantChargeInputtype.
Input Type: MerchantChargeInput
Section titled “Input Type: MerchantChargeInput”Represents a single charge submitted by the merchant.
Fields
Section titled “Fields”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 eitherTAXorUSAGE.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.
Input Type: MerchantChargeDetailsInput
Section titled “Input Type: MerchantChargeDetailsInput”Contains detailed information about the charge.
Fields
Section titled “Fields”id(ID!): The unique identifier associated with this charge. When the charge is related to a subscription, this field should be set to the SubscriptionID. When the charge is related to a one-time product purchase, this field should be set to theIDof a Product Option.context(MerchantChargeContext!): The context of the charge, set toSUBSCRIPTIONto indicate this is a subscription charge or set toONE_TIMEto indicate this is a one-time product purchase.
Enum: MerchantChargeType
Section titled “Enum: MerchantChargeType”Defines the type of the charge.
TAX: Represents a tax-related charge.USAGE: Represents a charge based on usage, such as metered services.
Enum: MerchantChargeContext
Section titled “Enum: MerchantChargeContext”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.
Example Usage
Section titled “Example Usage”Below is an example of how to use the submitMerchantCharges mutation, including sample JSON data for a Voice Service.
GraphQL Mutation
Section titled “GraphQL Mutation”mutation SubmitMerchantCharges($input: SubmitMerchantChargesInput!) { submitMerchantCharges(input: $input)}JSON Variables
Section titled “JSON Variables”{ "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" } } ] }}Explanation
Section titled “Explanation”- 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 (
USAGEtype):- 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".
- id:
- amount:
- Second Charge (
TAXtype):- 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".
- id:
- amount:
- First Charge (
Sample Response
Section titled “Sample Response”{ "data": { "submitMerchantCharges": true }}- A response of
trueindicates that the charges were submitted successfully.
- Date Fields: All date fields should be in the format
YYYY-MM-DD. - Amount Field: The
amountshould be an integer representing the smallest currency unit (e.g., cents for USD). - Reference IDs: Ensure that
merchantId,accountId, anddetails.idare unique and correctly correspond to existing records. - Enum Values: The
typeandcontextfields must match one of the defined enum values exactly ("TAX","USAGE","SUBSCRIPTION","ONE_TIME"). - Optional Fields: The
descriptionandendedAtfields are optional and can be omitted if not applicable.
Error Handling
Section titled “Error Handling”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
errorsarray for details about what went wrong.