awesome-node-checkout 1.0.1 → 1.0.2
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/dist/abstract/base-payment-provider.abstract.d.ts +30 -0
- package/dist/abstract/base-payment-provider.abstract.d.ts.map +1 -0
- package/dist/abstract/base-payment-provider.abstract.js +28 -0
- package/dist/abstract/base-payment-provider.abstract.js.map +1 -0
- package/dist/adapters/express/index.d.ts +35 -0
- package/dist/adapters/express/index.d.ts.map +1 -0
- package/dist/adapters/express/index.js +129 -0
- package/dist/adapters/express/index.js.map +1 -0
- package/dist/checkout-configurator.d.ts +66 -0
- package/dist/checkout-configurator.d.ts.map +1 -0
- package/dist/checkout-configurator.js +148 -0
- package/dist/checkout-configurator.js.map +1 -0
- package/dist/events/checkout-event-bus.d.ts +29 -0
- package/dist/events/checkout-event-bus.d.ts.map +1 -0
- package/dist/events/checkout-event-bus.js +37 -0
- package/dist/events/checkout-event-bus.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/payment-provider.interface.d.ts +33 -0
- package/dist/interfaces/payment-provider.interface.d.ts.map +1 -0
- package/dist/interfaces/payment-provider.interface.js +3 -0
- package/dist/interfaces/payment-provider.interface.js.map +1 -0
- package/dist/interfaces/transaction-store.interface.d.ts +24 -0
- package/dist/interfaces/transaction-store.interface.d.ts.map +1 -0
- package/dist/interfaces/transaction-store.interface.js +3 -0
- package/dist/interfaces/transaction-store.interface.js.map +1 -0
- package/dist/models/checkout-config.model.d.ts +12 -0
- package/dist/models/checkout-config.model.d.ts.map +1 -0
- package/dist/models/checkout-config.model.js +3 -0
- package/dist/models/checkout-config.model.js.map +1 -0
- package/dist/models/errors.d.ts +7 -0
- package/dist/models/errors.d.ts.map +1 -0
- package/dist/models/errors.js +17 -0
- package/dist/models/errors.js.map +1 -0
- package/dist/models/payment-request.model.d.ts +21 -0
- package/dist/models/payment-request.model.d.ts.map +1 -0
- package/dist/models/payment-request.model.js +3 -0
- package/dist/models/payment-request.model.js.map +1 -0
- package/dist/models/payment-result.model.d.ts +23 -0
- package/dist/models/payment-result.model.d.ts.map +1 -0
- package/dist/models/payment-result.model.js +3 -0
- package/dist/models/payment-result.model.js.map +1 -0
- package/dist/providers/nexi/nexi.provider.d.ts +64 -0
- package/dist/providers/nexi/nexi.provider.d.ts.map +1 -0
- package/dist/providers/nexi/nexi.provider.js +227 -0
- package/dist/providers/nexi/nexi.provider.js.map +1 -0
- package/dist/providers/paypal/paypal.provider.d.ts +33 -0
- package/dist/providers/paypal/paypal.provider.d.ts.map +1 -0
- package/dist/providers/paypal/paypal.provider.js +167 -0
- package/dist/providers/paypal/paypal.provider.js.map +1 -0
- package/dist/providers/satispay/satispay.provider.d.ts +79 -0
- package/dist/providers/satispay/satispay.provider.d.ts.map +1 -0
- package/dist/providers/satispay/satispay.provider.js +301 -0
- package/dist/providers/satispay/satispay.provider.js.map +1 -0
- package/dist/stores/in-memory-transaction.store.d.ts +17 -0
- package/dist/stores/in-memory-transaction.store.d.ts.map +1 -0
- package/dist/stores/in-memory-transaction.store.js +30 -0
- package/dist/stores/in-memory-transaction.store.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-provider.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/payment-provider.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5D,MAAM,WAAW,gBAAgB;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAE3B,8FAA8F;IAC9F,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAE/D,mDAAmD;IACnD,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAEzF,2DAA2D;IAC3D,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAE7D,4DAA4D;IAC5D,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAE1E;;;OAGG;IACH,aAAa,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAEvG;;;OAGG;IACH,cAAc,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-provider.interface.js","sourceRoot":"","sources":["../../src/interfaces/payment-provider.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arbitrary data associated with a transaction.
|
|
3
|
+
* Extended by providers that need to persist state across async flows
|
|
4
|
+
* (e.g. correlating a Satispay webhook with the original order).
|
|
5
|
+
*/
|
|
6
|
+
export interface TransactionData {
|
|
7
|
+
provider: string;
|
|
8
|
+
orderId?: string;
|
|
9
|
+
paymentId?: string;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
metadata?: Record<string, any>;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Abstraction over transaction state persistence.
|
|
16
|
+
* Built-in: InMemoryTransactionStore.
|
|
17
|
+
* Implement this interface to use Redis, PostgreSQL, MongoDB, etc.
|
|
18
|
+
*/
|
|
19
|
+
export interface ITransactionStore {
|
|
20
|
+
save(key: string, data: TransactionData): Promise<void>;
|
|
21
|
+
get(key: string): Promise<TransactionData | null>;
|
|
22
|
+
delete(key: string): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=transaction-store.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-store.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/transaction-store.interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IAClD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-store.interface.js","sourceRoot":"","sources":["../../src/interfaces/transaction-store.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global configuration for CheckoutConfigurator.
|
|
3
|
+
*/
|
|
4
|
+
export interface CheckoutConfig {
|
|
5
|
+
/**
|
|
6
|
+
* When `true`, the event bus emits lifecycle events for every payment
|
|
7
|
+
* operation (payment.created, payment.completed, payment.failed, etc.).
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
emitEvents?: boolean;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=checkout-config.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout-config.model.d.ts","sourceRoot":"","sources":["../../src/models/checkout-config.model.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout-config.model.js","sourceRoot":"","sources":["../../src/models/checkout-config.model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type CheckoutErrorCode = 'PROVIDER_NOT_FOUND' | 'PROVIDER_ALREADY_REGISTERED' | 'PAYMENT_FAILED' | 'WEBHOOK_NOT_SUPPORTED' | 'REDIRECT_NOT_SUPPORTED' | 'TRANSACTION_NOT_FOUND';
|
|
2
|
+
export declare class CheckoutError extends Error {
|
|
3
|
+
readonly code: CheckoutErrorCode;
|
|
4
|
+
readonly provider?: string | undefined;
|
|
5
|
+
constructor(message: string, code: CheckoutErrorCode, provider?: string | undefined);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/models/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB,oBAAoB,GACpB,6BAA6B,GAC7B,gBAAgB,GAChB,uBAAuB,GACvB,wBAAwB,GACxB,uBAAuB,CAAC;AAE5B,qBAAa,aAAc,SAAQ,KAAK;aAGpB,IAAI,EAAE,iBAAiB;aACvB,QAAQ,CAAC,EAAE,MAAM;gBAFjC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,iBAAiB,EACvB,QAAQ,CAAC,EAAE,MAAM,YAAA;CASpC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CheckoutError = void 0;
|
|
4
|
+
class CheckoutError extends Error {
|
|
5
|
+
constructor(message, code, provider) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.provider = provider;
|
|
9
|
+
this.name = 'CheckoutError';
|
|
10
|
+
// Maintains proper stack trace in V8
|
|
11
|
+
if (Error.captureStackTrace) {
|
|
12
|
+
Error.captureStackTrace(this, CheckoutError);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.CheckoutError = CheckoutError;
|
|
17
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/models/errors.ts"],"names":[],"mappings":";;;AAQA,MAAa,aAAc,SAAQ,KAAK;IACtC,YACE,OAAe,EACC,IAAuB,EACvB,QAAiB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAmB;QACvB,aAAQ,GAAR,QAAQ,CAAS;QAGjC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,qCAAqC;QACrC,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;CACF;AAbD,sCAaC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified payment request passed to any provider.
|
|
3
|
+
* All monetary values are in major currency units (e.g. 9.99 for €9.99).
|
|
4
|
+
*/
|
|
5
|
+
export interface PaymentRequest {
|
|
6
|
+
/** Amount in major currency units (e.g. 9.99) */
|
|
7
|
+
amount: number;
|
|
8
|
+
/** ISO 4217 currency code (e.g. 'EUR', 'USD') */
|
|
9
|
+
currency: string;
|
|
10
|
+
/** Human-readable description of the payment */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** URL to redirect the user to after a successful payment */
|
|
13
|
+
returnUrl: string;
|
|
14
|
+
/** URL to redirect the user to if the payment is cancelled */
|
|
15
|
+
cancelUrl: string;
|
|
16
|
+
/** External order identifier from the merchant's system */
|
|
17
|
+
orderId?: string;
|
|
18
|
+
/** Arbitrary key-value pairs forwarded to the provider when supported */
|
|
19
|
+
metadata?: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=payment-request.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-request.model.d.ts","sourceRoot":"","sources":["../../src/models/payment-request.model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IAEf,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IAEjB,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAElB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAElB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-request.model.js","sourceRoot":"","sources":["../../src/models/payment-request.model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Unified result returned by all payment operations */
|
|
2
|
+
export interface PaymentResult {
|
|
3
|
+
success: boolean;
|
|
4
|
+
/** Provider-specific payment identifier */
|
|
5
|
+
paymentId?: string;
|
|
6
|
+
/** Redirect URL for the user (redirect-flow providers: PayPal, Nexi) */
|
|
7
|
+
approvalUrl?: string;
|
|
8
|
+
/** Current payment status (provider-specific string, e.g. 'COMPLETED', 'ACCEPTED') */
|
|
9
|
+
status?: string;
|
|
10
|
+
/** Error message if success is false */
|
|
11
|
+
error?: string;
|
|
12
|
+
/** Raw provider response — useful for debugging or provider-specific fields */
|
|
13
|
+
raw?: any;
|
|
14
|
+
}
|
|
15
|
+
/** Result returned by handleWebhook() */
|
|
16
|
+
export interface WebhookResult {
|
|
17
|
+
success: boolean;
|
|
18
|
+
paymentId?: string;
|
|
19
|
+
status?: string;
|
|
20
|
+
error?: string;
|
|
21
|
+
raw?: any;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=payment-result.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-result.model.d.ts","sourceRoot":"","sources":["../../src/models/payment-result.model.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IAEjB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,+EAA+E;IAC/E,GAAG,CAAC,EAAE,GAAG,CAAC;CACX;AAED,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,GAAG,CAAC;CACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-result.model.js","sourceRoot":"","sources":["../../src/models/payment-result.model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { BasePaymentProvider } from '../../abstract/base-payment-provider.abstract';
|
|
2
|
+
import { PaymentRequest } from '../../models/payment-request.model';
|
|
3
|
+
import { PaymentResult } from '../../models/payment-result.model';
|
|
4
|
+
export interface NexiProviderConfig {
|
|
5
|
+
merchantId: string;
|
|
6
|
+
macKey: string;
|
|
7
|
+
/** Optional group identifier */
|
|
8
|
+
group?: string;
|
|
9
|
+
/** @default 'sandbox' */
|
|
10
|
+
environment?: 'sandbox' | 'production';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Nexi eCommerce provider.
|
|
14
|
+
* Flow: `redirect` — builds a signed checkout URL, redirects the user to Nexi,
|
|
15
|
+
* then handles the POST-back via `handleRedirect`.
|
|
16
|
+
*
|
|
17
|
+
* Note: Nexi XPay mandates SHA-1 for MAC computation. This is a requirement of
|
|
18
|
+
* the Nexi API and cannot be changed on the client side.
|
|
19
|
+
*/
|
|
20
|
+
export declare class NexiProvider extends BasePaymentProvider {
|
|
21
|
+
private readonly config;
|
|
22
|
+
readonly name = "nexi";
|
|
23
|
+
readonly flow: "redirect";
|
|
24
|
+
private readonly apiUrl;
|
|
25
|
+
constructor(config: NexiProviderConfig);
|
|
26
|
+
/**
|
|
27
|
+
* Computes the SHA-1 MAC required by Nexi to authenticate the payment request.
|
|
28
|
+
* Format: `codTrans={val}divisa={val}importo={val}{macKey}`
|
|
29
|
+
*
|
|
30
|
+
* SHA-1 is used here because Nexi XPay mandates it for MAC computation.
|
|
31
|
+
*/
|
|
32
|
+
private generateMac;
|
|
33
|
+
/**
|
|
34
|
+
* Computes the SHA-1 MAC for the status (getPaymentDetails) API call.
|
|
35
|
+
* Format: `alias={alias}codTrans={codTrans}timestamp={timestamp}{macKey}`
|
|
36
|
+
*/
|
|
37
|
+
private generateStatusMac;
|
|
38
|
+
/**
|
|
39
|
+
* Computes the SHA-1 MAC for the refund (storno) API call.
|
|
40
|
+
* Format: `alias={alias}codTrans={codTrans}importo={importo}timestamp={timestamp}{macKey}`
|
|
41
|
+
*/
|
|
42
|
+
private generateRefundMac;
|
|
43
|
+
/**
|
|
44
|
+
* Verifies the SHA-1 MAC included in a Nexi POST-back response.
|
|
45
|
+
* Format: `codTrans={val}esito={val}importo={val}divisa={val}{macKey}`
|
|
46
|
+
*/
|
|
47
|
+
private verifyResponseMac;
|
|
48
|
+
createPayment(request: PaymentRequest): Promise<PaymentResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Validates the POST-back data from Nexi.
|
|
51
|
+
* `data` is the query/body object sent by Nexi to the returnUrl.
|
|
52
|
+
* The MAC is verified before the result is considered authoritative.
|
|
53
|
+
*/
|
|
54
|
+
executePayment(paymentId: string, data?: Record<string, string>): Promise<PaymentResult>;
|
|
55
|
+
getPaymentDetails(paymentId: string): Promise<PaymentResult>;
|
|
56
|
+
refundPayment(paymentId: string, amount?: number): Promise<PaymentResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Handles the POST-back from Nexi to the returnUrl.
|
|
59
|
+
* Nexi sends `esito`, `codTrans`, `importo`, `divisa`, `mac`, etc. as query/body params.
|
|
60
|
+
* The MAC is verified to ensure the response was not spoofed.
|
|
61
|
+
*/
|
|
62
|
+
handleRedirect(query: Record<string, string>): Promise<PaymentResult>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=nexi.provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nexi.provider.d.ts","sourceRoot":"","sources":["../../../src/providers/nexi/nexi.provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,aAA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, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.NexiProvider = void 0;
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
38
|
+
const base_payment_provider_abstract_1 = require("../../abstract/base-payment-provider.abstract");
|
|
39
|
+
/**
|
|
40
|
+
* Nexi eCommerce provider.
|
|
41
|
+
* Flow: `redirect` — builds a signed checkout URL, redirects the user to Nexi,
|
|
42
|
+
* then handles the POST-back via `handleRedirect`.
|
|
43
|
+
*
|
|
44
|
+
* Note: Nexi XPay mandates SHA-1 for MAC computation. This is a requirement of
|
|
45
|
+
* the Nexi API and cannot be changed on the client side.
|
|
46
|
+
*/
|
|
47
|
+
class NexiProvider extends base_payment_provider_abstract_1.BasePaymentProvider {
|
|
48
|
+
constructor(config) {
|
|
49
|
+
super();
|
|
50
|
+
this.config = config;
|
|
51
|
+
this.name = 'nexi';
|
|
52
|
+
this.flow = 'redirect';
|
|
53
|
+
this.apiUrl =
|
|
54
|
+
config.environment === 'production'
|
|
55
|
+
? 'https://ecommerce.nexi.it'
|
|
56
|
+
: 'https://int-ecommerce.nexi.it';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Computes the SHA-1 MAC required by Nexi to authenticate the payment request.
|
|
60
|
+
* Format: `codTrans={val}divisa={val}importo={val}{macKey}`
|
|
61
|
+
*
|
|
62
|
+
* SHA-1 is used here because Nexi XPay mandates it for MAC computation.
|
|
63
|
+
*/
|
|
64
|
+
generateMac(codTrans, divisa, importoCents) {
|
|
65
|
+
const raw = `codTrans=${codTrans}divisa=${divisa}importo=${importoCents}${this.config.macKey}`;
|
|
66
|
+
return crypto.createHash('sha1').update(raw).digest('hex');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Computes the SHA-1 MAC for the status (getPaymentDetails) API call.
|
|
70
|
+
* Format: `alias={alias}codTrans={codTrans}timestamp={timestamp}{macKey}`
|
|
71
|
+
*/
|
|
72
|
+
generateStatusMac(alias, codTrans, timestamp) {
|
|
73
|
+
const raw = `alias=${alias}codTrans=${codTrans}timestamp=${timestamp}${this.config.macKey}`;
|
|
74
|
+
return crypto.createHash('sha1').update(raw).digest('hex');
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Computes the SHA-1 MAC for the refund (storno) API call.
|
|
78
|
+
* Format: `alias={alias}codTrans={codTrans}importo={importo}timestamp={timestamp}{macKey}`
|
|
79
|
+
*/
|
|
80
|
+
generateRefundMac(alias, codTrans, importo, timestamp) {
|
|
81
|
+
const raw = `alias=${alias}codTrans=${codTrans}importo=${importo}timestamp=${timestamp}${this.config.macKey}`;
|
|
82
|
+
return crypto.createHash('sha1').update(raw).digest('hex');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Verifies the SHA-1 MAC included in a Nexi POST-back response.
|
|
86
|
+
* Format: `codTrans={val}esito={val}importo={val}divisa={val}{macKey}`
|
|
87
|
+
*/
|
|
88
|
+
verifyResponseMac(codTrans, esito, importo, divisa, mac) {
|
|
89
|
+
const raw = `codTrans=${codTrans}esito=${esito}importo=${importo}divisa=${divisa}${this.config.macKey}`;
|
|
90
|
+
const expected = crypto.createHash('sha1').update(raw).digest('hex');
|
|
91
|
+
return crypto.timingSafeEqual(Buffer.from(expected, 'hex'), Buffer.from(mac, 'hex'));
|
|
92
|
+
}
|
|
93
|
+
async createPayment(request) {
|
|
94
|
+
try {
|
|
95
|
+
const amountCents = Math.round(request.amount * 100);
|
|
96
|
+
const orderId = request.orderId ?? `ORD-${Date.now()}`;
|
|
97
|
+
const mac = this.generateMac(orderId, request.currency, amountCents);
|
|
98
|
+
const params = {
|
|
99
|
+
alias: this.config.merchantId,
|
|
100
|
+
importo: amountCents.toString(),
|
|
101
|
+
divisa: request.currency,
|
|
102
|
+
codTrans: orderId,
|
|
103
|
+
url: request.returnUrl,
|
|
104
|
+
url_back: request.cancelUrl,
|
|
105
|
+
mac,
|
|
106
|
+
};
|
|
107
|
+
if (this.config.group) {
|
|
108
|
+
params.gruppo = this.config.group;
|
|
109
|
+
}
|
|
110
|
+
const approvalUrl = `${this.apiUrl}/ecomm/ecomm/DispatcherServlet?${new URLSearchParams(params)}`;
|
|
111
|
+
return {
|
|
112
|
+
success: true,
|
|
113
|
+
paymentId: orderId,
|
|
114
|
+
approvalUrl,
|
|
115
|
+
status: 'CREATED',
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
return this.errorResult(error, 'Failed to create Nexi payment');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Validates the POST-back data from Nexi.
|
|
124
|
+
* `data` is the query/body object sent by Nexi to the returnUrl.
|
|
125
|
+
* The MAC is verified before the result is considered authoritative.
|
|
126
|
+
*/
|
|
127
|
+
async executePayment(paymentId, data) {
|
|
128
|
+
try {
|
|
129
|
+
const esito = data?.esito ?? '';
|
|
130
|
+
const codTrans = data?.codTrans ?? paymentId;
|
|
131
|
+
const importo = data?.importo ?? '';
|
|
132
|
+
const divisa = data?.divisa ?? '';
|
|
133
|
+
const mac = data?.mac ?? '';
|
|
134
|
+
if (mac) {
|
|
135
|
+
let macValid;
|
|
136
|
+
try {
|
|
137
|
+
macValid = this.verifyResponseMac(codTrans, esito, importo, divisa, mac);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
macValid = false;
|
|
141
|
+
}
|
|
142
|
+
if (!macValid) {
|
|
143
|
+
return {
|
|
144
|
+
success: false,
|
|
145
|
+
paymentId: codTrans,
|
|
146
|
+
status: 'FAILED',
|
|
147
|
+
error: 'MAC verification failed: response may have been tampered with',
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
success: esito === 'OK',
|
|
153
|
+
paymentId: codTrans,
|
|
154
|
+
status: esito === 'OK' ? 'COMPLETED' : 'FAILED',
|
|
155
|
+
raw: data,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
return this.errorResult(error, 'Failed to execute Nexi payment');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async getPaymentDetails(paymentId) {
|
|
163
|
+
try {
|
|
164
|
+
const timestamp = new Date().toISOString();
|
|
165
|
+
const mac = this.generateStatusMac(this.config.merchantId, paymentId, timestamp);
|
|
166
|
+
const params = {
|
|
167
|
+
alias: this.config.merchantId,
|
|
168
|
+
codTrans: paymentId,
|
|
169
|
+
timestamp,
|
|
170
|
+
mac,
|
|
171
|
+
};
|
|
172
|
+
const response = await fetch(`${this.apiUrl}/ecomm/api/vas/igfs/status/plain`, {
|
|
173
|
+
method: 'POST',
|
|
174
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
175
|
+
body: new URLSearchParams(params),
|
|
176
|
+
});
|
|
177
|
+
if (!response.ok)
|
|
178
|
+
throw new Error(`Nexi API error: ${response.statusText}`);
|
|
179
|
+
const result = await response.json();
|
|
180
|
+
return { success: true, paymentId, status: result['status'], raw: result };
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
return this.errorResult(error, 'Failed to get Nexi payment details');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async refundPayment(paymentId, amount) {
|
|
187
|
+
try {
|
|
188
|
+
const timestamp = new Date().toISOString();
|
|
189
|
+
const importo = amount ? Math.round(amount * 100).toString() : '';
|
|
190
|
+
const mac = this.generateRefundMac(this.config.merchantId, paymentId, importo, timestamp);
|
|
191
|
+
const params = {
|
|
192
|
+
alias: this.config.merchantId,
|
|
193
|
+
codTrans: paymentId,
|
|
194
|
+
importo,
|
|
195
|
+
timestamp,
|
|
196
|
+
mac,
|
|
197
|
+
};
|
|
198
|
+
const response = await fetch(`${this.apiUrl}/ecomm/api/vas/igfs/storno/plain`, {
|
|
199
|
+
method: 'POST',
|
|
200
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
201
|
+
body: new URLSearchParams(params),
|
|
202
|
+
});
|
|
203
|
+
if (!response.ok)
|
|
204
|
+
throw new Error(`Nexi API error: ${response.statusText}`);
|
|
205
|
+
const result = await response.json();
|
|
206
|
+
return {
|
|
207
|
+
success: result['esito'] === 'OK',
|
|
208
|
+
paymentId,
|
|
209
|
+
status: result['esito'] === 'OK' ? 'REFUNDED' : 'REFUND_FAILED',
|
|
210
|
+
raw: result,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
return this.errorResult(error, 'Failed to refund Nexi payment');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Handles the POST-back from Nexi to the returnUrl.
|
|
219
|
+
* Nexi sends `esito`, `codTrans`, `importo`, `divisa`, `mac`, etc. as query/body params.
|
|
220
|
+
* The MAC is verified to ensure the response was not spoofed.
|
|
221
|
+
*/
|
|
222
|
+
async handleRedirect(query) {
|
|
223
|
+
return this.executePayment(query['codTrans'] ?? '', query);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
exports.NexiProvider = NexiProvider;
|
|
227
|
+
//# sourceMappingURL=nexi.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nexi.provider.js","sourceRoot":"","sources":["../../../src/providers/nexi/nexi.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AACjC,kGAAoF;AAapF;;;;;;;GAOG;AACH,MAAa,YAAa,SAAQ,oDAAmB;IAMnD,YAA6B,MAA0B;QACrD,KAAK,EAAE,CAAC;QADmB,WAAM,GAAN,MAAM,CAAoB;QAL9C,SAAI,GAAG,MAAM,CAAC;QACd,SAAI,GAAG,UAAmB,CAAC;QAMlC,IAAI,CAAC,MAAM;YACT,MAAM,CAAC,WAAW,KAAK,YAAY;gBACjC,CAAC,CAAC,2BAA2B;gBAC7B,CAAC,CAAC,+BAA+B,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACK,WAAW,CAAC,QAAgB,EAAE,MAAc,EAAE,YAAoB;QACxE,MAAM,GAAG,GAAG,YAAY,QAAQ,UAAU,MAAM,WAAW,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAC/F,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAA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A2B;gBACrC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;gBAC7B,QAAQ,EAAE,SAAS;gBACnB,OAAO;gBACP,SAAS;gBACT,GAAG;aACJ,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,kCAAkC,EAAE;gBAC7E,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,mCAAmC,EAAE;gBAChE,IAAI,EAAE,IAAI,eAAe,CAAC,MAAM,CAAC;aAClC,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;YAC5E,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAA6B,CAAC;YAEhE,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI;gBACjC,SAAS;gBACT,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe;gBAC/D,GAAG,EAAE,MAAM;aACZ,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,+BAA+B,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,cAAc,CAAC,KAA6B;QAChD,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC;CACF;AA/MD,oCA+MC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BasePaymentProvider } from '../../abstract/base-payment-provider.abstract';
|
|
2
|
+
import { PaymentRequest } from '../../models/payment-request.model';
|
|
3
|
+
import { PaymentResult } from '../../models/payment-result.model';
|
|
4
|
+
export interface PayPalProviderConfig {
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
/** @default 'sandbox' */
|
|
8
|
+
environment?: 'sandbox' | 'live';
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* PayPal Checkout provider.
|
|
12
|
+
* Flow: `redirect` — creates an order, redirects the user to PayPal,
|
|
13
|
+
* then captures the payment on return via `handleRedirect`.
|
|
14
|
+
*/
|
|
15
|
+
export declare class PayPalProvider extends BasePaymentProvider {
|
|
16
|
+
private readonly config;
|
|
17
|
+
readonly name = "paypal";
|
|
18
|
+
readonly flow: "redirect";
|
|
19
|
+
private client;
|
|
20
|
+
private ordersController;
|
|
21
|
+
private paymentsController;
|
|
22
|
+
constructor(config: PayPalProviderConfig);
|
|
23
|
+
createPayment(request: PaymentRequest): Promise<PaymentResult>;
|
|
24
|
+
executePayment(paymentId: string): Promise<PaymentResult>;
|
|
25
|
+
getPaymentDetails(paymentId: string): Promise<PaymentResult>;
|
|
26
|
+
refundPayment(paymentId: string, amount?: number): Promise<PaymentResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Handles the redirect from PayPal after the user approves the payment.
|
|
29
|
+
* PayPal appends `token` (order ID) and `PayerID` to the returnUrl.
|
|
30
|
+
*/
|
|
31
|
+
handleRedirect(query: Record<string, string>): Promise<PaymentResult>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=paypal.provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paypal.provider.d.ts","sourceRoot":"","sources":["../../../src/providers/paypal/paypal.provider.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,WAAW,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;CAClC;AAED;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,mBAAmB;IAQzC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPnC,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,IAAI,EAAG,UAAU,CAAU;IAEpC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,kBAAkB,CAAqB;gBAElB,MAAM,EAAE,oBAAoB;IAoBnD,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IA0C9D,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAkBzD,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAiB5D,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAuD/E;;;OAGG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;CAU5E"}
|