Skip to content

Create Transaction

The API equivalent of the admin Sales → Transactions → Create ("Record Payment") action. Records a manual payment against an invoice and returns the created transaction, which then appears in the Transactions listing.

Partial payments are supported. Once the cumulative recorded payments for an invoice reach its grand total, the invoice is marked paid and the order advances to completed (when it already has a shipment) or processing.

Two ways to create a transaction

This mutation records an arbitrary or partial payment you specify (invoice, method, amount). Alternatively, the Create Transaction checkbox on invoice creation captures the full invoice amount in one step using the order's payment method. Both result in a transaction that appears in the Transactions listing.

Mutation

createAdminTransaction(input: createAdminTransactionInput!)

Input fields

FieldTypeRequiredDescription
invoiceIdIntYesThe invoice to record the payment against.
paymentMethodStringYesPayment method code (e.g. cashondelivery, moneytransfer).
amountFloatYesAmount paid. Must be greater than 0 and cannot push the invoice's cumulative payments above its grand total.

Response fields

The mutation returns the created transaction under adminTransaction:

FieldTypeDescription
id / _idID / IntegerResource identifier and numeric transaction id.
transactionIdStringGenerated transaction reference.
invoiceIdIntegerThe invoice this payment was recorded against.
orderId / orderIncrementIdInteger / StringParent order id and human-facing number.
amount / formattedAmountNumber / StringRecorded amount, raw and formatted.
statusStringAlways paid for a recorded payment.
type / paymentMethodStringThe payment method code used.
paymentTitleStringHuman-readable payment method title.
dataObjectRecorded payment payload — { "paidAmount": <amount> }.
createdAt / updatedAtStringTimestamps.
orderObjectSlim order summary — id, incrementId, status, customerName, customerEmail, grandTotal, orderCurrencyCode.

Errors

Business-rule failures are returned in the errors array: an unknown invoice, an already-paid invoice, an amount ≤ 0, or an amount that would exceed the invoice grand total. Missing or non-numeric input fields are rejected as validation errors.

Creating a transaction while invoicing (the "Create Transaction" checkbox)

On the order detail page, the admin invoice form has a Create Transaction checkbox. Ticking it records the payment automatically at the moment the invoice is created — you don't call this mutation at all.

The API equivalent is not a separate transaction call: it's a single flag on the Create Invoice mutation. Pass canCreateTransaction: true in the invoice input and the invoice's full amount is recorded as a transaction against the order's payment method in the same mutation:

graphql
mutation CreateAdminInvoice($input: createAdminInvoiceInput!) {
  createAdminInvoice(input: $input) {
    adminInvoice {
      id
      _id
      state
    }
  }
}
json
{
  "input": {
    "orderId": 8,
    "items": [ { "orderItemId": 42, "quantity": 1 } ],
    "canCreateTransaction": true
  }
}

The resulting transaction then appears in the Transactions listing, exactly like one created through this mutation.

Which to use:

You want to…Use
Record the full invoice amount at invoice time (one step)Create Invoice with canCreateTransaction: true
Record a partial payment, a later payment, or a specific amount/method against an existing invoiceThis mutation (createAdminTransaction)

Permission

sales.transactions.view

Released under the MIT License.