Kijan pou m estoke tranzaksyon MonCash ak NatCash yo nan baz done a?
posée 3 months ago634 vuesht
7
Mwen vle kenbe istwa tout peman yo pou kontablite ak pou lè kliyan gen plent. Ki estrikti tab ou konseye pou plizyè founisè?
Diagnostic IA
Généré par IA. Ce n'est pas une réponse — la communauté ci-dessous le confirme ou le corrige. Vérifiez toujours avant de vous y fier.
posée 3 months ago
James Étienne 2.3k
1 réponse
3
✓✓ Réponse acceptée
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.
Connectez-vous pour dire si ça a marché.
answered 3 months ago
Jean Pierre 5.1k
Sign in and verify your email to post an answer.