@mostajs/payment 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 +86 -0
- package/dist/api/checkout.route.d.ts +7 -0
- package/dist/api/checkout.route.d.ts.map +1 -0
- package/dist/api/checkout.route.js +23 -0
- package/dist/api/checkout.route.js.map +1 -0
- package/dist/api/payments.route.d.ts +9 -0
- package/dist/api/payments.route.d.ts.map +1 -0
- package/dist/api/payments.route.js +28 -0
- package/dist/api/payments.route.js.map +1 -0
- package/dist/components/PaymentPage.d.ts +18 -0
- package/dist/components/PaymentPage.d.ts.map +1 -0
- package/dist/components/PaymentPage.js +65 -0
- package/dist/components/PaymentPage.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/module-info.d.ts +10 -0
- package/dist/lib/module-info.d.ts.map +1 -0
- package/dist/lib/module-info.js +14 -0
- package/dist/lib/module-info.js.map +1 -0
- package/dist/lib/payment-factory.d.ts +12 -0
- package/dist/lib/payment-factory.d.ts.map +1 -0
- package/dist/lib/payment-factory.js +21 -0
- package/dist/lib/payment-factory.js.map +1 -0
- package/dist/lib/stripe.d.ts +16 -0
- package/dist/lib/stripe.d.ts.map +1 -0
- package/dist/lib/stripe.js +48 -0
- package/dist/lib/stripe.js.map +1 -0
- package/dist/register.d.ts +10 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +12 -0
- package/dist/register.js.map +1 -0
- package/dist/schemas/payment.schema.d.ts +16 -0
- package/dist/schemas/payment.schema.d.ts.map +1 -0
- package/dist/schemas/payment.schema.js +39 -0
- package/dist/schemas/payment.schema.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +14 -0
- package/dist/server.js.map +1 -0
- package/dist/types/index.d.ts +76 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @mostajs/payment
|
|
2
|
+
|
|
3
|
+
> Payment module for @mostajs — Stripe checkout, multi-method (card, transfer, cash), multi-currency.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mostajs/payment stripe
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Schema
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { createPaymentSchema } from '@mostajs/payment'
|
|
17
|
+
|
|
18
|
+
// Default (no relation, USD)
|
|
19
|
+
const schema = createPaymentSchema()
|
|
20
|
+
|
|
21
|
+
// With relation to Reservation, DZD currency
|
|
22
|
+
const schema = createPaymentSchema({
|
|
23
|
+
currency: 'DZD',
|
|
24
|
+
relationTarget: 'Reservation',
|
|
25
|
+
relationRequired: true,
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Stripe Checkout (server-side)
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { createCheckoutHandler } from '@mostajs/payment/server'
|
|
33
|
+
|
|
34
|
+
const config = {
|
|
35
|
+
currency: 'EUR',
|
|
36
|
+
stripeSecretKey: process.env.STRIPE_SECRET_KEY,
|
|
37
|
+
successUrlTemplate: '/confirmation/{orderId}?paid=true',
|
|
38
|
+
cancelUrlTemplate: '/payment/{orderId}?cancelled=true',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Next.js App Router
|
|
42
|
+
export const POST = createCheckoutHandler(config)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Payment Page (React)
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { PaymentPage } from '@mostajs/payment'
|
|
49
|
+
|
|
50
|
+
<PaymentPage
|
|
51
|
+
orderId="12345"
|
|
52
|
+
orderSummary={{
|
|
53
|
+
title: 'Commande #12345',
|
|
54
|
+
lines: [{ label: 'Article', value: '2x Widget' }],
|
|
55
|
+
amount: 99.99,
|
|
56
|
+
currency: 'EUR',
|
|
57
|
+
}}
|
|
58
|
+
config={{
|
|
59
|
+
currency: 'EUR',
|
|
60
|
+
stripePublicKey: process.env.NEXT_PUBLIC_STRIPE_KEY,
|
|
61
|
+
successUrlTemplate: '/confirmation/{orderId}',
|
|
62
|
+
cancelUrlTemplate: '/payment/{orderId}',
|
|
63
|
+
methods: ['card', 'transfer'],
|
|
64
|
+
bankInfo: { rib: 'FR76...', bankName: 'BNP', holder: 'SARL Example' },
|
|
65
|
+
}}
|
|
66
|
+
onSuccess={(method) => console.log('Paid via', method)}
|
|
67
|
+
/>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## API
|
|
71
|
+
|
|
72
|
+
| Export | Entry | Description |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| `PaymentSchema` | `.` | Default schema (no relation) |
|
|
75
|
+
| `createPaymentSchema(opts)` | `.` | Schema factory with options |
|
|
76
|
+
| `PaymentPage` | `.` | React payment UI component |
|
|
77
|
+
| `createStripeClient(config)` | `./server` | Stripe SDK wrapper |
|
|
78
|
+
| `createCheckoutSession(stripe, req, config)` | `./server` | Create Stripe session |
|
|
79
|
+
| `handleWebhook(stripe, body, sig, secret)` | `./server` | Verify webhook |
|
|
80
|
+
| `createCheckoutHandler(config)` | `./server` | Next.js checkout route |
|
|
81
|
+
| `createPaymentHandlers(dialect)` | `./server` | CRUD route handlers |
|
|
82
|
+
| `getPaymentRepo(dialect)` | `./server` | Payment repository |
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT — (c) 2026 Dr Hamid MADANI <drmdh@msn.com>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PaymentConfig } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a checkout route handler (Next.js App Router).
|
|
4
|
+
* Generalized from booking-baloon /api/checkout/route.ts
|
|
5
|
+
*/
|
|
6
|
+
export declare function createCheckoutHandler(config: PaymentConfig): (req: Request) => Promise<Response>;
|
|
7
|
+
//# sourceMappingURL=checkout.route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.route.d.ts","sourceRoot":"","sources":["../../src/api/checkout.route.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,mBAAmB,CAAA;AAGvE;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,IAC9B,KAAK,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAuB5D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createStripeClient, createCheckoutSession } from '../lib/stripe.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a checkout route handler (Next.js App Router).
|
|
4
|
+
* Generalized from booking-baloon /api/checkout/route.ts
|
|
5
|
+
*/
|
|
6
|
+
export function createCheckoutHandler(config) {
|
|
7
|
+
return async function POST(req) {
|
|
8
|
+
try {
|
|
9
|
+
const body = await req.json();
|
|
10
|
+
if (!body.orderId || !body.lineItems?.length) {
|
|
11
|
+
return Response.json({ error: 'orderId and lineItems are required' }, { status: 400 });
|
|
12
|
+
}
|
|
13
|
+
const stripe = createStripeClient(config);
|
|
14
|
+
const result = await createCheckoutSession(stripe, body, config);
|
|
15
|
+
return Response.json(result);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
console.error('[payment] Checkout error:', err);
|
|
19
|
+
return Response.json({ error: err instanceof Error ? err.message : 'Checkout failed' }, { status: 500 });
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=checkout.route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.route.js","sourceRoot":"","sources":["../../src/api/checkout.route.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAE5E;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAqB;IACzD,OAAO,KAAK,UAAU,IAAI,CAAC,GAAY;QACrC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAqB,CAAA;YAEhD,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;gBAC7C,OAAO,QAAQ,CAAC,IAAI,CAClB,EAAE,KAAK,EAAE,oCAAoC,EAAE,EAC/C,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAA;YACH,CAAC;YAED,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAA;YACzC,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;YAEhE,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAA;YAC/C,OAAO,QAAQ,CAAC,IAAI,CAClB,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,EAAE,EACjE,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAA;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IDialect } from '@mostajs/orm';
|
|
2
|
+
/**
|
|
3
|
+
* Create payment CRUD handlers (Next.js App Router).
|
|
4
|
+
*/
|
|
5
|
+
export declare function createPaymentHandlers(dialect: IDialect): {
|
|
6
|
+
GET: () => Promise<Response>;
|
|
7
|
+
POST: (req: Request) => Promise<Response>;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=payments.route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.route.d.ts","sourceRoot":"","sources":["../../src/api/payments.route.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAI5C;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,QAAQ;eAG/B,OAAO,CAAC,QAAQ,CAAC;gBASd,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;EAWrD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getPaymentRepo } from '../lib/payment-factory.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create payment CRUD handlers (Next.js App Router).
|
|
4
|
+
*/
|
|
5
|
+
export function createPaymentHandlers(dialect) {
|
|
6
|
+
const repo = getPaymentRepo(dialect);
|
|
7
|
+
async function GET() {
|
|
8
|
+
try {
|
|
9
|
+
const payments = await repo.findAll();
|
|
10
|
+
return Response.json(payments);
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
return Response.json({ error: 'Failed to fetch payments' }, { status: 500 });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async function POST(req) {
|
|
17
|
+
try {
|
|
18
|
+
const data = await req.json();
|
|
19
|
+
const payment = await repo.create(data);
|
|
20
|
+
return Response.json(payment, { status: 201 });
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
return Response.json({ error: 'Failed to create payment' }, { status: 500 });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { GET, POST };
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=payments.route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.route.js","sourceRoot":"","sources":["../../src/api/payments.route.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE1D;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAiB;IACrD,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;IAEpC,KAAK,UAAU,GAAG;QAChB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;YACrC,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAChC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,0BAA0B,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAC9E,CAAC;IACH,CAAC;IAED,KAAK,UAAU,IAAI,CAAC,GAAY;QAC9B,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAA6B,CAAA;YACxD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAA2B,CAAC,CAAA;YAC9D,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAChD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,0BAA0B,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAC9E,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAA;AACtB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OrderSummary, PaymentMethodType, PaymentConfig } from '../types/index.js';
|
|
2
|
+
interface PaymentPageProps {
|
|
3
|
+
/** Unique order identifier */
|
|
4
|
+
orderId: string;
|
|
5
|
+
/** Order summary to display */
|
|
6
|
+
orderSummary: OrderSummary;
|
|
7
|
+
/** Payment configuration */
|
|
8
|
+
config: PaymentConfig;
|
|
9
|
+
/** Callback on successful payment initiation */
|
|
10
|
+
onSuccess?: (method: PaymentMethodType, transactionRef?: string) => void;
|
|
11
|
+
/** Callback to go back */
|
|
12
|
+
onBack?: () => void;
|
|
13
|
+
/** Checkout API endpoint (default: '/api/checkout') */
|
|
14
|
+
checkoutApiPath?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function PaymentPage({ orderId, orderSummary, config, onSuccess, onBack, checkoutApiPath, }: PaymentPageProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=PaymentPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaymentPage.d.ts","sourceRoot":"","sources":["../../src/components/PaymentPage.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEvF,UAAU,gBAAgB;IACxB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,+BAA+B;IAC/B,YAAY,EAAE,YAAY,CAAA;IAC1B,4BAA4B;IAC5B,MAAM,EAAE,aAAa,CAAA;IACrB,gDAAgD;IAChD,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IACxE,0BAA0B;IAC1B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB,uDAAuD;IACvD,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,YAAY,EACZ,MAAM,EACN,SAAS,EACT,MAAM,EACN,eAAiC,GAClC,EAAE,gBAAgB,2CAoIlB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// @mostajs/payment — PaymentPage component
|
|
2
|
+
// Generalized from booking-baloon /payment/[id]/page.tsx
|
|
3
|
+
// Author: Dr Hamid MADANI drmdh@msn.com
|
|
4
|
+
'use client';
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
export function PaymentPage({ orderId, orderSummary, config, onSuccess, onBack, checkoutApiPath = '/api/checkout', }) {
|
|
8
|
+
const [method, setMethod] = useState('card');
|
|
9
|
+
const [processing, setProcessing] = useState(false);
|
|
10
|
+
const [success, setSuccess] = useState(false);
|
|
11
|
+
const methods = config.methods ?? ['card', 'transfer', 'cash'];
|
|
12
|
+
const METHOD_LABELS = {
|
|
13
|
+
card: { label: 'Carte bancaire', icon: '💳', desc: 'Paiement securise via Stripe' },
|
|
14
|
+
transfer: { label: 'Virement bancaire', icon: '🏦', desc: 'Virement vers notre compte' },
|
|
15
|
+
cash: { label: 'Especes sur place', icon: '💵', desc: 'Paiement a la reception' },
|
|
16
|
+
tpe: { label: 'Terminal de paiement', icon: '📱', desc: 'Paiement par TPE' },
|
|
17
|
+
};
|
|
18
|
+
async function handlePay() {
|
|
19
|
+
setProcessing(true);
|
|
20
|
+
try {
|
|
21
|
+
if (method === 'card') {
|
|
22
|
+
const res = await fetch(checkoutApiPath, {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: { 'Content-Type': 'application/json' },
|
|
25
|
+
body: JSON.stringify({
|
|
26
|
+
orderId,
|
|
27
|
+
lineItems: [{ name: orderSummary.title, unitAmount: orderSummary.amount, quantity: 1 }],
|
|
28
|
+
currency: orderSummary.currency,
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
const data = await res.json();
|
|
32
|
+
if (data.url) {
|
|
33
|
+
globalThis.location.href = data.url;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// For non-card methods, mark as success immediately
|
|
38
|
+
setSuccess(true);
|
|
39
|
+
onSuccess?.(method);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.error('[payment] Error:', err);
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
setProcessing(false);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (success) {
|
|
49
|
+
return (_jsxs("div", { style: { maxWidth: 500, margin: '40px auto', textAlign: 'center', padding: 24 }, children: [_jsx("div", { style: { fontSize: 48, marginBottom: 16 }, children: "\u2705" }), _jsx("h2", { style: { marginBottom: 8 }, children: "Paiement enregistre" }), _jsxs("p", { style: { color: '#6b7280' }, children: [method === 'transfer' && 'Votre virement sera verifie sous 24-48h.', method === 'cash' && 'Veuillez payer sur place lors de votre visite.', method === 'tpe' && 'Paiement par terminal enregistre.'] }), onBack && _jsx("button", { onClick: onBack, style: { marginTop: 16, padding: '8px 24px', cursor: 'pointer' }, children: "Retour" })] }));
|
|
50
|
+
}
|
|
51
|
+
return (_jsxs("div", { style: { maxWidth: 500, margin: '40px auto', padding: 24 }, children: [_jsx("h1", { style: { fontSize: 24, fontWeight: 'bold', marginBottom: 24 }, children: "Paiement" }), _jsxs("div", { style: { background: '#f9fafb', borderRadius: 8, padding: 16, marginBottom: 24 }, children: [_jsx("h3", { style: { fontWeight: 600, marginBottom: 8 }, children: orderSummary.title }), orderSummary.lines.map((line, i) => (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', fontSize: 14, color: '#6b7280' }, children: [_jsx("span", { children: line.label }), _jsx("span", { children: line.value })] }, i))), _jsxs("div", { style: { borderTop: '1px solid #e5e7eb', marginTop: 8, paddingTop: 8, fontWeight: 'bold', fontSize: 18 }, children: ["Total : ", orderSummary.amount, " ", orderSummary.currency] })] }), _jsxs("div", { style: { marginBottom: 24 }, children: [_jsx("h3", { style: { fontWeight: 600, marginBottom: 12 }, children: "Mode de paiement" }), methods.map(m => {
|
|
52
|
+
const info = METHOD_LABELS[m];
|
|
53
|
+
if (!info)
|
|
54
|
+
return null;
|
|
55
|
+
return (_jsxs("label", { style: {
|
|
56
|
+
display: 'flex', alignItems: 'center', gap: 12, padding: 12, marginBottom: 8,
|
|
57
|
+
border: `2px solid ${method === m ? '#3b82f6' : '#e5e7eb'}`,
|
|
58
|
+
borderRadius: 8, cursor: 'pointer', background: method === m ? '#eff6ff' : '#fff',
|
|
59
|
+
}, children: [_jsx("input", { type: "radio", name: "method", checked: method === m, onChange: () => setMethod(m) }), _jsx("span", { style: { fontSize: 24 }, children: info.icon }), _jsxs("div", { children: [_jsx("div", { style: { fontWeight: 500 }, children: info.label }), _jsx("div", { style: { fontSize: 12, color: '#6b7280' }, children: info.desc })] })] }, m));
|
|
60
|
+
})] }), method === 'transfer' && config.bankInfo && (_jsxs("div", { style: { background: '#fefce8', borderRadius: 8, padding: 16, marginBottom: 24, fontSize: 14 }, children: [_jsx("h4", { style: { fontWeight: 600, marginBottom: 8 }, children: "Coordonnees bancaires" }), _jsxs("div", { children: ["RIB : ", _jsx("strong", { children: config.bankInfo.rib })] }), _jsxs("div", { children: ["Banque : ", config.bankInfo.bankName] }), _jsxs("div", { children: ["Titulaire : ", config.bankInfo.holder] }), _jsxs("div", { style: { marginTop: 8, color: '#92400e' }, children: ["Mentionnez la reference ", _jsx("strong", { children: orderId }), " dans le motif du virement."] })] })), _jsx("button", { onClick: handlePay, disabled: processing || (method === 'card' && !config.stripePublicKey), style: {
|
|
61
|
+
width: '100%', padding: '12px 0', fontSize: 16, fontWeight: 'bold', color: '#fff',
|
|
62
|
+
background: processing ? '#9ca3af' : '#3b82f6', border: 'none', borderRadius: 8, cursor: 'pointer',
|
|
63
|
+
}, children: processing ? 'Traitement en cours...' : method === 'card' ? `Payer ${orderSummary.amount} ${orderSummary.currency}` : 'Confirmer' }), method === 'card' && !config.stripePublicKey && (_jsx("p", { style: { color: '#ef4444', fontSize: 12, marginTop: 8, textAlign: 'center' }, children: "Stripe non configure \u2014 definissez stripePublicKey dans la config." }))] }));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=PaymentPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaymentPage.js","sourceRoot":"","sources":["../../src/components/Paym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AK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,uFAE3E,CACL,IACG,CACP,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { PaymentConfig, PaymentStatus, PaymentMethodType, LineItem, CheckoutRequest, CheckoutResult, OrderSummary, PaymentDTO, } from './types/index.js';
|
|
2
|
+
export { PaymentSchema, createPaymentSchema } from './schemas/payment.schema.js';
|
|
3
|
+
export { PaymentPage } from './components/PaymentPage.js';
|
|
4
|
+
export { moduleInfo } from './lib/module-info.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,YAAY,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,cAAc,EACd,YAAY,EACZ,UAAU,GACX,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGhF,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAGzD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @mostajs/payment — Payment module for @mostajs
|
|
2
|
+
// Stripe checkout, multi-method, multi-currency
|
|
3
|
+
// Author: Dr Hamid MADANI drmdh@msn.com
|
|
4
|
+
// Schema
|
|
5
|
+
export { PaymentSchema, createPaymentSchema } from './schemas/payment.schema.js';
|
|
6
|
+
// Components
|
|
7
|
+
export { PaymentPage } from './components/PaymentPage.js';
|
|
8
|
+
// Module info
|
|
9
|
+
export { moduleInfo } from './lib/module-info.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,gDAAgD;AAChD,wCAAwC;AAcxC,SAAS;AACT,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEhF,aAAa;AACb,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EntitySchema } from '@mostajs/orm';
|
|
2
|
+
export declare function getSchemas(): EntitySchema[];
|
|
3
|
+
export declare const moduleInfo: {
|
|
4
|
+
name: string;
|
|
5
|
+
label: string;
|
|
6
|
+
description: string;
|
|
7
|
+
version: string;
|
|
8
|
+
schemas: string[];
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=module-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-info.d.ts","sourceRoot":"","sources":["../../src/lib/module-info.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD,wBAAgB,UAAU,IAAI,YAAY,EAAE,CAE3C;AAED,eAAO,MAAM,UAAU;;;;;;CAMtB,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @mostajs/payment — Module info
|
|
2
|
+
// Author: Dr Hamid MADANI drmdh@msn.com
|
|
3
|
+
import { PaymentSchema } from '../schemas/payment.schema.js';
|
|
4
|
+
export function getSchemas() {
|
|
5
|
+
return [PaymentSchema];
|
|
6
|
+
}
|
|
7
|
+
export const moduleInfo = {
|
|
8
|
+
name: 'payment',
|
|
9
|
+
label: 'Payment',
|
|
10
|
+
description: 'Payment processing — Stripe, bank transfer, cash',
|
|
11
|
+
version: '0.1.0',
|
|
12
|
+
schemas: ['Payment'],
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=module-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-info.js","sourceRoot":"","sources":["../../src/lib/module-info.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,wCAAwC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAG5D,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,aAAa,CAAC,CAAA;AACxB,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,kDAAkD;IAC/D,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,CAAC,SAAS,CAAC;CACrB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseRepository } from '@mostajs/orm';
|
|
2
|
+
import type { IDialect } from '@mostajs/orm';
|
|
3
|
+
import type { PaymentDTO } from '../types/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Get or create the Payment repository.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getPaymentRepo(dialect: IDialect): BaseRepository<PaymentDTO>;
|
|
8
|
+
/**
|
|
9
|
+
* Reset cache (for testing or dialect change).
|
|
10
|
+
*/
|
|
11
|
+
export declare function resetPaymentRepo(): void;
|
|
12
|
+
//# sourceMappingURL=payment-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-factory.d.ts","sourceRoot":"","sources":["../../src/lib/payment-factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAKnD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAK5E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @mostajs/payment — Payment repository factory
|
|
2
|
+
// Author: Dr Hamid MADANI drmdh@msn.com
|
|
3
|
+
import { BaseRepository } from '@mostajs/orm';
|
|
4
|
+
import { PaymentSchema } from '../schemas/payment.schema.js';
|
|
5
|
+
let cachedRepo = null;
|
|
6
|
+
/**
|
|
7
|
+
* Get or create the Payment repository.
|
|
8
|
+
*/
|
|
9
|
+
export function getPaymentRepo(dialect) {
|
|
10
|
+
if (!cachedRepo) {
|
|
11
|
+
cachedRepo = new BaseRepository(PaymentSchema, dialect);
|
|
12
|
+
}
|
|
13
|
+
return cachedRepo;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reset cache (for testing or dialect change).
|
|
17
|
+
*/
|
|
18
|
+
export function resetPaymentRepo() {
|
|
19
|
+
cachedRepo = null;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=payment-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-factory.js","sourceRoot":"","sources":["../../src/lib/payment-factory.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,wCAAwC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE5D,IAAI,UAAU,GAAsC,IAAI,CAAA;AAExD;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAiB;IAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,UAAU,GAAG,IAAI,cAAc,CAAa,aAAa,EAAE,OAAO,CAAC,CAAA;IACrE,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,UAAU,GAAG,IAAI,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Stripe from 'stripe';
|
|
2
|
+
import type { CheckoutRequest, CheckoutResult, PaymentConfig } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a Stripe client instance.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createStripeClient(config: PaymentConfig): Stripe;
|
|
7
|
+
/**
|
|
8
|
+
* Create a Stripe Checkout session.
|
|
9
|
+
* Generalized from booking-baloon /api/checkout — works with any line items.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createCheckoutSession(stripe: Stripe, request: CheckoutRequest, config: PaymentConfig): Promise<CheckoutResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Construct and verify a Stripe webhook event.
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleWebhook(stripe: Stripe, body: string | Buffer, signature: string, secret: string): Promise<Stripe.Event>;
|
|
16
|
+
//# sourceMappingURL=stripe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.d.ts","sourceRoot":"","sources":["../../src/lib/stripe.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEvF;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAKhE;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,cAAc,CAAC,CA0BzB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAEvB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @mostajs/payment — Stripe SDK wrapper
|
|
2
|
+
// Author: Dr Hamid MADANI drmdh@msn.com
|
|
3
|
+
import Stripe from 'stripe';
|
|
4
|
+
/**
|
|
5
|
+
* Create a Stripe client instance.
|
|
6
|
+
*/
|
|
7
|
+
export function createStripeClient(config) {
|
|
8
|
+
if (!config.stripeSecretKey) {
|
|
9
|
+
throw new Error('[payment] stripeSecretKey is required');
|
|
10
|
+
}
|
|
11
|
+
return new Stripe(config.stripeSecretKey);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a Stripe Checkout session.
|
|
15
|
+
* Generalized from booking-baloon /api/checkout — works with any line items.
|
|
16
|
+
*/
|
|
17
|
+
export async function createCheckoutSession(stripe, request, config) {
|
|
18
|
+
const currency = (request.currency ?? config.currency ?? 'usd').toLowerCase();
|
|
19
|
+
const session = await stripe.checkout.sessions.create({
|
|
20
|
+
payment_method_types: ['card'],
|
|
21
|
+
line_items: request.lineItems.map(item => ({
|
|
22
|
+
price_data: {
|
|
23
|
+
currency,
|
|
24
|
+
product_data: {
|
|
25
|
+
name: item.name,
|
|
26
|
+
...(item.description ? { description: item.description } : {}),
|
|
27
|
+
},
|
|
28
|
+
unit_amount: Math.round(item.unitAmount * 100), // convert to cents
|
|
29
|
+
},
|
|
30
|
+
quantity: item.quantity,
|
|
31
|
+
})),
|
|
32
|
+
mode: 'payment',
|
|
33
|
+
success_url: config.successUrlTemplate.replace('{orderId}', request.orderId),
|
|
34
|
+
cancel_url: config.cancelUrlTemplate.replace('{orderId}', request.orderId),
|
|
35
|
+
metadata: {
|
|
36
|
+
orderId: request.orderId,
|
|
37
|
+
...request.metadata,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return { url: session.url, sessionId: session.id };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Construct and verify a Stripe webhook event.
|
|
44
|
+
*/
|
|
45
|
+
export async function handleWebhook(stripe, body, signature, secret) {
|
|
46
|
+
return stripe.webhooks.constructEvent(body, signature, secret);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=stripe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.js","sourceRoot":"","sources":["../../src/lib/stripe.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,wCAAwC;AACxC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAG3B;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAqB;IACtD,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;IAC1D,CAAC;IACD,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAA;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAc,EACd,OAAwB,EACxB,MAAqB;IAErB,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;IAE7E,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;QACpD,oBAAoB,EAAE,CAAC,MAAM,CAAC;QAC9B,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACzC,UAAU,EAAE;gBACV,QAAQ;gBACR,YAAY,EAAE;oBACZ,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC/D;gBACD,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,EAAE,mBAAmB;aACpE;YACD,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QACH,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC;QAC5E,UAAU,EAAE,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC;QAC1E,QAAQ,EAAE;YACR,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,GAAG,OAAO,CAAC,QAAQ;SACpB;KACF,CAAC,CAAA;IAEF,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE,CAAA;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAc,EACd,IAAqB,EACrB,SAAiB,EACjB,MAAc;IAEd,OAAO,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;AAChE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getSchemas } from './lib/module-info.js';
|
|
2
|
+
export declare const paymentModuleRegistration: {
|
|
3
|
+
name: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description: string;
|
|
6
|
+
version: string;
|
|
7
|
+
priority: number;
|
|
8
|
+
getSchemas: typeof getSchemas;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAE7D,eAAO,MAAM,yBAAyB;;;;;;;CAOrC,CAAA"}
|
package/dist/register.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @mostajs/payment — Module registration
|
|
2
|
+
// Author: Dr Hamid MADANI drmdh@msn.com
|
|
3
|
+
import { moduleInfo, getSchemas } from './lib/module-info.js';
|
|
4
|
+
export const paymentModuleRegistration = {
|
|
5
|
+
name: moduleInfo.name,
|
|
6
|
+
label: moduleInfo.label,
|
|
7
|
+
description: moduleInfo.description,
|
|
8
|
+
version: moduleInfo.version,
|
|
9
|
+
priority: 50,
|
|
10
|
+
getSchemas,
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,wCAAwC;AACxC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAE7D,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,UAAU,CAAC,IAAI;IACrB,KAAK,EAAE,UAAU,CAAC,KAAK;IACvB,WAAW,EAAE,UAAU,CAAC,WAAW;IACnC,OAAO,EAAE,UAAU,CAAC,OAAO;IAC3B,QAAQ,EAAE,EAAE;IACZ,UAAU;CACX,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EntitySchema } from '@mostajs/orm';
|
|
2
|
+
/**
|
|
3
|
+
* Create a Payment schema with configurable options.
|
|
4
|
+
*
|
|
5
|
+
* @param options.currency - Default currency (default: 'USD')
|
|
6
|
+
* @param options.relationTarget - Related entity name (e.g. 'Reservation', 'Order')
|
|
7
|
+
* @param options.relationRequired - Whether the relation is required
|
|
8
|
+
*/
|
|
9
|
+
export declare function createPaymentSchema(options?: {
|
|
10
|
+
currency?: string;
|
|
11
|
+
relationTarget?: string;
|
|
12
|
+
relationRequired?: boolean;
|
|
13
|
+
}): EntitySchema;
|
|
14
|
+
/** Default Payment schema (no relation, USD currency) */
|
|
15
|
+
export declare const PaymentSchema: EntitySchema;
|
|
16
|
+
//# sourceMappingURL=payment.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.schema.d.ts","sourceRoot":"","sources":["../../src/schemas/payment.schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,GAAG,YAAY,CAiCf;AAED,yDAAyD;AACzD,eAAO,MAAM,aAAa,cAAwB,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a Payment schema with configurable options.
|
|
3
|
+
*
|
|
4
|
+
* @param options.currency - Default currency (default: 'USD')
|
|
5
|
+
* @param options.relationTarget - Related entity name (e.g. 'Reservation', 'Order')
|
|
6
|
+
* @param options.relationRequired - Whether the relation is required
|
|
7
|
+
*/
|
|
8
|
+
export function createPaymentSchema(options) {
|
|
9
|
+
const schema = {
|
|
10
|
+
name: 'Payment',
|
|
11
|
+
collection: 'payments',
|
|
12
|
+
timestamps: true,
|
|
13
|
+
fields: {
|
|
14
|
+
amount: { type: 'number', required: true },
|
|
15
|
+
currency: { type: 'string', default: options?.currency ?? 'USD' },
|
|
16
|
+
method: { type: 'string', enum: ['card', 'transfer', 'cash', 'tpe'] },
|
|
17
|
+
status: { type: 'string', enum: ['pending', 'paid', 'refunded', 'failed'], default: 'pending' },
|
|
18
|
+
transactionRef: { type: 'string' },
|
|
19
|
+
paidAt: { type: 'date' },
|
|
20
|
+
},
|
|
21
|
+
relations: {},
|
|
22
|
+
indexes: [
|
|
23
|
+
{ fields: { status: 'asc' } },
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
if (options?.relationTarget) {
|
|
27
|
+
const relKey = options.relationTarget.toLowerCase();
|
|
28
|
+
schema.relations[relKey] = {
|
|
29
|
+
target: options.relationTarget,
|
|
30
|
+
type: 'many-to-one',
|
|
31
|
+
required: options.relationRequired ?? false,
|
|
32
|
+
};
|
|
33
|
+
schema.indexes.push({ fields: { [relKey]: 'asc' } });
|
|
34
|
+
}
|
|
35
|
+
return schema;
|
|
36
|
+
}
|
|
37
|
+
/** Default Payment schema (no relation, USD currency) */
|
|
38
|
+
export const PaymentSchema = createPaymentSchema();
|
|
39
|
+
//# sourceMappingURL=payment.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.schema.js","sourceRoot":"","sources":["../../src/schemas/payment.schema.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAInC;IACC,MAAM,MAAM,GAAiB;QAC3B,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,UAAU;QACtB,UAAU,EAAE,IAAI;QAEhB,MAAM,EAAE;YACN,MAAM,EAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;YAClD,QAAQ,EAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,IAAI,KAAK,EAAE;YACvE,MAAM,EAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE;YAC7E,MAAM,EAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE;YACvG,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAClC,MAAM,EAAU,EAAE,IAAI,EAAE,MAAM,EAAE;SACjC;QAED,SAAS,EAAE,EAAE;QAEb,OAAO,EAAE;YACP,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;SAC9B;KACF,CAAA;IAED,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,CAAA;QACnD,MAAM,CAAC,SAAU,CAAC,MAAM,CAAC,GAAG;YAC1B,MAAM,EAAE,OAAO,CAAC,cAAc;YAC9B,IAAI,EAAE,aAAa;YACnB,QAAQ,EAAE,OAAO,CAAC,gBAAgB,IAAI,KAAK;SAC5C,CAAA;QACD,MAAM,CAAC,OAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;IACvD,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED,yDAAyD;AACzD,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAA"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createStripeClient, createCheckoutSession, handleWebhook } from './lib/stripe.js';
|
|
2
|
+
export { getPaymentRepo, resetPaymentRepo } from './lib/payment-factory.js';
|
|
3
|
+
export { createCheckoutHandler } from './api/checkout.route.js';
|
|
4
|
+
export { createPaymentHandlers } from './api/payments.route.js';
|
|
5
|
+
export { getSchemas, moduleInfo } from './lib/module-info.js';
|
|
6
|
+
export { paymentModuleRegistration } from './register.js';
|
|
7
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAG1F,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAG3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAG/D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAG7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @mostajs/payment — Server-side exports (ORM + Stripe dependent)
|
|
2
|
+
// Author: Dr Hamid MADANI drmdh@msn.com
|
|
3
|
+
// Stripe
|
|
4
|
+
export { createStripeClient, createCheckoutSession, handleWebhook } from './lib/stripe.js';
|
|
5
|
+
// Repository
|
|
6
|
+
export { getPaymentRepo, resetPaymentRepo } from './lib/payment-factory.js';
|
|
7
|
+
// API handlers
|
|
8
|
+
export { createCheckoutHandler } from './api/checkout.route.js';
|
|
9
|
+
export { createPaymentHandlers } from './api/payments.route.js';
|
|
10
|
+
// Module info
|
|
11
|
+
export { getSchemas, moduleInfo } from './lib/module-info.js';
|
|
12
|
+
// Registration
|
|
13
|
+
export { paymentModuleRegistration } from './register.js';
|
|
14
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,wCAAwC;AAExC,SAAS;AACT,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE1F,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAE3E,eAAe;AACf,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAE7D,eAAe;AACf,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export type PaymentStatus = 'pending' | 'paid' | 'refunded' | 'failed';
|
|
2
|
+
export type PaymentMethodType = 'card' | 'transfer' | 'cash' | 'tpe';
|
|
3
|
+
export interface PaymentConfig {
|
|
4
|
+
/** Default currency code (e.g. 'USD', 'EUR', 'DZD') */
|
|
5
|
+
currency: string;
|
|
6
|
+
/** Stripe secret key (server-side only) */
|
|
7
|
+
stripeSecretKey?: string;
|
|
8
|
+
/** Stripe public key (client-side) */
|
|
9
|
+
stripePublicKey?: string;
|
|
10
|
+
/** Stripe webhook signing secret */
|
|
11
|
+
stripeWebhookSecret?: string;
|
|
12
|
+
/** URL template for successful payment — {orderId} is replaced */
|
|
13
|
+
successUrlTemplate: string;
|
|
14
|
+
/** URL template for cancelled payment — {orderId} is replaced */
|
|
15
|
+
cancelUrlTemplate: string;
|
|
16
|
+
/** Available payment methods */
|
|
17
|
+
methods?: PaymentMethodType[];
|
|
18
|
+
/** Bank transfer details (for transfer method) */
|
|
19
|
+
bankInfo?: {
|
|
20
|
+
rib: string;
|
|
21
|
+
bankName: string;
|
|
22
|
+
holder: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface LineItem {
|
|
26
|
+
/** Product/service name */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Optional description */
|
|
29
|
+
description?: string;
|
|
30
|
+
/** Unit amount in currency base units (NOT cents — conversion is handled internally) */
|
|
31
|
+
unitAmount: number;
|
|
32
|
+
/** Quantity */
|
|
33
|
+
quantity: number;
|
|
34
|
+
}
|
|
35
|
+
export interface CheckoutRequest {
|
|
36
|
+
/** Unique order/reservation identifier */
|
|
37
|
+
orderId: string;
|
|
38
|
+
/** Items to pay for */
|
|
39
|
+
lineItems: LineItem[];
|
|
40
|
+
/** Override default currency */
|
|
41
|
+
currency?: string;
|
|
42
|
+
/** Override return URL */
|
|
43
|
+
returnUrl?: string;
|
|
44
|
+
/** Additional metadata for Stripe */
|
|
45
|
+
metadata?: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
export interface CheckoutResult {
|
|
48
|
+
/** Stripe checkout URL (redirect user here) */
|
|
49
|
+
url: string | null;
|
|
50
|
+
/** Stripe session ID */
|
|
51
|
+
sessionId: string;
|
|
52
|
+
}
|
|
53
|
+
export interface OrderSummary {
|
|
54
|
+
/** Display title (e.g. "Reservation #12345") */
|
|
55
|
+
title: string;
|
|
56
|
+
/** Description lines */
|
|
57
|
+
lines: {
|
|
58
|
+
label: string;
|
|
59
|
+
value: string;
|
|
60
|
+
}[];
|
|
61
|
+
/** Total amount */
|
|
62
|
+
amount: number;
|
|
63
|
+
/** Currency code */
|
|
64
|
+
currency: string;
|
|
65
|
+
}
|
|
66
|
+
export interface PaymentDTO {
|
|
67
|
+
id: string;
|
|
68
|
+
amount: number;
|
|
69
|
+
currency: string;
|
|
70
|
+
method: PaymentMethodType;
|
|
71
|
+
status: PaymentStatus;
|
|
72
|
+
transactionRef?: string;
|
|
73
|
+
paidAt?: Date;
|
|
74
|
+
orderId?: string;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAA;AACtE,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,CAAA;AAEpE,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAA;IAChB,2CAA2C;IAC3C,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sCAAsC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,oCAAoC;IACpC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,kEAAkE;IAClE,kBAAkB,EAAE,MAAM,CAAA;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AAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,iBAAiB,CAAA;IACzB,MAAM,EAAE,aAAa,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,IAAI,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,wCAAwC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mostajs/payment",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Payment module for @mostajs — Stripe checkout, multi-method (card, transfer, cash), multi-currency",
|
|
5
|
+
"author": "Dr Hamid MADANI <drmdh@msn.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./server": {
|
|
17
|
+
"types": "./dist/server.d.ts",
|
|
18
|
+
"import": "./dist/server.js",
|
|
19
|
+
"default": "./dist/server.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"dev": "tsc --watch",
|
|
29
|
+
"prepublishOnly": "npm run build"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"stripe": "^17.0.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@mostajs/orm": ">=1.8.0",
|
|
36
|
+
"react": ">=18.0.0",
|
|
37
|
+
"next": ">=14.0.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependenciesMeta": {
|
|
40
|
+
"react": { "optional": true },
|
|
41
|
+
"next": { "optional": true }
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@mostajs/orm": "^1.8.0",
|
|
45
|
+
"@types/node": "^22.0.0",
|
|
46
|
+
"@types/react": "^19.0.0",
|
|
47
|
+
"next": "^15.0.0",
|
|
48
|
+
"react": "^19.0.0",
|
|
49
|
+
"typescript": "^5.7.0"
|
|
50
|
+
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/apolocine/mosta-payment"
|
|
54
|
+
},
|
|
55
|
+
"keywords": [
|
|
56
|
+
"mostajs",
|
|
57
|
+
"payment",
|
|
58
|
+
"stripe",
|
|
59
|
+
"checkout",
|
|
60
|
+
"multi-currency",
|
|
61
|
+
"orm"
|
|
62
|
+
]
|
|
63
|
+
}
|