1b8d6fcce6
Add database-backed administrators, configurable Alipay packages, idempotent payment settlement and platform reporting. Standardize Gitea workflows on the xiaoxin runner so reviewed staging commits are tested, packaged, and deployed by immutable image digest.
21 lines
1.1 KiB
TypeScript
21 lines
1.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { test } from "node:test";
|
|
import { epayCanonical, epaySign } from "../src/lib/epay/sign";
|
|
|
|
const migration = readFileSync(new URL("../supabase/migrations/20260727020000_epay_packages_orders.sql", import.meta.url), "utf8");
|
|
|
|
test("易支付签名过滤空值并按键排序", () => {
|
|
const params = { money: "10.00", pid: "10001", name: "套餐", empty: "", sign_type: "MD5" };
|
|
assert.equal(epayCanonical(params), "money=10.00&name=套餐&pid=10001");
|
|
assert.equal(epaySign(params, "secret"), "79dd3a13f9fd32622fa2197c0a2d7b66");
|
|
});
|
|
|
|
test("支付迁移包含套餐、订单、payment 类型与原子结算", () => {
|
|
assert.match(migration, /create table public\.payment_packages/);
|
|
assert.match(migration, /create table public\.payment_orders/);
|
|
assert.match(migration, /transaction_type in \('redeem', 'reserve', 'refund', 'payment'\)/);
|
|
assert.match(migration, /settle_epay_order/);
|
|
assert.match(migration, /on conflict \(user_id, transaction_type, request_id\) do nothing/);
|
|
});
|