@birtalanrobert/commerce 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +601 -0
- package/LICENSE +661 -0
- package/NOTICE +45 -0
- package/README.md +79 -0
- package/dist/deposits.d.ts +52 -0
- package/dist/deposits.d.ts.map +1 -0
- package/dist/deposits.js +71 -0
- package/dist/deposits.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/1789800000000-CreateCommerce.d.ts +38 -0
- package/dist/migrations/1789800000000-CreateCommerce.d.ts.map +1 -0
- package/dist/migrations/1789800000000-CreateCommerce.js +152 -0
- package/dist/migrations/1789800000000-CreateCommerce.js.map +1 -0
- package/dist/nestjs/commerce.service.d.ts +122 -0
- package/dist/nestjs/commerce.service.d.ts.map +1 -0
- package/dist/nestjs/commerce.service.js +337 -0
- package/dist/nestjs/commerce.service.js.map +1 -0
- package/dist/nestjs/index.d.ts +18 -0
- package/dist/nestjs/index.d.ts.map +1 -0
- package/dist/nestjs/index.js +27 -0
- package/dist/nestjs/index.js.map +1 -0
- package/dist/nestjs/payment.entity.d.ts +94 -0
- package/dist/nestjs/payment.entity.d.ts.map +1 -0
- package/dist/nestjs/payment.entity.js +181 -0
- package/dist/nestjs/payment.entity.js.map +1 -0
- package/dist/nestjs/payout-account.entity.d.ts +41 -0
- package/dist/nestjs/payout-account.entity.d.ts.map +1 -0
- package/dist/nestjs/payout-account.entity.js +83 -0
- package/dist/nestjs/payout-account.entity.js.map +1 -0
- package/dist/providers/port.d.ts +97 -0
- package/dist/providers/port.d.ts.map +1 -0
- package/dist/providers/port.js +16 -0
- package/dist/providers/port.js.map +1 -0
- package/dist/providers/stripe.d.ts +39 -0
- package/dist/providers/stripe.d.ts.map +1 -0
- package/dist/providers/stripe.js +221 -0
- package/dist/providers/stripe.js.map +1 -0
- package/nestjs/package.json +5 -0
- package/package.json +49 -0
- package/src/deposits.ts +96 -0
- package/src/index.ts +40 -0
- package/src/migrations/1789800000000-CreateCommerce.ts +156 -0
- package/src/nestjs/commerce.service.ts +476 -0
- package/src/nestjs/index.ts +24 -0
- package/src/nestjs/payment.entity.ts +150 -0
- package/src/nestjs/payout-account.entity.ts +56 -0
- package/src/providers/port.ts +108 -0
- package/src/providers/stripe.ts +274 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CommerceService = exports.COMMERCE_PROVIDER = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const database_1 = require("@birtalanrobert/database");
|
|
18
|
+
const tenancy_1 = require("@birtalanrobert/tenancy");
|
|
19
|
+
const context_1 = require("@birtalanrobert/context");
|
|
20
|
+
const http_1 = require("@birtalanrobert/http");
|
|
21
|
+
const deposits_1 = require("../deposits");
|
|
22
|
+
const payout_account_entity_1 = require("./payout-account.entity");
|
|
23
|
+
const payment_entity_1 = require("./payment.entity");
|
|
24
|
+
/** The provider this deployment uses, injected so tests can supply their own. */
|
|
25
|
+
exports.COMMERCE_PROVIDER = Symbol('COMMERCE_PROVIDER');
|
|
26
|
+
/**
|
|
27
|
+
* Money between a customer and a business, and the record of it.
|
|
28
|
+
*
|
|
29
|
+
* **We never hold their funds** — the customer pays the business directly and
|
|
30
|
+
* our fee is taken on top — so almost everything here is about the *record*
|
|
31
|
+
* rather than the movement. That record has to be complete enough to produce a
|
|
32
|
+
* business's own takings years later, after the provider account is closed.
|
|
33
|
+
*
|
|
34
|
+
* Every method runs inside the tenant's policy, reads included: these tables are
|
|
35
|
+
* under row-level security, and an unbound read returns *nothing* rather than
|
|
36
|
+
* failing — which here means a revenue report of zero for a business that took
|
|
37
|
+
* money all month.
|
|
38
|
+
*/
|
|
39
|
+
let CommerceService = class CommerceService {
|
|
40
|
+
dataSource;
|
|
41
|
+
provider;
|
|
42
|
+
constructor(dataSource, provider) {
|
|
43
|
+
this.dataSource = dataSource;
|
|
44
|
+
this.provider = provider;
|
|
45
|
+
}
|
|
46
|
+
// ── Getting paid at all ──────────────────────────────────────────────────
|
|
47
|
+
/** Where a business's money goes, and whether the provider will send it yet. */
|
|
48
|
+
async payoutAccount(tenantId) {
|
|
49
|
+
return (0, tenancy_1.runInTenantTransaction)(this.dataSource, (scoped) => scoped
|
|
50
|
+
.getRepository(payout_account_entity_1.PayoutAccount)
|
|
51
|
+
.findOne({ where: { tenantId, provider: this.provider.name } }), { tenantId });
|
|
52
|
+
}
|
|
53
|
+
async payoutStatus(tenantId) {
|
|
54
|
+
return (await this.payoutAccount(tenantId))?.status ?? 'none';
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Starts or resumes onboarding, creating the provider's account if needed.
|
|
58
|
+
*
|
|
59
|
+
* Called again as often as somebody presses the button: onboarding is a form
|
|
60
|
+
* people abandon and come back to, and the link is short-lived, so "resume"
|
|
61
|
+
* is the common case rather than the exception.
|
|
62
|
+
*/
|
|
63
|
+
async startOnboarding(tenantId, options) {
|
|
64
|
+
const existing = await this.payoutAccount(tenantId);
|
|
65
|
+
const account = await this.provider.account(existing?.externalId ?? null, options.country, options.email);
|
|
66
|
+
await this.saveAccount(tenantId, account);
|
|
67
|
+
return this.provider.onboard(account.externalId, options.returnUrl, options.refreshUrl);
|
|
68
|
+
}
|
|
69
|
+
/** Asks the provider where onboarding stands, and records the answer. */
|
|
70
|
+
async refreshPayoutAccount(tenantId) {
|
|
71
|
+
const existing = await this.payoutAccount(tenantId);
|
|
72
|
+
if (!existing)
|
|
73
|
+
return 'none';
|
|
74
|
+
const account = await this.provider.account(existing.externalId, 'RO');
|
|
75
|
+
await this.saveAccount(tenantId, account);
|
|
76
|
+
return account.status;
|
|
77
|
+
}
|
|
78
|
+
// ── Taking money ─────────────────────────────────────────────────────────
|
|
79
|
+
/**
|
|
80
|
+
* Charges a card, or holds one.
|
|
81
|
+
*
|
|
82
|
+
* Refused before the provider is called if the business cannot be paid out:
|
|
83
|
+
* a charge that succeeds into an account with no destination leaves the
|
|
84
|
+
* customer debited and the money nowhere anybody can see it, and the first
|
|
85
|
+
* the business hears is asking where it went.
|
|
86
|
+
*/
|
|
87
|
+
async take(tenantId, input) {
|
|
88
|
+
const account = await this.payoutAccount(tenantId);
|
|
89
|
+
if (!account || !(0, deposits_1.canTakeMoney)(account.status)) {
|
|
90
|
+
throw new http_1.ConflictError('This business cannot take card payments yet.');
|
|
91
|
+
}
|
|
92
|
+
if (input.amount <= 0) {
|
|
93
|
+
throw new http_1.ValidationError([{ field: 'amount', message: 'There is nothing to charge.' }], 'There is nothing to charge.');
|
|
94
|
+
}
|
|
95
|
+
const result = await this.provider.charge({
|
|
96
|
+
account: account.externalId,
|
|
97
|
+
amount: input.amount,
|
|
98
|
+
currency: input.currency,
|
|
99
|
+
applicationFee: input.applicationFee ?? 0,
|
|
100
|
+
subject: input.subject,
|
|
101
|
+
capture: input.capture ?? true,
|
|
102
|
+
...(input.description ? { description: input.description } : {}),
|
|
103
|
+
reference: input.reference,
|
|
104
|
+
});
|
|
105
|
+
return (0, tenancy_1.runInTenantTransaction)(this.dataSource, async (scoped) => {
|
|
106
|
+
const repository = scoped.getRepository(payment_entity_1.Payment);
|
|
107
|
+
return repository.save(repository.create({
|
|
108
|
+
tenantId,
|
|
109
|
+
subject: input.subject,
|
|
110
|
+
method: 'card',
|
|
111
|
+
state: result.state,
|
|
112
|
+
amount: String(input.amount),
|
|
113
|
+
currency: input.currency,
|
|
114
|
+
applicationFee: String(input.applicationFee ?? 0),
|
|
115
|
+
refunded: '0',
|
|
116
|
+
provider: this.provider.name,
|
|
117
|
+
externalId: result.externalId || null,
|
|
118
|
+
instrument: result.instrument ?? null,
|
|
119
|
+
// Only when the money actually moved. A hold has not moved it, and
|
|
120
|
+
// a report that counted holds would overstate a business's takings.
|
|
121
|
+
takenAt: result.state === 'captured' ? new Date() : null,
|
|
122
|
+
detail: result.detail ?? null,
|
|
123
|
+
recordedBy: (0, context_1.getActor)()?.id ?? null,
|
|
124
|
+
}));
|
|
125
|
+
}, { tenantId });
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Writes down money that arrived some other way.
|
|
129
|
+
*
|
|
130
|
+
* Cash at the counter, a card terminal, a meal voucher, a bank transfer.
|
|
131
|
+
* **Recording is not a lesser feature**: a salon is mostly cash, a restaurant
|
|
132
|
+
* takes vouchers, a box office takes notes — and a report that counted only
|
|
133
|
+
* what a provider processed would tell a business a fraction of its own
|
|
134
|
+
* takings while looking complete.
|
|
135
|
+
*/
|
|
136
|
+
async record(tenantId, input) {
|
|
137
|
+
if (input.amount <= 0) {
|
|
138
|
+
throw new http_1.ValidationError([{ field: 'amount', message: 'There is nothing to record.' }], 'There is nothing to record.');
|
|
139
|
+
}
|
|
140
|
+
return (0, tenancy_1.runInTenantTransaction)(this.dataSource, async (scoped) => {
|
|
141
|
+
const repository = scoped.getRepository(payment_entity_1.Payment);
|
|
142
|
+
return repository.save(repository.create({
|
|
143
|
+
tenantId,
|
|
144
|
+
subject: input.subject,
|
|
145
|
+
method: input.method,
|
|
146
|
+
// Captured immediately: the money is in the till. There is no
|
|
147
|
+
// provider to wait for and nothing that can fail later.
|
|
148
|
+
state: 'captured',
|
|
149
|
+
amount: String(input.amount),
|
|
150
|
+
currency: input.currency,
|
|
151
|
+
applicationFee: '0',
|
|
152
|
+
refunded: '0',
|
|
153
|
+
provider: null,
|
|
154
|
+
externalId: null,
|
|
155
|
+
takenAt: new Date(),
|
|
156
|
+
detail: input.detail ?? null,
|
|
157
|
+
// Who wrote it down, because a cash payment has no other evidence.
|
|
158
|
+
recordedBy: (0, context_1.getActor)()?.id ?? null,
|
|
159
|
+
}));
|
|
160
|
+
}, { tenantId });
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Takes money that was only held.
|
|
164
|
+
*
|
|
165
|
+
* **The human decision has been made by the time this is called.** Charging a
|
|
166
|
+
* no-show fee automatically is how a business loses that customer
|
|
167
|
+
* permanently, so this package offers the mechanism and never the trigger.
|
|
168
|
+
*/
|
|
169
|
+
async capture(tenantId, paymentId, amount) {
|
|
170
|
+
const payment = await this.find(tenantId, paymentId);
|
|
171
|
+
if (payment.state !== 'authorized' || !payment.externalId) {
|
|
172
|
+
throw new http_1.ConflictError('That payment is not being held.');
|
|
173
|
+
}
|
|
174
|
+
const result = await this.provider.capture(payment.externalId, amount);
|
|
175
|
+
return this.update(tenantId, paymentId, {
|
|
176
|
+
state: result.state,
|
|
177
|
+
takenAt: result.state === 'captured' ? new Date() : null,
|
|
178
|
+
...(amount === undefined ? {} : { amount: String(amount) }),
|
|
179
|
+
detail: result.detail ?? null,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/** Lets a held card go without taking anything. */
|
|
183
|
+
async release(tenantId, paymentId) {
|
|
184
|
+
const payment = await this.find(tenantId, paymentId);
|
|
185
|
+
if (payment.state !== 'authorized' || !payment.externalId) {
|
|
186
|
+
throw new http_1.ConflictError('That payment is not being held.');
|
|
187
|
+
}
|
|
188
|
+
await this.provider.release(payment.externalId);
|
|
189
|
+
return this.update(tenantId, paymentId, { state: 'cancelled' });
|
|
190
|
+
}
|
|
191
|
+
// ── Giving it back ───────────────────────────────────────────────────────
|
|
192
|
+
/**
|
|
193
|
+
* Refunds some or all of a payment, with a reason.
|
|
194
|
+
*
|
|
195
|
+
* The reason is required because "we refunded her ninety lei in March" is a
|
|
196
|
+
* question somebody asks a year later, and a blank answer cannot be defended.
|
|
197
|
+
*/
|
|
198
|
+
async refund(tenantId, paymentId, amount, reason) {
|
|
199
|
+
const payment = await this.find(tenantId, paymentId);
|
|
200
|
+
if (payment.state !== 'captured' && payment.state !== 'partially_refunded') {
|
|
201
|
+
throw new http_1.ConflictError('That payment cannot be refunded.');
|
|
202
|
+
}
|
|
203
|
+
const already = Number(payment.refunded);
|
|
204
|
+
const remaining = Number(payment.amount) - already;
|
|
205
|
+
if (amount <= 0 || amount > remaining) {
|
|
206
|
+
throw new http_1.ValidationError([{ field: 'amount', message: `At most ${remaining} can be given back.` }], `At most ${remaining} can be given back.`);
|
|
207
|
+
}
|
|
208
|
+
/*
|
|
209
|
+
* The provider first, then the record.
|
|
210
|
+
*
|
|
211
|
+
* A row saying money was returned when it was not is worse than no row: it
|
|
212
|
+
* is an answer to "did she get it back" that happens to be wrong, and the
|
|
213
|
+
* customer is the one who finds out.
|
|
214
|
+
*/
|
|
215
|
+
const external = payment.externalId
|
|
216
|
+
? await this.provider.refund({
|
|
217
|
+
externalId: payment.externalId,
|
|
218
|
+
amount,
|
|
219
|
+
reason,
|
|
220
|
+
reference: `${paymentId}-${already + amount}`,
|
|
221
|
+
})
|
|
222
|
+
: null;
|
|
223
|
+
return (0, tenancy_1.runInTenantTransaction)(this.dataSource, async (scoped) => {
|
|
224
|
+
const refunds = scoped.getRepository(payment_entity_1.PaymentRefund);
|
|
225
|
+
await refunds.save(refunds.create({
|
|
226
|
+
tenantId,
|
|
227
|
+
paymentId,
|
|
228
|
+
amount: String(amount),
|
|
229
|
+
reason,
|
|
230
|
+
externalId: external?.externalId ?? null,
|
|
231
|
+
refundedBy: (0, context_1.getActor)()?.id ?? null,
|
|
232
|
+
}));
|
|
233
|
+
const total = already + amount;
|
|
234
|
+
await scoped.getRepository(payment_entity_1.Payment).update({ id: paymentId, tenantId }, {
|
|
235
|
+
refunded: String(total),
|
|
236
|
+
state: total >= Number(payment.amount) ? 'refunded' : 'partially_refunded',
|
|
237
|
+
});
|
|
238
|
+
return scoped.getRepository(payment_entity_1.Payment).findOneOrFail({ where: { id: paymentId, tenantId } });
|
|
239
|
+
}, { tenantId });
|
|
240
|
+
}
|
|
241
|
+
// ── Reading ──────────────────────────────────────────────────────────────
|
|
242
|
+
/** Everything taken for one thing: a booking, an order, a tab. */
|
|
243
|
+
async forSubject(tenantId, subject) {
|
|
244
|
+
return (0, tenancy_1.runInTenantTransaction)(this.dataSource, (scoped) => scoped
|
|
245
|
+
.getRepository(payment_entity_1.Payment)
|
|
246
|
+
.find({ where: { tenantId, subject }, order: { createdAt: 'ASC' } }), { tenantId });
|
|
247
|
+
}
|
|
248
|
+
/** What a payment has had given back, and why. */
|
|
249
|
+
async refundsFor(tenantId, paymentId) {
|
|
250
|
+
return (0, tenancy_1.runInTenantTransaction)(this.dataSource, (scoped) => scoped
|
|
251
|
+
.getRepository(payment_entity_1.PaymentRefund)
|
|
252
|
+
.find({ where: { tenantId, paymentId }, order: { createdAt: 'ASC' } }), { tenantId });
|
|
253
|
+
}
|
|
254
|
+
// ── What the provider says afterwards ────────────────────────────────────
|
|
255
|
+
/**
|
|
256
|
+
* Records what a webhook said, whatever it was about.
|
|
257
|
+
*
|
|
258
|
+
* A payment the deployment has no record of is **ignored rather than
|
|
259
|
+
* inserted**: it belongs to another environment sharing the provider account,
|
|
260
|
+
* and inventing a row for it would put another system's money in this one's
|
|
261
|
+
* books.
|
|
262
|
+
*/
|
|
263
|
+
async settle(event) {
|
|
264
|
+
if (event.kind === 'account' && event.accountStatus) {
|
|
265
|
+
const rows = await this.dataSource.query(`SELECT "tenant_id" FROM "mortar_payout_accounts" WHERE "external_id" = $1`, [event.externalId]);
|
|
266
|
+
const tenantId = rows[0]?.tenant_id;
|
|
267
|
+
if (!tenantId)
|
|
268
|
+
return undefined;
|
|
269
|
+
await this.saveAccount(tenantId, event.accountStatus);
|
|
270
|
+
return (await this.payoutAccount(tenantId)) ?? undefined;
|
|
271
|
+
}
|
|
272
|
+
if (event.kind !== 'payment' || !event.state)
|
|
273
|
+
return undefined;
|
|
274
|
+
/*
|
|
275
|
+
* Found by the provider's identifier, which is the only thing both sides
|
|
276
|
+
* share — and read without a tenant because a webhook does not carry one.
|
|
277
|
+
* The row itself says whose it is.
|
|
278
|
+
*/
|
|
279
|
+
const rows = await this.dataSource.query(`SELECT "id", "tenant_id" FROM "mortar_payments" WHERE "external_id" = $1`, [event.externalId]);
|
|
280
|
+
const found = rows[0];
|
|
281
|
+
if (!found)
|
|
282
|
+
return undefined;
|
|
283
|
+
const state = event.state === 'refunded' ? 'refunded' : event.state;
|
|
284
|
+
return this.update(found.tenant_id, found.id, {
|
|
285
|
+
state,
|
|
286
|
+
...(state === 'captured' ? { takenAt: new Date() } : {}),
|
|
287
|
+
...(event.instrument ? { instrument: event.instrument } : {}),
|
|
288
|
+
...(event.detail ? { detail: event.detail } : {}),
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
// ── Internals ────────────────────────────────────────────────────────────
|
|
292
|
+
async find(tenantId, paymentId) {
|
|
293
|
+
const payment = await (0, tenancy_1.runInTenantTransaction)(this.dataSource, (scoped) => scoped.getRepository(payment_entity_1.Payment).findOne({ where: { id: paymentId, tenantId } }), { tenantId });
|
|
294
|
+
if (!payment)
|
|
295
|
+
throw new http_1.NotFoundError('Payment', paymentId);
|
|
296
|
+
return payment;
|
|
297
|
+
}
|
|
298
|
+
async update(tenantId, paymentId, patch, manager) {
|
|
299
|
+
const work = async (scoped) => {
|
|
300
|
+
await scoped.getRepository(payment_entity_1.Payment).update({ id: paymentId, tenantId }, patch);
|
|
301
|
+
return scoped.getRepository(payment_entity_1.Payment).findOneOrFail({ where: { id: paymentId, tenantId } });
|
|
302
|
+
};
|
|
303
|
+
return manager ? work(manager) : (0, tenancy_1.runInTenantTransaction)(this.dataSource, work, { tenantId });
|
|
304
|
+
}
|
|
305
|
+
async saveAccount(tenantId, account) {
|
|
306
|
+
await (0, tenancy_1.runInTenantTransaction)(this.dataSource, async (scoped) => {
|
|
307
|
+
await scoped.query(`INSERT INTO "mortar_payout_accounts"
|
|
308
|
+
("tenant_id", "provider", "external_id", "status", "requirements", "ready_at")
|
|
309
|
+
VALUES ($1, $2, $3, $4, $5::jsonb, $6)
|
|
310
|
+
ON CONFLICT ("tenant_id", "provider")
|
|
311
|
+
DO UPDATE SET "external_id" = EXCLUDED."external_id",
|
|
312
|
+
"status" = EXCLUDED."status",
|
|
313
|
+
"requirements" = EXCLUDED."requirements",
|
|
314
|
+
-- Set once and never cleared: the first time a
|
|
315
|
+
-- provider agreed to pay a business out is a date
|
|
316
|
+
-- worth keeping, and a later restriction does not
|
|
317
|
+
-- unmake it.
|
|
318
|
+
"ready_at" = COALESCE("mortar_payout_accounts"."ready_at", EXCLUDED."ready_at"),
|
|
319
|
+
"updated_at" = now()`, [
|
|
320
|
+
tenantId,
|
|
321
|
+
this.provider.name,
|
|
322
|
+
account.externalId,
|
|
323
|
+
account.status,
|
|
324
|
+
JSON.stringify([...account.requirements]),
|
|
325
|
+
account.status === 'ready' ? new Date() : null,
|
|
326
|
+
]);
|
|
327
|
+
}, { tenantId });
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
exports.CommerceService = CommerceService;
|
|
331
|
+
exports.CommerceService = CommerceService = __decorate([
|
|
332
|
+
(0, common_1.Injectable)(),
|
|
333
|
+
__param(0, (0, database_1.InjectDataSource)()),
|
|
334
|
+
__param(1, (0, common_1.Inject)(exports.COMMERCE_PROVIDER)),
|
|
335
|
+
__metadata("design:paramtypes", [Function, Object])
|
|
336
|
+
], CommerceService);
|
|
337
|
+
//# sourceMappingURL=commerce.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commerce.service.js","sourceRoot":"","sources":["../../src/nestjs/commerce.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,uDAA4D;AAC5D,qDAAiE;AACjE,qDAAmD;AACnD,+CAAqF;AACrF,0CAA8D;AAE9D,mEAAwD;AACxD,qDAA8E;AAE9E,iFAAiF;AACpE,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AA2B7D;;;;;;;;;;;;GAYG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAEa;IACO;IAF9C,YACuC,UAAsB,EACf,QAAyB;QADhC,eAAU,GAAV,UAAU,CAAY;QACf,aAAQ,GAAR,QAAQ,CAAiB;IACpE,CAAC;IAEJ,4EAA4E;IAE5E,gFAAgF;IAChF,KAAK,CAAC,aAAa,CAAC,QAAgB;QAClC,OAAO,IAAA,gCAAsB,EAC3B,IAAI,CAAC,UAAU,EACf,CAAC,MAAM,EAAE,EAAE,CACT,MAAM;aACH,aAAa,CAAC,qCAAa,CAAC;aAC5B,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,EACnE,EAAE,QAAQ,EAAE,CACb,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAgB;QACjC,OAAO,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,IAAI,MAAM,CAAC;IAChE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CACnB,QAAgB,EAChB,OAAmF;QAEnF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QA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AtaY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,2BAAgB,GAAE,CAAA;IAClB,WAAA,IAAA,eAAM,EAAC,yBAAiB,CAAC,CAAA;;GAHjB,eAAe,CAsa3B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts that need a database and a container.
|
|
3
|
+
*
|
|
4
|
+
* Separate from the root entry point so that working out a deposit — which a
|
|
5
|
+
* console does while somebody drags a slider — does not drag TypeORM into a
|
|
6
|
+
* browser bundle.
|
|
7
|
+
*/
|
|
8
|
+
export { PayoutAccount } from './payout-account.entity';
|
|
9
|
+
export { Payment, PaymentRefund, type PaymentMethod, type PaymentState } from './payment.entity';
|
|
10
|
+
export { COMMERCE_PROVIDER, CommerceService, type RecordPayment, type TakePayment, } from './commerce.service';
|
|
11
|
+
export { CreateCommerce1789800000000 } from '../migrations/1789800000000-CreateCommerce';
|
|
12
|
+
import { PayoutAccount } from './payout-account.entity';
|
|
13
|
+
import { Payment, PaymentRefund } from './payment.entity';
|
|
14
|
+
import { CreateCommerce1789800000000 } from '../migrations/1789800000000-CreateCommerce';
|
|
15
|
+
/** Register with the data source, the way every other mortar package is. */
|
|
16
|
+
export declare const commerceEntities: (typeof PayoutAccount | typeof Payment | typeof PaymentRefund)[];
|
|
17
|
+
export declare const commerceMigrations: (typeof CreateCommerce1789800000000)[];
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nestjs/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,WAAW,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,kEAA0C,CAAC;AACxE,eAAO,MAAM,kBAAkB,wCAAgC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commerceMigrations = exports.commerceEntities = exports.CreateCommerce1789800000000 = exports.CommerceService = exports.COMMERCE_PROVIDER = exports.PaymentRefund = exports.Payment = exports.PayoutAccount = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The parts that need a database and a container.
|
|
6
|
+
*
|
|
7
|
+
* Separate from the root entry point so that working out a deposit — which a
|
|
8
|
+
* console does while somebody drags a slider — does not drag TypeORM into a
|
|
9
|
+
* browser bundle.
|
|
10
|
+
*/
|
|
11
|
+
var payout_account_entity_1 = require("./payout-account.entity");
|
|
12
|
+
Object.defineProperty(exports, "PayoutAccount", { enumerable: true, get: function () { return payout_account_entity_1.PayoutAccount; } });
|
|
13
|
+
var payment_entity_1 = require("./payment.entity");
|
|
14
|
+
Object.defineProperty(exports, "Payment", { enumerable: true, get: function () { return payment_entity_1.Payment; } });
|
|
15
|
+
Object.defineProperty(exports, "PaymentRefund", { enumerable: true, get: function () { return payment_entity_1.PaymentRefund; } });
|
|
16
|
+
var commerce_service_1 = require("./commerce.service");
|
|
17
|
+
Object.defineProperty(exports, "COMMERCE_PROVIDER", { enumerable: true, get: function () { return commerce_service_1.COMMERCE_PROVIDER; } });
|
|
18
|
+
Object.defineProperty(exports, "CommerceService", { enumerable: true, get: function () { return commerce_service_1.CommerceService; } });
|
|
19
|
+
var _1789800000000_CreateCommerce_1 = require("../migrations/1789800000000-CreateCommerce");
|
|
20
|
+
Object.defineProperty(exports, "CreateCommerce1789800000000", { enumerable: true, get: function () { return _1789800000000_CreateCommerce_1.CreateCommerce1789800000000; } });
|
|
21
|
+
const payout_account_entity_2 = require("./payout-account.entity");
|
|
22
|
+
const payment_entity_2 = require("./payment.entity");
|
|
23
|
+
const _1789800000000_CreateCommerce_2 = require("../migrations/1789800000000-CreateCommerce");
|
|
24
|
+
/** Register with the data source, the way every other mortar package is. */
|
|
25
|
+
exports.commerceEntities = [payout_account_entity_2.PayoutAccount, payment_entity_2.Payment, payment_entity_2.PaymentRefund];
|
|
26
|
+
exports.commerceMigrations = [_1789800000000_CreateCommerce_2.CreateCommerce1789800000000];
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nestjs/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,iEAAwD;AAA/C,sHAAA,aAAa,OAAA;AACtB,mDAAiG;AAAxF,yGAAA,OAAO,OAAA;AAAE,+GAAA,aAAa,OAAA;AAC/B,uDAK4B;AAJ1B,qHAAA,iBAAiB,OAAA;AACjB,mHAAA,eAAe,OAAA;AAIjB,4FAAyF;AAAhF,4IAAA,2BAA2B,OAAA;AAEpC,mEAAwD;AACxD,qDAA0D;AAC1D,8FAAyF;AAEzF,4EAA4E;AAC/D,QAAA,gBAAgB,GAAG,CAAC,qCAAa,EAAE,wBAAO,EAAE,8BAAa,CAAC,CAAC;AAC3D,QAAA,kBAAkB,GAAG,CAAC,2DAA2B,CAAC,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { BaseEntity } from '@birtalanrobert/database';
|
|
2
|
+
/**
|
|
3
|
+
* How the money arrived.
|
|
4
|
+
*
|
|
5
|
+
* `card` is the only one this package processes. The rest are **recorded, not
|
|
6
|
+
* taken** — and recording them is not a lesser feature: a salon is mostly cash
|
|
7
|
+
* at the counter, a restaurant's till takes meal vouchers, and a box office
|
|
8
|
+
* takes notes. A report that only counts what a provider processed tells a
|
|
9
|
+
* business a fraction of its own takings, which is worse than telling it
|
|
10
|
+
* nothing because it looks complete.
|
|
11
|
+
*/
|
|
12
|
+
export type PaymentMethod = 'card' | 'cash' | 'terminal' | 'voucher' | 'transfer';
|
|
13
|
+
/**
|
|
14
|
+
* Where a payment is.
|
|
15
|
+
*
|
|
16
|
+
* `authorized` is separate from `captured` on purpose: a card held against a
|
|
17
|
+
* no-show fee is authorised and never captured unless the fee is applied, and
|
|
18
|
+
* that decision is a human one.
|
|
19
|
+
*/
|
|
20
|
+
export type PaymentState = 'pending' | 'authorized' | 'captured' | 'failed' | 'refunded' | 'partially_refunded' | 'cancelled';
|
|
21
|
+
/**
|
|
22
|
+
* One movement of money between a customer and a business.
|
|
23
|
+
*
|
|
24
|
+
* **The record outlives the provider.** Amounts, dates, what it was for and who
|
|
25
|
+
* decided are all here in full rather than as identifiers to fetch: a business
|
|
26
|
+
* has to be able to produce its own takings years later, when the provider
|
|
27
|
+
* account may be closed, the API version retired, or the vendor replaced.
|
|
28
|
+
*
|
|
29
|
+
* There is deliberately **no foreign key to the subject**. One product takes a
|
|
30
|
+
* deposit against an appointment, another against a seat, a third against a
|
|
31
|
+
* table's tab — and a key to any one of them is precisely what would stop this
|
|
32
|
+
* table being shared.
|
|
33
|
+
*/
|
|
34
|
+
export declare class Payment extends BaseEntity {
|
|
35
|
+
tenantId: string;
|
|
36
|
+
/** What it was for, as the owning product names it: `booking:<id>`. */
|
|
37
|
+
subject: string;
|
|
38
|
+
method: PaymentMethod;
|
|
39
|
+
state: PaymentState;
|
|
40
|
+
/** Minor units, and the currency it was taken in. Never a float. */
|
|
41
|
+
amount: string;
|
|
42
|
+
currency: string;
|
|
43
|
+
/**
|
|
44
|
+
* Our cut, taken on top rather than out of the business's money.
|
|
45
|
+
*
|
|
46
|
+
* Recorded even when zero, because "this product charged nothing for that
|
|
47
|
+
* transaction" and "nobody wrote down what it charged" are different facts
|
|
48
|
+
* and only one of them survives an argument.
|
|
49
|
+
*/
|
|
50
|
+
applicationFee: string;
|
|
51
|
+
/** Sum of everything given back. Never more than `amount`. */
|
|
52
|
+
refunded: string;
|
|
53
|
+
provider: string | null;
|
|
54
|
+
/** The provider's identifier, which is what a webhook arrives carrying. */
|
|
55
|
+
externalId: string | null;
|
|
56
|
+
/**
|
|
57
|
+
* The last four digits and the brand, for a person to recognise it by.
|
|
58
|
+
*
|
|
59
|
+
* Never the number, never a token that could be charged from a database
|
|
60
|
+
* dump. What a receptionist needs is "Visa ending 4242", and what a customer
|
|
61
|
+
* needs is to know which of their cards was used.
|
|
62
|
+
*/
|
|
63
|
+
instrument: string | null;
|
|
64
|
+
/** When the money actually moved, which is not when the row was created. */
|
|
65
|
+
takenAt: Date | null;
|
|
66
|
+
/** Why it failed, or what a person recorded about a cash payment. */
|
|
67
|
+
detail: string | null;
|
|
68
|
+
/** Who recorded it, for the payments a person entered by hand. */
|
|
69
|
+
recordedBy: string | null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Money given back, one row per act of giving it.
|
|
73
|
+
*
|
|
74
|
+
* Several partial refunds against one payment is ordinary — a deposit returned
|
|
75
|
+
* in part, a ticket refunded and its fee kept — and a single `refunded` column
|
|
76
|
+
* cannot say when each happened or why. The column stays as the running total,
|
|
77
|
+
* because that is what every read wants, and these rows are what explain it.
|
|
78
|
+
*/
|
|
79
|
+
export declare class PaymentRefund extends BaseEntity {
|
|
80
|
+
tenantId: string;
|
|
81
|
+
paymentId: string;
|
|
82
|
+
amount: string;
|
|
83
|
+
/**
|
|
84
|
+
* Why, in the words of whoever decided.
|
|
85
|
+
*
|
|
86
|
+
* Required rather than optional: "we refunded her ninety lei in March" is a
|
|
87
|
+
* question somebody asks a year later, and a blank reason is an answer
|
|
88
|
+
* nobody can defend.
|
|
89
|
+
*/
|
|
90
|
+
reason: string;
|
|
91
|
+
externalId: string | null;
|
|
92
|
+
refundedBy: string | null;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=payment.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.entity.d.ts","sourceRoot":"","sources":["../../src/nestjs/payment.entity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAuB,MAAM,0BAA0B,CAAC;AAE3E;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AAElF;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,UAAU,GACV,oBAAoB,GACpB,WAAW,CAAC;AAEhB;;;;;;;;;;;;GAYG;AACH,qBAKa,OAAQ,SAAQ,UAAU;IAErC,QAAQ,EAAG,MAAM,CAAC;IAElB,uEAAuE;IAEvE,OAAO,EAAG,MAAM,CAAC;IAGjB,MAAM,EAAG,aAAa,CAAC;IAGvB,KAAK,EAAG,YAAY,CAAC;IAErB,oEAAoE;IAEpE,MAAM,EAAG,MAAM,CAAC;IAGhB,QAAQ,EAAG,MAAM,CAAC;IAElB;;;;;;OAMG;IAEH,cAAc,EAAG,MAAM,CAAC;IAExB,8DAA8D;IAE9D,QAAQ,EAAG,MAAM,CAAC;IAGlB,QAAQ,EAAG,MAAM,GAAG,IAAI,CAAC;IAEzB,2EAA2E;IAE3E,UAAU,EAAG,MAAM,GAAG,IAAI,CAAC;IAE3B;;;;;;OAMG;IAEH,UAAU,EAAG,MAAM,GAAG,IAAI,CAAC;IAE3B,4EAA4E;IAE5E,OAAO,EAAG,IAAI,GAAG,IAAI,CAAC;IAEtB,qEAAqE;IAErE,MAAM,EAAG,MAAM,GAAG,IAAI,CAAC;IAEvB,kEAAkE;IAElE,UAAU,E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