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
| Parameter | Type | Description |
|---|---|---|
connection | Pool | PoolClient | Database connection |
orderId | number | Order database ID |
amount | number | Transaction amount |
transactionId | string | number | Provider's transaction ID |
transactionType | string | e.g., 'capture', 'refund', 'authorization' |
paymentAction | string | e.g., 'Capture', 'Refund' |
additionalInformation | string (optional) | Extra details (JSON string) |
parentTransactionId | string | 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
- updatePaymentStatus — Update payment status
- Payment Method Development — Payment gateway guide