@backendfree/payments 0.0.0-stage → 0.1.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/README.md +125 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/.tsbuildinfo 3 +1 -0
- package/dist/index 3.js +154 -0
- package/dist/index.d 3.ts +129 -0
- package/dist/index.d.ts +129 -0
- package/dist/index.d.ts 3.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +154 -0
- package/dist/index.js 3.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/types 3.js +16 -0
- package/dist/types.d 3.ts +110 -0
- package/dist/types.d.ts +112 -0
- package/dist/types.d.ts 3.map +1 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js 3.map +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -4
- package/src/index.ts +210 -0
- package/src/types.ts +123 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @backendfree/payments
|
|
3
|
+
*
|
|
4
|
+
* A project's money: what has been taken, and taking some.
|
|
5
|
+
*
|
|
6
|
+
* import { Client } from '@backendfree/core';
|
|
7
|
+
* import { Payments } from '@backendfree/payments';
|
|
8
|
+
*
|
|
9
|
+
* const payments = new Payments(new Client({ origin, key: process.env.SECRET_KEY }));
|
|
10
|
+
* const payment = await payments.checkout({ amount: 3500, success_url, cancel_url });
|
|
11
|
+
* redirect(payment.checkout_url);
|
|
12
|
+
*
|
|
13
|
+
* Four things are worth knowing before using it.
|
|
14
|
+
*
|
|
15
|
+
* **All of it needs a secret key, and this throws on a publishable one.** A
|
|
16
|
+
* payment carries the paying customer's name and email, and a checkout is a
|
|
17
|
+
* charge on somebody's bank account. Neither belongs in a bundle whoever loads
|
|
18
|
+
* the site can read, so the mistake is refused at construction rather than by a
|
|
19
|
+
* 403 in production.
|
|
20
|
+
*
|
|
21
|
+
* **There is no refund method, and that is deliberate.** Refunding is the one
|
|
22
|
+
* act that moves money out of the business's own account, and it lives in the
|
|
23
|
+
* payments screen in the dashboard, behind a capability only the account owner
|
|
24
|
+
* holds. A leaked key that can read payments is one incident; one that could
|
|
25
|
+
* refund would drain the account. See the README.
|
|
26
|
+
*
|
|
27
|
+
* **Nothing here says a payment was made.** A checkout is a page that exists.
|
|
28
|
+
* The provider's webhook is what says money moved, and the page the customer
|
|
29
|
+
* lands on afterwards says nothing at all. Read `payment.status` back, or
|
|
30
|
+
* better, take the platform's `payment.succeeded` webhook and verify it with
|
|
31
|
+
* `verifyWebhook` from core.
|
|
32
|
+
*
|
|
33
|
+
* **Money is minor units and a currency, everywhere.** 3500 is CHF 35.00.
|
|
34
|
+
* `formatMoney` turns that into something to show a person, and dividing by a
|
|
35
|
+
* hundred yourself is wrong in both directions depending on the currency.
|
|
36
|
+
*/
|
|
37
|
+
import type { Client, Page as Paginated, RequestOptions } from '@backendfree/core';
|
|
38
|
+
import type { CheckoutRequest, Money, Payment } from './types.js';
|
|
39
|
+
/** Which payments to list. Every filter is optional and they combine. */
|
|
40
|
+
export interface PaymentQuery extends RequestOptions {
|
|
41
|
+
status?: string;
|
|
42
|
+
/** For example `bookings.booking`. */
|
|
43
|
+
subject_type?: string;
|
|
44
|
+
/** That object's id, to answer "was this one paid for?". */
|
|
45
|
+
subject_id?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Where to send the customer, when offering a page for a payment that exists. */
|
|
48
|
+
export interface OfferOptions extends RequestOptions {
|
|
49
|
+
success_url: string;
|
|
50
|
+
cancel_url: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare class Payments {
|
|
54
|
+
#private;
|
|
55
|
+
constructor(client: Client);
|
|
56
|
+
/**
|
|
57
|
+
* Payments, newest first.
|
|
58
|
+
*
|
|
59
|
+
* Not cached, on purpose: a payment moves when the provider says so, and a
|
|
60
|
+
* stored answer would outlive the money it describes.
|
|
61
|
+
*/
|
|
62
|
+
list(query?: PaymentQuery): Promise<Paginated<Payment>>;
|
|
63
|
+
payment(id: string, options?: RequestOptions): Promise<Payment>;
|
|
64
|
+
/**
|
|
65
|
+
* Whether something on the platform has been paid for, in one call.
|
|
66
|
+
*
|
|
67
|
+
* What a booking confirmation page asks. Returns the payments against that
|
|
68
|
+
* object, because there can be more than one: a deposit and a balance, or a
|
|
69
|
+
* first attempt that failed and a second that did not.
|
|
70
|
+
*/
|
|
71
|
+
forSubject(subject_type: string, subject_id: string, options?: RequestOptions): Promise<Payment[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Open a payment page for one amount.
|
|
74
|
+
*
|
|
75
|
+
* An invoice, a deposit taken over the phone, a donation button. It settles
|
|
76
|
+
* nothing on the platform and names no booking, which is why it cannot be
|
|
77
|
+
* used to mark somebody else's appointment paid.
|
|
78
|
+
*
|
|
79
|
+
* Retrying this call is safe: core puts an idempotency key on it, and the
|
|
80
|
+
* same key is always the same charge. Pass your own order id as
|
|
81
|
+
* `idempotencyKey` to make a retry from another process count as the same
|
|
82
|
+
* request.
|
|
83
|
+
*
|
|
84
|
+
* A provider that refuses does not fail the call. The payment comes back with
|
|
85
|
+
* an empty `checkout_url` and the reason in `failure_message`, so the attempt
|
|
86
|
+
* is on record and you have an id to try again with. `offerAgain` is what
|
|
87
|
+
* tries again; calling this a second time would be a second payment for one
|
|
88
|
+
* order.
|
|
89
|
+
*/
|
|
90
|
+
checkout(request: CheckoutRequest, options?: RequestOptions): Promise<Payment>;
|
|
91
|
+
/**
|
|
92
|
+
* Offer the page again for a payment that already exists.
|
|
93
|
+
*
|
|
94
|
+
* What a customer needs when the provider refused, or when they closed the
|
|
95
|
+
* tab. Keyed on the payment rather than on a fresh idempotency key, so asking
|
|
96
|
+
* twice is one page.
|
|
97
|
+
*
|
|
98
|
+
* What is owed comes off the payment, never off this call: the price was
|
|
99
|
+
* agreed when the payment was made. A payment that is settled or over is
|
|
100
|
+
* answered rather than re-opened, because re-opening one is how somebody pays
|
|
101
|
+
* twice.
|
|
102
|
+
*/
|
|
103
|
+
offerAgain(id: string, options: OfferOptions): Promise<Payment>;
|
|
104
|
+
}
|
|
105
|
+
/** Whether the money arrived. True of a refunded payment too: it did arrive. */
|
|
106
|
+
export declare function hasPaid(payment: Payment): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Whether nothing further will happen to this payment.
|
|
109
|
+
*
|
|
110
|
+
* What decides whether offering the page again is worth anything. A failed,
|
|
111
|
+
* cancelled, expired or fully refunded payment is over; a created or pending
|
|
112
|
+
* one can still be paid.
|
|
113
|
+
*/
|
|
114
|
+
export declare function isOver(payment: Payment): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* An amount, written the way a person in a given place writes it.
|
|
117
|
+
*
|
|
118
|
+
* The one formatting helper worth shipping, for the same reason bookings ships
|
|
119
|
+
* one for time: the obvious version is wrong. Dividing by a hundred is right
|
|
120
|
+
* for CHF, wrong for JPY, which has no minor unit at all, and wrong the other
|
|
121
|
+
* way for KWD, which has three. The number of places comes from the currency
|
|
122
|
+
* rather than from a constant, so this is correct for currencies nobody thought
|
|
123
|
+
* about when writing it.
|
|
124
|
+
*
|
|
125
|
+
* `locales` defaults to the reader's own. Pass one to match a page's language.
|
|
126
|
+
*/
|
|
127
|
+
export declare function formatMoney(money: Money, locales?: string | string[]): string;
|
|
128
|
+
export type { CheckoutRequest, Money, Payment, PaymentStatus, Refund, RefundStatus, } from './types.js';
|
|
129
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,IAAI,SAAS,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvF,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM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BG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlF;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;CAQhE;AAID,gFAAgF;AAChF,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAMjD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAOhD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAI7E;AAED,YAAY,EACV,eAAe,EACf,KAAK,EACL,OAAO,EACP,aAAa,EACb,MAAM,EACN,YAAY,GACb,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @backendfree/payments
|
|
3
|
+
*
|
|
4
|
+
* A project's money: what has been taken, and taking some.
|
|
5
|
+
*
|
|
6
|
+
* import { Client } from '@backendfree/core';
|
|
7
|
+
* import { Payments } from '@backendfree/payments';
|
|
8
|
+
*
|
|
9
|
+
* const payments = new Payments(new Client({ origin, key: process.env.SECRET_KEY }));
|
|
10
|
+
* const payment = await payments.checkout({ amount: 3500, success_url, cancel_url });
|
|
11
|
+
* redirect(payment.checkout_url);
|
|
12
|
+
*
|
|
13
|
+
* Four things are worth knowing before using it.
|
|
14
|
+
*
|
|
15
|
+
* **All of it needs a secret key, and this throws on a publishable one.** A
|
|
16
|
+
* payment carries the paying customer's name and email, and a checkout is a
|
|
17
|
+
* charge on somebody's bank account. Neither belongs in a bundle whoever loads
|
|
18
|
+
* the site can read, so the mistake is refused at construction rather than by a
|
|
19
|
+
* 403 in production.
|
|
20
|
+
*
|
|
21
|
+
* **There is no refund method, and that is deliberate.** Refunding is the one
|
|
22
|
+
* act that moves money out of the business's own account, and it lives in the
|
|
23
|
+
* payments screen in the dashboard, behind a capability only the account owner
|
|
24
|
+
* holds. A leaked key that can read payments is one incident; one that could
|
|
25
|
+
* refund would drain the account. See the README.
|
|
26
|
+
*
|
|
27
|
+
* **Nothing here says a payment was made.** A checkout is a page that exists.
|
|
28
|
+
* The provider's webhook is what says money moved, and the page the customer
|
|
29
|
+
* lands on afterwards says nothing at all. Read `payment.status` back, or
|
|
30
|
+
* better, take the platform's `payment.succeeded` webhook and verify it with
|
|
31
|
+
* `verifyWebhook` from core.
|
|
32
|
+
*
|
|
33
|
+
* **Money is minor units and a currency, everywhere.** 3500 is CHF 35.00.
|
|
34
|
+
* `formatMoney` turns that into something to show a person, and dividing by a
|
|
35
|
+
* hundred yourself is wrong in both directions depending on the currency.
|
|
36
|
+
*/
|
|
37
|
+
import { ConfigError } from '@backendfree/core';
|
|
38
|
+
export class Payments {
|
|
39
|
+
#client;
|
|
40
|
+
constructor(client) {
|
|
41
|
+
// Refused here rather than by the API, because the answer is the same
|
|
42
|
+
// either way and finding out at construction is a stack trace pointing at
|
|
43
|
+
// the line that is wrong.
|
|
44
|
+
if (client.publishable) {
|
|
45
|
+
throw new ConfigError('secret_key_required', 'Payments needs a secret key. A payment carries a customer name and email and a ' +
|
|
46
|
+
'checkout is a charge on a bank account, so none of it is safe in a browser.');
|
|
47
|
+
}
|
|
48
|
+
this.#client = client;
|
|
49
|
+
}
|
|
50
|
+
// --- what has been taken -----------------------------------------------------
|
|
51
|
+
/**
|
|
52
|
+
* Payments, newest first.
|
|
53
|
+
*
|
|
54
|
+
* Not cached, on purpose: a payment moves when the provider says so, and a
|
|
55
|
+
* stored answer would outlive the money it describes.
|
|
56
|
+
*/
|
|
57
|
+
list(query = {}) {
|
|
58
|
+
const { status, subject_type, subject_id, ...rest } = query;
|
|
59
|
+
return this.#client.get('/payments', {
|
|
60
|
+
...rest,
|
|
61
|
+
query: { status, subject_type, subject_id, ...rest.query },
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
payment(id, options = {}) {
|
|
65
|
+
return this.#client.get(`/payments/${encodeURIComponent(id)}`, options);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Whether something on the platform has been paid for, in one call.
|
|
69
|
+
*
|
|
70
|
+
* What a booking confirmation page asks. Returns the payments against that
|
|
71
|
+
* object, because there can be more than one: a deposit and a balance, or a
|
|
72
|
+
* first attempt that failed and a second that did not.
|
|
73
|
+
*/
|
|
74
|
+
async forSubject(subject_type, subject_id, options = {}) {
|
|
75
|
+
const { results } = await this.list({ ...options, subject_type, subject_id });
|
|
76
|
+
return results;
|
|
77
|
+
}
|
|
78
|
+
// --- taking some -------------------------------------------------------------
|
|
79
|
+
/**
|
|
80
|
+
* Open a payment page for one amount.
|
|
81
|
+
*
|
|
82
|
+
* An invoice, a deposit taken over the phone, a donation button. It settles
|
|
83
|
+
* nothing on the platform and names no booking, which is why it cannot be
|
|
84
|
+
* used to mark somebody else's appointment paid.
|
|
85
|
+
*
|
|
86
|
+
* Retrying this call is safe: core puts an idempotency key on it, and the
|
|
87
|
+
* same key is always the same charge. Pass your own order id as
|
|
88
|
+
* `idempotencyKey` to make a retry from another process count as the same
|
|
89
|
+
* request.
|
|
90
|
+
*
|
|
91
|
+
* A provider that refuses does not fail the call. The payment comes back with
|
|
92
|
+
* an empty `checkout_url` and the reason in `failure_message`, so the attempt
|
|
93
|
+
* is on record and you have an id to try again with. `offerAgain` is what
|
|
94
|
+
* tries again; calling this a second time would be a second payment for one
|
|
95
|
+
* order.
|
|
96
|
+
*/
|
|
97
|
+
checkout(request, options = {}) {
|
|
98
|
+
return this.#client.post('/checkouts', request, options);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Offer the page again for a payment that already exists.
|
|
102
|
+
*
|
|
103
|
+
* What a customer needs when the provider refused, or when they closed the
|
|
104
|
+
* tab. Keyed on the payment rather than on a fresh idempotency key, so asking
|
|
105
|
+
* twice is one page.
|
|
106
|
+
*
|
|
107
|
+
* What is owed comes off the payment, never off this call: the price was
|
|
108
|
+
* agreed when the payment was made. A payment that is settled or over is
|
|
109
|
+
* answered rather than re-opened, because re-opening one is how somebody pays
|
|
110
|
+
* twice.
|
|
111
|
+
*/
|
|
112
|
+
offerAgain(id, options) {
|
|
113
|
+
const { success_url, cancel_url, description, ...rest } = options;
|
|
114
|
+
return this.#client.post(`/payments/${encodeURIComponent(id)}/checkout`, { success_url, cancel_url, description }, rest);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// --- reading a payment ---------------------------------------------------------
|
|
118
|
+
/** Whether the money arrived. True of a refunded payment too: it did arrive. */
|
|
119
|
+
export function hasPaid(payment) {
|
|
120
|
+
return (payment.status === 'paid' ||
|
|
121
|
+
payment.status === 'partially_refunded' ||
|
|
122
|
+
payment.status === 'refunded');
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Whether nothing further will happen to this payment.
|
|
126
|
+
*
|
|
127
|
+
* What decides whether offering the page again is worth anything. A failed,
|
|
128
|
+
* cancelled, expired or fully refunded payment is over; a created or pending
|
|
129
|
+
* one can still be paid.
|
|
130
|
+
*/
|
|
131
|
+
export function isOver(payment) {
|
|
132
|
+
return (payment.status === 'failed' ||
|
|
133
|
+
payment.status === 'cancelled' ||
|
|
134
|
+
payment.status === 'expired' ||
|
|
135
|
+
payment.status === 'refunded');
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* An amount, written the way a person in a given place writes it.
|
|
139
|
+
*
|
|
140
|
+
* The one formatting helper worth shipping, for the same reason bookings ships
|
|
141
|
+
* one for time: the obvious version is wrong. Dividing by a hundred is right
|
|
142
|
+
* for CHF, wrong for JPY, which has no minor unit at all, and wrong the other
|
|
143
|
+
* way for KWD, which has three. The number of places comes from the currency
|
|
144
|
+
* rather than from a constant, so this is correct for currencies nobody thought
|
|
145
|
+
* about when writing it.
|
|
146
|
+
*
|
|
147
|
+
* `locales` defaults to the reader's own. Pass one to match a page's language.
|
|
148
|
+
*/
|
|
149
|
+
export function formatMoney(money, locales) {
|
|
150
|
+
const format = new Intl.NumberFormat(locales, { style: 'currency', currency: money.currency });
|
|
151
|
+
const places = format.resolvedOptions().maximumFractionDigits ?? 2;
|
|
152
|
+
return format.format(money.amount / 10 ** places);
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAqBpD,MAAM,OAAO,QAAQ;IACV,OAAO,CAAS;IAEzB,YAAY,MAAc;QACxB,sEAAsE;QACtE,0EAA0E;QAC1E,0BAA0B;QAC1B,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACvB,MAAM,IAAI,WAAW,CACnB,qBAAqB,EACrB,iFAAiF;gBAC/E,6EAA6E,CAChF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,gFAAgF;IAEhF;;;;;OAKG;IACH,IAAI,CAAC,QAAsB,EAAE;QAC3B,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAqB,WAAW,EAAE;YACvD,GAAG,IAAI;YACP,KAAK,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE;SAC3D,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,EAAU,EAAE,UAA0B,EAAE;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAU,aAA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;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAC,OAAgB;IACrC,OAAO,CACL,OAAO,CAAC,MAAM,KAAK,QAAQ;QAC3B,OAAO,CAAC,MAAM,KAAK,WAAW;QAC9B,OAAO,CAAC,MAAM,KAAK,SAAS;QAC5B,OAAO,CAAC,MAAM,KAAK,UAAU,CAC9B,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAC,KAAY,EAAE,OAA2B;IACnE,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/F,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC,qBAAqB,IAAI,CAAC,CAAC;IACnE,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE,IAAI,MAAM,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/types 3.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `/v1` returns for payments, as the wire returns it.
|
|
3
|
+
*
|
|
4
|
+
* Money is an object rather than a bare number: `{amount: 3500, currency:
|
|
5
|
+
* "CHF"}` says what 3500 means. A bare number invites dividing by a hundred that
|
|
6
|
+
* somebody guessed at, which is wrong for JPY and wrong for KWD in the other
|
|
7
|
+
* direction. `formatMoney` does it properly.
|
|
8
|
+
*
|
|
9
|
+
* Three things a payment deliberately does not say, and their absence is the
|
|
10
|
+
* product rather than an omission. The provider account the money landed in is
|
|
11
|
+
* the client's alone and appears nowhere. Neither do the credentials behind it.
|
|
12
|
+
* Neither does the provider's own name or its session and charge references,
|
|
13
|
+
* because nothing a receipt renders needs them.
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `/v1` returns for payments, as the wire returns it.
|
|
3
|
+
*
|
|
4
|
+
* Money is an object rather than a bare number: `{amount: 3500, currency:
|
|
5
|
+
* "CHF"}` says what 3500 means. A bare number invites dividing by a hundred that
|
|
6
|
+
* somebody guessed at, which is wrong for JPY and wrong for KWD in the other
|
|
7
|
+
* direction. `formatMoney` does it properly.
|
|
8
|
+
*
|
|
9
|
+
* Three things a payment deliberately does not say, and their absence is the
|
|
10
|
+
* product rather than an omission. The provider account the money landed in is
|
|
11
|
+
* the client's alone and appears nowhere. Neither do the credentials behind it.
|
|
12
|
+
* Neither does the provider's own name or its session and charge references,
|
|
13
|
+
* because nothing a receipt renders needs them.
|
|
14
|
+
*/
|
|
15
|
+
export interface Money {
|
|
16
|
+
/** Minor units: 3500 is CHF 35.00. Never divide without the currency. */
|
|
17
|
+
amount: number;
|
|
18
|
+
currency: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Where one payment has got to.
|
|
22
|
+
*
|
|
23
|
+
* It only ever moves forward. A provider redelivers events for days and
|
|
24
|
+
* promises no order, so the platform applies a status as a maximum rather than
|
|
25
|
+
* as an assignment, and a late "still pending" cannot undo a payment that
|
|
26
|
+
* arrived.
|
|
27
|
+
*
|
|
28
|
+
* `created` is a payment whose page was never opened, which is a provider that
|
|
29
|
+
* refused rather than a customer who declined.
|
|
30
|
+
*/
|
|
31
|
+
export type PaymentStatus = 'created' | 'pending' | 'requires_action' | 'paid' | 'failed' | 'cancelled' | 'expired' | 'partially_refunded' | 'refunded';
|
|
32
|
+
/**
|
|
33
|
+
* Where one refund has got to.
|
|
34
|
+
*
|
|
35
|
+
* Its own vocabulary rather than a corner of the payment's, because a refund
|
|
36
|
+
* succeeding and a payment being refunded are different facts: a payment can
|
|
37
|
+
* carry several refunds, and one of them failing does not move the payment.
|
|
38
|
+
*/
|
|
39
|
+
export type RefundStatus = 'pending' | 'succeeded' | 'failed' | 'cancelled';
|
|
40
|
+
export interface Refund {
|
|
41
|
+
id: string;
|
|
42
|
+
amount: Money;
|
|
43
|
+
/** `pending` is money on its way, not money that has arrived. */
|
|
44
|
+
status: RefundStatus;
|
|
45
|
+
reason: string;
|
|
46
|
+
created_at: string;
|
|
47
|
+
}
|
|
48
|
+
export interface Payment {
|
|
49
|
+
id: string;
|
|
50
|
+
status: PaymentStatus;
|
|
51
|
+
amount: Money;
|
|
52
|
+
/** What has gone back so far. */
|
|
53
|
+
refunded: Money;
|
|
54
|
+
/**
|
|
55
|
+
* What is still there to give back.
|
|
56
|
+
*
|
|
57
|
+
* Published rather than left to be worked out, because the arithmetic is not
|
|
58
|
+
* what it looks like: a refund still settling is money already spent, and
|
|
59
|
+
* subtracting only the settled ones would show more left than there is.
|
|
60
|
+
*/
|
|
61
|
+
refundable: Money;
|
|
62
|
+
/**
|
|
63
|
+
* What this settled on the platform, as a model label and that object's id.
|
|
64
|
+
* `"bookings.booking"`, or empty on a standalone payment page.
|
|
65
|
+
*/
|
|
66
|
+
subject_type: string;
|
|
67
|
+
subject_id: string | null;
|
|
68
|
+
customer: {
|
|
69
|
+
email: string;
|
|
70
|
+
name: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Where to send the customer to pay.
|
|
74
|
+
*
|
|
75
|
+
* Empty only when no page was ever opened, which is a provider that refused.
|
|
76
|
+
* It is not cleared once the payment settles, so read `status` to decide
|
|
77
|
+
* whether to show it: the provider refuses a session that has been paid, but
|
|
78
|
+
* a paid receipt with a pay button on it is still a bad page.
|
|
79
|
+
*/
|
|
80
|
+
checkout_url: string;
|
|
81
|
+
checkout_expires_at: string | null;
|
|
82
|
+
created_at: string;
|
|
83
|
+
/** When the provider said the money arrived. Null until it did. */
|
|
84
|
+
paid_at: string | null;
|
|
85
|
+
/** Why nothing was taken. `checkout_failed` means no page was ever opened. */
|
|
86
|
+
failure_code: string;
|
|
87
|
+
failure_message: string;
|
|
88
|
+
refunds: Refund[];
|
|
89
|
+
}
|
|
90
|
+
export interface CheckoutRequest {
|
|
91
|
+
/** Minor units. 3500 is CHF 35.00. */
|
|
92
|
+
amount: number;
|
|
93
|
+
/** Defaults to the project's own currency, which is nearly always the answer. */
|
|
94
|
+
currency?: string;
|
|
95
|
+
/** What the customer reads on the payment page. */
|
|
96
|
+
description?: string;
|
|
97
|
+
customer_email?: string;
|
|
98
|
+
customer_name?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Where the provider sends the customer afterwards. Your pages, so your URLs.
|
|
101
|
+
*
|
|
102
|
+
* The success page confirms nothing. It means a form was submitted, and only
|
|
103
|
+
* the provider's webhook says money moved.
|
|
104
|
+
*/
|
|
105
|
+
success_url: string;
|
|
106
|
+
cancel_url: string;
|
|
107
|
+
/** Your own references, carried to the provider and back on every webhook. */
|
|
108
|
+
metadata?: Record<string, string>;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `/v1` returns for payments, as the wire returns it.
|
|
3
|
+
*
|
|
4
|
+
* Money is an object rather than a bare number: `{amount: 3500, currency:
|
|
5
|
+
* "CHF"}` says what 3500 means. A bare number invites dividing by a hundred that
|
|
6
|
+
* somebody guessed at, which is wrong for JPY and wrong for KWD in the other
|
|
7
|
+
* direction. `formatMoney` does it properly.
|
|
8
|
+
*
|
|
9
|
+
* Three things a payment deliberately does not say, and their absence is the
|
|
10
|
+
* product rather than an omission. The provider account the money landed in is
|
|
11
|
+
* the business's alone and appears nowhere. Neither do the credentials behind it.
|
|
12
|
+
* Neither does the provider's own name or its session and charge references,
|
|
13
|
+
* because nothing a receipt renders needs them.
|
|
14
|
+
*/
|
|
15
|
+
export interface Money {
|
|
16
|
+
/** Minor units: 3500 is CHF 35.00. Never divide without the currency. */
|
|
17
|
+
amount: number;
|
|
18
|
+
currency: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Where one payment has got to.
|
|
22
|
+
*
|
|
23
|
+
* It only ever moves forward. A provider redelivers events for days and
|
|
24
|
+
* promises no order, so the platform applies a status as a maximum rather than
|
|
25
|
+
* as an assignment, and a late "still pending" cannot undo a payment that
|
|
26
|
+
* arrived.
|
|
27
|
+
*
|
|
28
|
+
* `created` is a payment whose page was never opened, which is a provider that
|
|
29
|
+
* refused rather than a customer who declined.
|
|
30
|
+
*/
|
|
31
|
+
export type PaymentStatus = 'created' | 'pending' | 'requires_action' | 'paid' | 'failed' | 'cancelled' | 'expired' | 'partially_refunded' | 'refunded';
|
|
32
|
+
/**
|
|
33
|
+
* Where one refund has got to.
|
|
34
|
+
*
|
|
35
|
+
* Its own vocabulary rather than a corner of the payment's, because a refund
|
|
36
|
+
* succeeding and a payment being refunded are different facts: a payment can
|
|
37
|
+
* carry several refunds, and one of them failing does not move the payment.
|
|
38
|
+
*/
|
|
39
|
+
export type RefundStatus = 'pending' | 'succeeded' | 'failed' | 'cancelled';
|
|
40
|
+
export interface Refund {
|
|
41
|
+
id: string;
|
|
42
|
+
amount: Money;
|
|
43
|
+
/** `pending` is money on its way, not money that has arrived. */
|
|
44
|
+
status: RefundStatus;
|
|
45
|
+
reason: string;
|
|
46
|
+
created_at: string;
|
|
47
|
+
}
|
|
48
|
+
export interface Payment {
|
|
49
|
+
id: string;
|
|
50
|
+
/** False for a payment a test key asked for, at the provider's test mode. */
|
|
51
|
+
livemode: boolean;
|
|
52
|
+
status: PaymentStatus;
|
|
53
|
+
amount: Money;
|
|
54
|
+
/** What has gone back so far. */
|
|
55
|
+
refunded: Money;
|
|
56
|
+
/**
|
|
57
|
+
* What is still there to give back.
|
|
58
|
+
*
|
|
59
|
+
* Published rather than left to be worked out, because the arithmetic is not
|
|
60
|
+
* what it looks like: a refund still settling is money already spent, and
|
|
61
|
+
* subtracting only the settled ones would show more left than there is.
|
|
62
|
+
*/
|
|
63
|
+
refundable: Money;
|
|
64
|
+
/**
|
|
65
|
+
* What this settled on the platform, as a model label and that object's id.
|
|
66
|
+
* `"bookings.booking"`, or empty on a standalone payment page.
|
|
67
|
+
*/
|
|
68
|
+
subject_type: string;
|
|
69
|
+
subject_id: string | null;
|
|
70
|
+
customer: {
|
|
71
|
+
email: string;
|
|
72
|
+
name: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Where to send the customer to pay.
|
|
76
|
+
*
|
|
77
|
+
* Empty only when no page was ever opened, which is a provider that refused.
|
|
78
|
+
* It is not cleared once the payment settles, so read `status` to decide
|
|
79
|
+
* whether to show it: the provider refuses a session that has been paid, but
|
|
80
|
+
* a paid receipt with a pay button on it is still a bad page.
|
|
81
|
+
*/
|
|
82
|
+
checkout_url: string;
|
|
83
|
+
checkout_expires_at: string | null;
|
|
84
|
+
created_at: string;
|
|
85
|
+
/** When the provider said the money arrived. Null until it did. */
|
|
86
|
+
paid_at: string | null;
|
|
87
|
+
/** Why nothing was taken. `checkout_failed` means no page was ever opened. */
|
|
88
|
+
failure_code: string;
|
|
89
|
+
failure_message: string;
|
|
90
|
+
refunds: Refund[];
|
|
91
|
+
}
|
|
92
|
+
export interface CheckoutRequest {
|
|
93
|
+
/** Minor units. 3500 is CHF 35.00. */
|
|
94
|
+
amount: number;
|
|
95
|
+
/** Defaults to the project's own currency, which is nearly always the answer. */
|
|
96
|
+
currency?: string;
|
|
97
|
+
/** What the customer reads on the payment page. */
|
|
98
|
+
description?: string;
|
|
99
|
+
customer_email?: string;
|
|
100
|
+
customer_name?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Where the provider sends the customer afterwards. Your pages, so your URLs.
|
|
103
|
+
*
|
|
104
|
+
* The success page confirms nothing. It means a form was submitted, and only
|
|
105
|
+
* the provider's webhook says money moved.
|
|
106
|
+
*/
|
|
107
|
+
success_url: string;
|
|
108
|
+
cancel_url: string;
|
|
109
|
+
/** Your own references, carried to the provider and back on every webhook. */
|
|
110
|
+
metadata?: Record<string, string>;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=types.d.ts.map
|
|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is an object rather than a bare number: `{amount: 3500, currency:
|
|
5
|
+
* "CHF"}` says what 3500 means. A bare number invites dividing by a hundred that
|
|
6
|
+
* somebody guessed at, which is wrong for JPY and wrong for KWD in the other
|
|
7
|
+
* direction. `formatMoney` does it properly.
|
|
8
|
+
*
|
|
9
|
+
* Three things a payment deliberately does not say, and their absence is the
|
|
10
|
+
* product rather than an omission. The provider account the money landed in is
|
|
11
|
+
* the business's alone and appears nowhere. Neither do the credentials behind it.
|
|
12
|
+
* Neither does the provider's own name or its session and charge references,
|
|
13
|
+
* because nothing a receipt renders needs them.
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backendfree/payments",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Typed access to a BackendFree project's money: what has been taken, and opening a payment page.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"backendfree",
|
|
7
|
+
"payments",
|
|
8
|
+
"checkout",
|
|
9
|
+
"stripe",
|
|
10
|
+
"sdk",
|
|
11
|
+
"typescript"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "BackendFree",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"src",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@backendfree/core": "^0.1.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"clean": "tsc --build --clean && rm -rf dist",
|
|
42
|
+
"build": "tsc --build",
|
|
43
|
+
"test": "npm run build && node --test test/*.test.mjs",
|
|
44
|
+
"prepare": "npm run build",
|
|
45
|
+
"prepublishOnly": "npm test"
|
|
46
|
+
}
|
|
47
|
+
}
|