diff --git a/resources/payments.ts b/resources/payments.ts index b489a630..9192d3e7 100644 --- a/resources/payments.ts +++ b/resources/payments.ts @@ -18,6 +18,10 @@ export class Payments extends BaseResource { return this.httpPatch>(`/${id}`, {data: request}) } + public async cancel(id: string) : Promise> { + return this.httpPost>(`/${id}/cancel`) + } + /** * Optional. A comma-separated list of related resources to include in the response. * Related resources include: customer, account, transaction. See Getting Related Resources diff --git a/tests/payments.spec.ts b/tests/payments.spec.ts index 70e1ce83..5b172402 100644 --- a/tests/payments.spec.ts +++ b/tests/payments.spec.ts @@ -60,11 +60,10 @@ describe("Create BookPayment", () => { }) }) -describe("Create Linkedayment", () => { - test("create linked payment", async () => { - const createCounterpartRes = await createCounterpartyForTest("22603") - - const req: CreateLinkedPaymentRequest = { +async function createPayment() : Promise { + const createCounterpartRes = await createCounterpartyForTest("22603") + + return { "type": "achPayment", "attributes": { "amount": 200, @@ -85,10 +84,29 @@ describe("Create Linkedayment", () => { } } } - } + } +} + +describe("Create LinkedPayment", () => { + test("create linked payment", async () => { + + + const req: CreateLinkedPaymentRequest = (await createPayment()) const createPaymentRes = await unit.payments.create(req) const res = await unit.payments.get(createPaymentRes.data.id) expect(res.data.type === "achPayment").toBeTruthy() }) }) + +describe("Create and cancel LinkedPayment", () => { + test("create and cancel linked payment", async () => { + + + const req: CreateLinkedPaymentRequest = (await createPayment()) + + const createPaymentRes = await unit.payments.create(req) + const res = await unit.payments.cancel(createPaymentRes.data.id) + expect(res.data.type === "achPayment").toBeTruthy() + }) +})