Kijan pou m estoke tranzaksyon MonCash ak NatCash yo nan baz done a?
asked 3 months ago629 viewsht
7
Mwen vle kenbe istwa tout peman yo pou kontablite ak pou lè kliyan gen plent. Ki estrikti tab ou konseye pou plizyè founisè?
AI diagnosis
AI-generated. Not an answer — the community below confirms or corrects it. Always verify before relying on it.
asked 3 months ago
James Étienne 2.3k
1 Answer
3
✓✓ Accepted answer
Yon estrikti ki mache byen: kòmand → tantativ peman → evènman.
CREATE TABLE payment_attempts (
id text PRIMARY KEY, -- ID ou voye bay founisè a (inik)
order_id text NOT NULL REFERENCES orders(id),
provider text NOT NULL CHECK (provider IN ('MONCASH','NATCASH','MANUAL')),
amount_htg_cents bigint NOT NULL CHECK (amount_htg_cents > 0),
status text NOT NULL DEFAULT 'PENDING', -- PENDING | SUCCEEDED | FAILED | EXPIRED
provider_reference text, -- transactionId founisè a
paid_at timestamptz,
created_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (provider, provider_reference) -- yon tranzaksyon = yon sèl peman
);
CREATE TABLE payment_events (
id bigserial PRIMARY KEY,
attempt_id text NOT NULL REFERENCES payment_attempts(id),
kind text NOT NULL, -- created | redirected | callback | status_checked | paid | expired
payload jsonb, -- repons founisè a (san done sansib)
created_at timestamptz NOT NULL DEFAULT now()
);
Poukisa se konsa:
payment_attemptsbay estati aktyèl la vit (pou afiche, pou rapò).payment_eventsse istwa konplè a: lè yon kliyan di "mwen te peye", ou wè chak etap ak repons founisè a.UNIQUE (provider, provider_reference)anpeche menm tranzaksyon an sèvi de fwa.- Montan yo an santim antye (
bigint), pafloat.
Sa pou w pa estoke: PIN, kòd OTP, oswa kle API. Pou nimewo telefòn moun ki peye a, kenbe l sèlman si w bezwen l, epi limite ki moun ki ka wè l.
Sign in to tell others whether this worked.
answered 3 months ago
Jean Pierre 5.1k
Sign in and verify your email to post an answer.