Skip to main content

addPaymentTransaction

Record a payment transaction (capture, refund, authorization) for an order.

Import

import { addPaymentTransaction } from "@evershop/evershop/oms/services";

Syntax

addPaymentTransaction(
connection: Pool | PoolClient,
orderId: number,
amount: number,
transactionId: string | number,
transactionType: string,
paymentAction: string,
additionalInformation?: string,
parentTransactionId?: string | number
): Promise<PaymentTransactionRow>

Parameters

ParameterTypeDescription
connectionPool | PoolClientDatabase connection
orderIdnumberOrder database ID
amountnumberTransaction amount
transactionIdstring | numberProvider's transaction ID
transactionTypestringe.g., 'capture', 'refund', 'authorization'
paymentActionstringe.g., 'Capture', 'Refund'
additionalInformationstring (optional)Extra details (JSON string)
parentTransactionIdstring | number (optional)Parent transaction for refunds

Examples

import { addPaymentTransaction } from "@evershop/evershop/oms/services";

// Record a capture
await addPaymentTransaction(
connection,
orderId,
99.99,
"pi_1234567890",
"capture",
"Capture",
JSON.stringify({ provider: "stripe" }),
);

// Record a refund linked to the capture
await addPaymentTransaction(
connection,
orderId,
49.99,
"re_0987654321",
"refund",
"Refund",
null,
"pi_1234567890", // parent transaction
);

See Also