1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! rustlavel-payment: payment gateways behind one trait.
//!
//! An application takes money through a *gateway* — a company that presents a
//! virtual account number, a QR code or an e-wallet screen to the customer,
//! collects the payment, and tells the application by webhook. Every gateway
//! does the same five things and describes them differently, so this crate
//! holds the description and a driver holds the difference.
//!
//! # What crosses the trait
//!
//! - [`Money`] — an amount in minor units and a currency. An integer, never a
//! float: money that is rounded is money that goes missing.
//! - [`Channel`] — how the customer pays: a bank's virtual account, QRIS, an
//! e-wallet, or a retail counter. The Indonesian set, because that is where
//! the first driver lives; the enum is not closed.
//! - [`Charge`] — a request for payment and its state, with what the customer
//! needs to pay it (a VA number, a QR string, a deeplink).
//! - [`Transfer`] — money out, to a bank account or an e-wallet.
//! - [`WebhookEvent`] — what a gateway says happened, after its signature has
//! been checked.
//!
//! # The receiver, and why it deduplicates on disk
//!
//! A gateway retries a webhook until it is acknowledged, and a network that
//! drops the acknowledgement delivers the same payment twice. [`Receiver`]
//! verifies the signature (each driver knows its own scheme), records the
//! event by the *gateway's* id, and hands a duplicate straight back as already
//! handled. That record must survive a restart: a duplicate that arrives after
//! a deploy is still a duplicate, and crediting it twice is a refund
//! conversation. So the log is a trait with a table-backed implementation
//! behind the `db` feature, and the in-memory one is for tests.
//!
//! # No driver is invented
//!
//! [`FakeGateway`] is the only driver here today. A driver for a real gateway
//! is written against that gateway's published specification, not from what
//! its competitors do — an adapter written from guesses is code that looks
//! finished and fails on the first real callback.
pub use ;
pub use ;
pub use FakeGateway;
pub use ;
pub use Money;
pub use ;
pub use ;
pub use ;
pub use ;