diff --git a/src/params/index.ts b/src/params/index.ts index 94c9ddb..617b455 100644 --- a/src/params/index.ts +++ b/src/params/index.ts @@ -31,6 +31,7 @@ export * from "./transactions/ListTransactionsParams"; export * from "./transactions/ReverseParams"; export * from "./transactions/TransferParams"; export * from "./transactions/VoidPendingParams"; +export * from "./transactions/GetTransactionChainParams"; export * from "./values/ChangeValuesCodeParams"; export * from "./values/CreateValueParams"; diff --git a/src/params/transactions/GetTransactionChainParams.ts b/src/params/transactions/GetTransactionChainParams.ts index 5837c1c..d63234b 100644 --- a/src/params/transactions/GetTransactionChainParams.ts +++ b/src/params/transactions/GetTransactionChainParams.ts @@ -1,5 +1,5 @@ import {Transaction} from "../../model"; import {LightrailResponse} from "../LightrailResponse"; -export interface GetTransactionChainResponse extends LightrailResponse { +export interface GetTransactionChainResponse extends LightrailResponse { } \ No newline at end of file diff --git a/src/transactions.test.ts b/src/transactions.test.ts index 1b51d55..e565478 100644 --- a/src/transactions.test.ts +++ b/src/transactions.test.ts @@ -254,6 +254,41 @@ describe("transactions", () => { }); }); + describe("getTransactionChain", () => { + it("successfully captures a pending transaction and fetches the chain", async () => { + const debitTxId = uuid.v4().substring(0, 24); + const captureTxId = uuid.v4().substring(0, 24); + + const debitTx = await Lightrail.transactions.debit({ + id: debitTxId, + currency: "USD", + amount: 100, + source: { + rail: "lightrail", + valueId: valueId + }, + pending: true + }); + + chai.assert.isNotNull(debitTx); + chai.assert.equal(debitTx.body.transactionType, "debit"); + + const captureTx = await Lightrail.transactions.capturePending(debitTx.body, { + id: captureTxId + }); + + chai.assert.isNotNull(captureTx); + chai.assert.equal(captureTx.body.transactionType, "capture"); + + const transactionChain = await Lightrail.transactions.getTransactionChain(debitTxId); + + chai.assert.isNotNull(transactionChain); + chai.assert.equal(transactionChain.body.length, 2); + chai.assert.isNotNull(transactionChain.body.find(p => p.id === debitTxId)); + chai.assert.isNotNull(transactionChain.body.find(p => p.id === captureTxId)); + }); + }); + describe("getTransaction()", () => { it("successfully fetches a transaction by id", async () => { const transaction = await getTransaction(creditId); diff --git a/src/transactions.ts b/src/transactions.ts index b6141d3..c5ff5ae 100644 --- a/src/transactions.ts +++ b/src/transactions.ts @@ -10,6 +10,7 @@ import { CreditResponse, DebitParams, DebitResponse, + GetTransactionChainResponse, GetTransactionResponse, ListTransactionsParams, ListTransactionsResponse, @@ -21,7 +22,6 @@ import { VoidPendingResponse } from "./params"; import {Transaction} from "./model"; -import {GetTransactionChainResponse, TransactionChainResponse} from "./params/transactions/GetTransactionChainParams"; export async function checkout(params: CheckoutParams): Promise { if (!params) {