@fanth/paymentic-sdk 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/LICENSE +7 -0
- package/README.md +57 -0
- package/dist/client.d.ts +24 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.test.d.ts +2 -0
- package/dist/client.test.d.ts.map +1 -0
- package/dist/index.cjs +107 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +148 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2026 Fanth
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @fanth/paymentic-sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the [Paymentic REST API](https://docs.paymentic.com/api/v1.2/payment-api/paymentic-payment-api).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @fanth/paymentic-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
With [pnpm](https://pnpm.io/):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add @fanth/paymentic-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
See examples in [examples](./examples) directory.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { PaymenticClient } from "@fanth/paymentic-sdk";
|
|
23
|
+
|
|
24
|
+
const client = new PaymenticClient({
|
|
25
|
+
pointId: "...",
|
|
26
|
+
apiToken: "...",
|
|
27
|
+
signatureKey: "...",
|
|
28
|
+
sandbox: true,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const transaction = await client.createTransaction({
|
|
32
|
+
amount: "1000",
|
|
33
|
+
currency: "PLN",
|
|
34
|
+
title: "Order #1",
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Webhook notifications
|
|
39
|
+
|
|
40
|
+
Use `parseWebhook` to verify and parse incoming Paymentic webhook calls. It checks the `X-Paymentic-Signature` header against the raw body and throws `PaymenticInvalidSignatureError` if it's missing or invalid.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
// e.g. a Next.js route handler / any Request-based HTTP framework
|
|
44
|
+
export async function POST(request: Request) {
|
|
45
|
+
const notification = await client.parseWebhook(request);
|
|
46
|
+
|
|
47
|
+
if (notification.event === "PAYMENT.TRANSACTION_STATUS_CHANGED" && notification.status === "PAID") {
|
|
48
|
+
// mark the order as paid
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return new Response(null, { status: 200 });
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
> Note: `parseWebhook` reads the body via `request.text()`, so pass it the raw `Request` before any other code consumes the body.
|
|
56
|
+
|
|
57
|
+
> Note: Not all endpoints are implemented yet. If you need an endpoint that is not implemented, feel free to open up a pull request :)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PaymenticCreateTransactionRequest, PaymenticCreateTransactionResponse, PaymenticWebhookNotification } from "./types.js";
|
|
2
|
+
export interface PaymenticConfig {
|
|
3
|
+
pointId: string;
|
|
4
|
+
apiToken: string;
|
|
5
|
+
signatureKey: string;
|
|
6
|
+
sandbox: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class PaymenticInvalidSignatureError extends Error {
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
export declare class PaymenticClient {
|
|
12
|
+
private readonly config;
|
|
13
|
+
private readonly api;
|
|
14
|
+
private readonly baseUrl;
|
|
15
|
+
constructor(config: PaymenticConfig);
|
|
16
|
+
createTransaction(body: PaymenticCreateTransactionRequest): Promise<PaymenticCreateTransactionResponse>;
|
|
17
|
+
private isValidSignature;
|
|
18
|
+
/**
|
|
19
|
+
* Verifies and parses an incoming Paymentic webhook request.
|
|
20
|
+
* Throws PaymenticInvalidSignatureError if the signature does not match.
|
|
21
|
+
*/
|
|
22
|
+
parseWebhook(request: Request): Promise<PaymenticWebhookNotification>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,iCAAiC,EACjC,kCAAkC,EAElC,4BAA4B,EAC/B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,eAAe;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,8BAA+B,SAAQ,KAAK;IACrD,cAEC;CACJ;AAED,qBAAa,eAAe;IAIZ,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC,YAA6B,MAAM,EAAE,eAAe,EAenD;IAEK,iBAAiB,CAAC,IAAI,EAAE,iCAAiC,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAM5G;IAED,OAAO,CAAC,gBAAgB;IAexB;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAgB1E;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../src/client.test.ts"],"names":[],"mappings":""}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
PaymenticClient: () => PaymenticClient,
|
|
34
|
+
PaymenticInvalidSignatureError: () => PaymenticInvalidSignatureError
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
|
|
38
|
+
// src/client.ts
|
|
39
|
+
var import_axios = __toESM(require("axios"), 1);
|
|
40
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
41
|
+
var PaymenticInvalidSignatureError = class extends Error {
|
|
42
|
+
constructor() {
|
|
43
|
+
super("Invalid Paymentic webhook signature");
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var PaymenticClient = class {
|
|
47
|
+
constructor(config) {
|
|
48
|
+
this.config = config;
|
|
49
|
+
this.baseUrl = this.config.sandbox ? "https://api.sandbox.paymentic.com/v1_2" : "https://api.paymentic.com/v1_2";
|
|
50
|
+
this.api = import_axios.default.create({
|
|
51
|
+
baseURL: this.baseUrl,
|
|
52
|
+
headers: {
|
|
53
|
+
Authorization: `Bearer ${this.config.apiToken}`
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
this.api.interceptors.response.use(
|
|
57
|
+
(response) => response,
|
|
58
|
+
(error) => {
|
|
59
|
+
console.error({ message: "Paymentic API error", errorResponse: error.response?.data });
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
config;
|
|
65
|
+
api;
|
|
66
|
+
baseUrl;
|
|
67
|
+
async createTransaction(body) {
|
|
68
|
+
const response = await this.api.post(
|
|
69
|
+
`/payment/points/${this.config.pointId}/transactions`,
|
|
70
|
+
body
|
|
71
|
+
);
|
|
72
|
+
return response.data;
|
|
73
|
+
}
|
|
74
|
+
isValidSignature(payload, signature) {
|
|
75
|
+
const expected = import_crypto.default.createHmac("sha512", this.config.signatureKey).update(payload, "utf8").digest("base64");
|
|
76
|
+
const expectedBuffer = Buffer.from(expected);
|
|
77
|
+
const signatureBuffer = Buffer.from(signature);
|
|
78
|
+
if (expectedBuffer.length !== signatureBuffer.length) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return import_crypto.default.timingSafeEqual(expectedBuffer, signatureBuffer);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Verifies and parses an incoming Paymentic webhook request.
|
|
85
|
+
* Throws PaymenticInvalidSignatureError if the signature does not match.
|
|
86
|
+
*/
|
|
87
|
+
async parseWebhook(request) {
|
|
88
|
+
const event = request.headers.get("x-paymentic-event");
|
|
89
|
+
const notificationId = request.headers.get("x-paymentic-notification-id") ?? "";
|
|
90
|
+
const time = request.headers.get("x-paymentic-time") ?? "";
|
|
91
|
+
const signature = request.headers.get("x-paymentic-signature") ?? "";
|
|
92
|
+
const version = (request.headers.get("user-agent") ?? "").split("/")[1] ?? "";
|
|
93
|
+
const rawBody = await request.text();
|
|
94
|
+
const signaturePayload = `${event}|${version}|${rawBody}|${notificationId}|${time}`;
|
|
95
|
+
if (!this.isValidSignature(signaturePayload, signature)) {
|
|
96
|
+
throw new PaymenticInvalidSignatureError();
|
|
97
|
+
}
|
|
98
|
+
const body = JSON.parse(rawBody);
|
|
99
|
+
return { ...body, event, notificationId, time };
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
PaymenticClient,
|
|
105
|
+
PaymenticInvalidSignatureError
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts"],"sourcesContent":["export * from \"./client.js\";\nexport * from \"./types.js\";\n","import axios, { AxiosError, type AxiosInstance } from \"axios\";\nimport crypto from \"crypto\";\nimport type {\n PaymenticCreateTransactionRequest,\n PaymenticCreateTransactionResponse,\n PaymenticWebhookEvent,\n PaymenticWebhookNotification,\n} from \"./types.js\";\n\nexport interface PaymenticConfig {\n pointId: string;\n apiToken: string;\n signatureKey: string;\n sandbox: boolean;\n}\n\nexport class PaymenticInvalidSignatureError extends Error {\n constructor() {\n super(\"Invalid Paymentic webhook signature\");\n }\n}\n\nexport class PaymenticClient {\n private readonly api: AxiosInstance;\n private readonly baseUrl: string;\n\n constructor(private readonly config: PaymenticConfig) {\n this.baseUrl = this.config.sandbox ? \"https://api.sandbox.paymentic.com/v1_2\" : \"https://api.paymentic.com/v1_2\";\n this.api = axios.create({\n baseURL: this.baseUrl,\n headers: {\n Authorization: `Bearer ${this.config.apiToken}`,\n },\n });\n this.api.interceptors.response.use(\n (response) => response,\n (error: AxiosError) => {\n console.error({ message: \"Paymentic API error\", errorResponse: error.response?.data });\n throw error;\n }\n );\n }\n\n async createTransaction(body: PaymenticCreateTransactionRequest): Promise<PaymenticCreateTransactionResponse> {\n const response = await this.api.post<PaymenticCreateTransactionResponse>(\n `/payment/points/${this.config.pointId}/transactions`,\n body\n );\n return response.data;\n }\n\n private isValidSignature(payload: string, signature: string): boolean {\n // in php: base64_encode(hash_hmac('sha512', $payload, $signatureKey, true));\n const expected = crypto.createHmac(\"sha512\", this.config.signatureKey).update(payload, \"utf8\").digest(\"base64\");\n\n const expectedBuffer = Buffer.from(expected);\n const signatureBuffer = Buffer.from(signature);\n\n // Length check guards timingSafeEqual, which throws on mismatched lengths\n if (expectedBuffer.length !== signatureBuffer.length) {\n return false;\n }\n\n return crypto.timingSafeEqual(expectedBuffer, signatureBuffer);\n }\n\n /**\n * Verifies and parses an incoming Paymentic webhook request.\n * Throws PaymenticInvalidSignatureError if the signature does not match.\n */\n async parseWebhook(request: Request): Promise<PaymenticWebhookNotification> {\n const event = request.headers.get(\"x-paymentic-event\") as PaymenticWebhookEvent;\n const notificationId = request.headers.get(\"x-paymentic-notification-id\") ?? \"\";\n const time = request.headers.get(\"x-paymentic-time\") ?? \"\";\n const signature = request.headers.get(\"x-paymentic-signature\") ?? \"\";\n // User-Agent is \"Paymentic/<version>\", e.g. \"Paymentic/1.1\"\n const version = (request.headers.get(\"user-agent\") ?? \"\").split(\"/\")[1] ?? \"\";\n\n const rawBody = await request.text();\n const signaturePayload = `${event}|${version}|${rawBody}|${notificationId}|${time}`;\n if (!this.isValidSignature(signaturePayload, signature)) {\n throw new PaymenticInvalidSignatureError();\n }\n\n const body = JSON.parse(rawBody);\n return { ...body, event, notificationId, time };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAsD;AACtD,oBAAmB;AAeZ,IAAM,iCAAN,cAA6C,MAAM;AAAA,EACtD,cAAc;AACV,UAAM,qCAAqC;AAAA,EAC/C;AACJ;AAEO,IAAM,kBAAN,MAAsB;AAAA,EAIzB,YAA6B,QAAyB;AAAzB;AACzB,SAAK,UAAU,KAAK,OAAO,UAAU,2CAA2C;AAChF,SAAK,MAAM,aAAAA,QAAM,OAAO;AAAA,MACpB,SAAS,KAAK;AAAA,MACd,SAAS;AAAA,QACL,eAAe,UAAU,KAAK,OAAO,QAAQ;AAAA,MACjD;AAAA,IACJ,CAAC;AACD,SAAK,IAAI,aAAa,SAAS;AAAA,MAC3B,CAAC,aAAa;AAAA,MACd,CAAC,UAAsB;AACnB,gBAAQ,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O,KAAK,MAAM,OAAO;AAC/B,WAAO,EAAE,GAAG,MAAM,OAAO,gBAAgB,KAAK;AAAA,EAClD;AACJ;","names":["axios","crypto"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import crypto from "crypto";
|
|
4
|
+
var PaymenticInvalidSignatureError = class extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("Invalid Paymentic webhook signature");
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
var PaymenticClient = class {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.baseUrl = this.config.sandbox ? "https://api.sandbox.paymentic.com/v1_2" : "https://api.paymentic.com/v1_2";
|
|
13
|
+
this.api = axios.create({
|
|
14
|
+
baseURL: this.baseUrl,
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${this.config.apiToken}`
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
this.api.interceptors.response.use(
|
|
20
|
+
(response) => response,
|
|
21
|
+
(error) => {
|
|
22
|
+
console.error({ message: "Paymentic API error", errorResponse: error.response?.data });
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
config;
|
|
28
|
+
api;
|
|
29
|
+
baseUrl;
|
|
30
|
+
async createTransaction(body) {
|
|
31
|
+
const response = await this.api.post(
|
|
32
|
+
`/payment/points/${this.config.pointId}/transactions`,
|
|
33
|
+
body
|
|
34
|
+
);
|
|
35
|
+
return response.data;
|
|
36
|
+
}
|
|
37
|
+
isValidSignature(payload, signature) {
|
|
38
|
+
const expected = crypto.createHmac("sha512", this.config.signatureKey).update(payload, "utf8").digest("base64");
|
|
39
|
+
const expectedBuffer = Buffer.from(expected);
|
|
40
|
+
const signatureBuffer = Buffer.from(signature);
|
|
41
|
+
if (expectedBuffer.length !== signatureBuffer.length) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return crypto.timingSafeEqual(expectedBuffer, signatureBuffer);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Verifies and parses an incoming Paymentic webhook request.
|
|
48
|
+
* Throws PaymenticInvalidSignatureError if the signature does not match.
|
|
49
|
+
*/
|
|
50
|
+
async parseWebhook(request) {
|
|
51
|
+
const event = request.headers.get("x-paymentic-event");
|
|
52
|
+
const notificationId = request.headers.get("x-paymentic-notification-id") ?? "";
|
|
53
|
+
const time = request.headers.get("x-paymentic-time") ?? "";
|
|
54
|
+
const signature = request.headers.get("x-paymentic-signature") ?? "";
|
|
55
|
+
const version = (request.headers.get("user-agent") ?? "").split("/")[1] ?? "";
|
|
56
|
+
const rawBody = await request.text();
|
|
57
|
+
const signaturePayload = `${event}|${version}|${rawBody}|${notificationId}|${time}`;
|
|
58
|
+
if (!this.isValidSignature(signaturePayload, signature)) {
|
|
59
|
+
throw new PaymenticInvalidSignatureError();
|
|
60
|
+
}
|
|
61
|
+
const body = JSON.parse(rawBody);
|
|
62
|
+
return { ...body, event, notificationId, time };
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
PaymenticClient,
|
|
67
|
+
PaymenticInvalidSignatureError
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import axios, { AxiosError, type AxiosInstance } from \"axios\";\nimport crypto from \"crypto\";\nimport type {\n PaymenticCreateTransactionRequest,\n PaymenticCreateTransactionResponse,\n PaymenticWebhookEvent,\n PaymenticWebhookNotification,\n} from \"./types.js\";\n\nexport interface PaymenticConfig {\n pointId: string;\n apiToken: string;\n signatureKey: string;\n sandbox: boolean;\n}\n\nexport class PaymenticInvalidSignatureError extends Error {\n constructor() {\n super(\"Invalid Paymentic webhook signature\");\n }\n}\n\nexport class PaymenticClient {\n private readonly api: AxiosInstance;\n private readonly baseUrl: string;\n\n constructor(private readonly config: PaymenticConfig) {\n this.baseUrl = this.config.sandbox ? \"https://api.sandbox.paymentic.com/v1_2\" : \"https://api.paymentic.com/v1_2\";\n this.api = axios.create({\n baseURL: this.baseUrl,\n headers: {\n Authorization: `Bearer ${this.config.apiToken}`,\n },\n });\n this.api.interceptors.response.use(\n (response) => response,\n (error: AxiosError) => {\n console.error({ message: \"Paymentic API error\", errorResponse: error.response?.data });\n throw error;\n }\n );\n }\n\n async createTransaction(body: PaymenticCreateTransactionRequest): Promise<PaymenticCreateTransactionResponse> {\n const response = await this.api.post<PaymenticCreateTransactionResponse>(\n `/payment/points/${this.config.pointId}/transactions`,\n body\n );\n return response.data;\n }\n\n private isValidSignature(payload: string, signature: string): boolean {\n // in php: base64_encode(hash_hmac('sha512', $payload, $signatureKey, true));\n const expected = crypto.createHmac(\"sha512\", this.config.signatureKey).update(payload, \"utf8\").digest(\"base64\");\n\n const expectedBuffer = Buffer.from(expected);\n const signatureBuffer = Buffer.from(signature);\n\n // Length check guards timingSafeEqual, which throws on mismatched lengths\n if (expectedBuffer.length !== signatureBuffer.length) {\n return false;\n }\n\n return crypto.timingSafeEqual(expectedBuffer, signatureBuffer);\n }\n\n /**\n * Verifies and parses an incoming Paymentic webhook request.\n * Throws PaymenticInvalidSignatureError if the signature does not match.\n */\n async parseWebhook(request: Request): Promise<PaymenticWebhookNotification> {\n const event = request.headers.get(\"x-paymentic-event\") as PaymenticWebhookEvent;\n const notificationId = request.headers.get(\"x-paymentic-notification-id\") ?? \"\";\n const time = request.headers.get(\"x-paymentic-time\") ?? \"\";\n const signature = request.headers.get(\"x-paymentic-signature\") ?? \"\";\n // User-Agent is \"Paymentic/<version>\", e.g. \"Paymentic/1.1\"\n const version = (request.headers.get(\"user-agent\") ?? \"\").split(\"/\")[1] ?? \"\";\n\n const rawBody = await request.text();\n const signaturePayload = `${event}|${version}|${rawBody}|${notificationId}|${time}`;\n if (!this.isValidSignature(signaturePayload, signature)) {\n throw new PaymenticInvalidSignatureError();\n }\n\n const body = JSON.parse(rawBody);\n return { ...body, event, notificationId, time };\n }\n}\n"],"mappings":";AAAA,OAAO,WAA+C;AACtD,OAAO,YAAY;AAeZ,IAAM,iCAAN,cAA6C,MAAM;AAAA,EACtD,cAAc;AACV,UAAM,qCAAqC;AAAA,EAC/C;AACJ;AAEO,IAAM,kBAAN,MAAsB;AAAA,EAIzB,YAA6B,QAAyB;AAAzB;AACzB,SAAK,UAAU,KAAK,OAAO,UAAU,2CAA2C;AAChF,SAAK,MAAM,MAAM,OAAO;AAAA,MACpB,SAAS,KAAK;AAAA,MACd,SAAS;AAAA,QACL,eAAe,UAAU,KAAK,OAAO,QAAQ;AAAA,MACjD;AAAA,IACJ,CAAC;AACD,SAAK,IAAI,aAAa,SAAS;AAAA,MAC3B,CAAC,aAAa;AAAA,MACd,CAAC,UAAsB;AACnB,gBAAQ,MAAM,EAAE,SAAS,uBAAuB,eAAe,MAAM,UAAU,KAAK,CAAC;AACrF,cAAM;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AAAA,EAf6B;AAAA,EAHZ;AAAA,EACA;AAAA,EAmBjB,MAAM,kBAAkB,MAAsF;AAC1G,UAAM,WAAW,MAAM,KAAK,IAAI;AAAA,MAC5B,mBAAmB,KAAK,OAAO,OAAO;AAAA,MACtC;AAAA,IACJ;AACA,WAAO,SAAS;AAAA,EACpB;AAAA,EAEQ,iBAAiB,SAAiB,WAA4B;AAElE,UAAM,WAAW,OAAO,WAAW,UAAU,KAAK,OAAO,YAAY,EAAE,OAAO,SAAS,MAAM,EAAE,OAAO,QAAQ;AAE9G,UAAM,iBAAiB,OAAO,KAAK,QAAQ;AAC3C,UAAM,kBAAkB,OAAO,KAAK,SAAS;AAG7C,QAAI,eAAe,WAAW,gBAAgB,QAAQ;AAClD,aAAO;AAAA,IACX;AAEA,WAAO,OAAO,gBAAgB,gBAAgB,eAAe;AAAA,EACjE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,aAAa,SAAyD;AACxE,UAAM,QAAQ,QAAQ,QAAQ,IAAI,mBAAmB;AACrD,UAAM,iBAAiB,QAAQ,QAAQ,IAAI,6BAA6B,KAAK;AAC7E,UAAM,OAAO,QAAQ,QAAQ,IAAI,kBAAkB,KAAK;AACxD,UAAM,YAAY,QAAQ,QAAQ,IAAI,uBAAuB,KAAK;AAElE,UAAM,WAAW,QAAQ,QAAQ,IAAI,YAAY,KAAK,IAAI,MAAM,GAAG,EAAE,CAAC,KAAK;AAE3E,UAAM,UAAU,MAAM,QAAQ,KAAK;AACnC,UAAM,mBAAmB,GAAG,KAAK,IAAI,OAAO,IAAI,OAAO,IAAI,cAAc,IAAI,IAAI;AACjF,QAAI,CAAC,KAAK,iBAAiB,kBAAkB,SAAS,GAAG;AACrD,YAAM,IAAI,+BAA+B;AAAA,IAC7C;AAEA,UAAM,OAAO,KAAK,MAAM,OAAO;AAC/B,WAAO,EAAE,GAAG,MAAM,OAAO,gBAAgB,KAAK;AAAA,EAClD;AACJ;","names":[]}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export interface PaymenticCreateTransactionRequest {
|
|
2
|
+
/** Amount in minor precision with up to 2 decimals */
|
|
3
|
+
amount: string;
|
|
4
|
+
/** ISO 4217 3-letter currency code. Defaults to PLN when omitted. */
|
|
5
|
+
currency?: "PLN" | "EUR" | null;
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string | null;
|
|
8
|
+
externalReferenceId?: string | null;
|
|
9
|
+
redirect?: {
|
|
10
|
+
success?: string | null;
|
|
11
|
+
failure?: string | null;
|
|
12
|
+
} | null;
|
|
13
|
+
customer?: {
|
|
14
|
+
name?: string | null;
|
|
15
|
+
email?: string | null;
|
|
16
|
+
emailVerified?: boolean | null;
|
|
17
|
+
phone?: string | null;
|
|
18
|
+
phoneVerified?: boolean | null;
|
|
19
|
+
/** ISO 3166-1 alpha-2 */
|
|
20
|
+
country?: string | null;
|
|
21
|
+
/** ISO 639-1 alpha-2 */
|
|
22
|
+
locale?: string | null;
|
|
23
|
+
ip?: string | null;
|
|
24
|
+
userAgent?: string | null;
|
|
25
|
+
fingerprint?: string | null;
|
|
26
|
+
} | null;
|
|
27
|
+
order?: {
|
|
28
|
+
id?: string | null;
|
|
29
|
+
shippingMethod?: "VIRTUAL" | "TRACKED_DELIVERY" | "UNTRACKED_DELIVERY" | "IN_STORE_PICKUP" | "PARCEL_PICKUP" | "LOCKER_PICKUP" | "HYBRID" | "OTHER" | null;
|
|
30
|
+
trackingNumber?: string | null;
|
|
31
|
+
customerType?: "B2B" | "B2C" | null;
|
|
32
|
+
} | null;
|
|
33
|
+
billingAddress?: {
|
|
34
|
+
firstName?: string | null;
|
|
35
|
+
lastName?: string | null;
|
|
36
|
+
street?: string | null;
|
|
37
|
+
buildingNumber?: string | null;
|
|
38
|
+
flat?: string | null;
|
|
39
|
+
city?: string | null;
|
|
40
|
+
region?: string | null;
|
|
41
|
+
postalCode?: string | null;
|
|
42
|
+
state?: string | null;
|
|
43
|
+
/** ISO-3166-1 alpha-2 */
|
|
44
|
+
country?: string | null;
|
|
45
|
+
company?: string | null;
|
|
46
|
+
} | null;
|
|
47
|
+
shippingAddress?: {
|
|
48
|
+
firstName?: string | null;
|
|
49
|
+
lastName?: string | null;
|
|
50
|
+
street?: string | null;
|
|
51
|
+
buildingNumber?: string | null;
|
|
52
|
+
flat?: string | null;
|
|
53
|
+
city?: string | null;
|
|
54
|
+
region?: string | null;
|
|
55
|
+
postalCode?: string | null;
|
|
56
|
+
state?: string | null;
|
|
57
|
+
/** ISO-3166-1 alpha-2 */
|
|
58
|
+
country?: string | null;
|
|
59
|
+
company?: string | null;
|
|
60
|
+
} | null;
|
|
61
|
+
cart?: {
|
|
62
|
+
name?: string | null;
|
|
63
|
+
quantity?: number | null;
|
|
64
|
+
unitPrice?: string | null;
|
|
65
|
+
type?: "PRODUCT" | "SHIPPING" | "DISCOUNT" | "SURCHARGE" | "GIFT_CARD" | null;
|
|
66
|
+
productType?: "PHYSICAL" | "DIGITAL" | "SERVICE" | "VIRTUAL" | null;
|
|
67
|
+
sku?: string | null;
|
|
68
|
+
}[] | null;
|
|
69
|
+
paymentMethod?: "BLIK" | "PBL" | "BNPL" | "CARD" | "MOBILE_WALLET" | null;
|
|
70
|
+
paymentChannel?: string | null;
|
|
71
|
+
/**
|
|
72
|
+
* Whitelist of payment methods (optionally narrowed to a specific channel) that the gateway will present to the customer.
|
|
73
|
+
* Cannot be combined with hiddenPaymentMethods, paymentMethod or paymentChannel.
|
|
74
|
+
* When paymentChannel is null, all channels of that method are allowed.
|
|
75
|
+
*/
|
|
76
|
+
allowedPaymentMethods?: {
|
|
77
|
+
paymentMethod: "BLIK" | "PBL" | "BNPL" | "CARD" | "MW" | "PAYSAFE";
|
|
78
|
+
paymentChannel?: string | null;
|
|
79
|
+
}[] | null;
|
|
80
|
+
/**
|
|
81
|
+
* List of payment methods (optionally narrowed to a specific channel) that the gateway will hide from the customer.
|
|
82
|
+
* Cannot be combined with allowedPaymentMethods, paymentMethod or paymentChannel.
|
|
83
|
+
* When paymentChannel is null, all channels of that method are hidden.
|
|
84
|
+
*/
|
|
85
|
+
hiddenPaymentMethods?: {
|
|
86
|
+
paymentMethod: "BLIK" | "PBL" | "BNPL" | "CARD" | "MW" | "PAYSAFE";
|
|
87
|
+
paymentChannel?: string | null;
|
|
88
|
+
}[] | null;
|
|
89
|
+
/** If true, store customer payment instrument for recurring transactions. */
|
|
90
|
+
createRegistration?: boolean | null;
|
|
91
|
+
whitelabel?: boolean | null;
|
|
92
|
+
autoCapture?: boolean | null;
|
|
93
|
+
expiresAt?: string | null;
|
|
94
|
+
}
|
|
95
|
+
export interface PaymenticCreateTransactionResponse {
|
|
96
|
+
/** Transaction ID */
|
|
97
|
+
id: string;
|
|
98
|
+
/** Transaction URL */
|
|
99
|
+
redirectUrl: string;
|
|
100
|
+
whitelabel?: object | null;
|
|
101
|
+
}
|
|
102
|
+
interface PaymenticWebhookEnvelope {
|
|
103
|
+
/** From the X-Paymentic-Notification-Id header, use for idempotency */
|
|
104
|
+
notificationId: string;
|
|
105
|
+
/** From the X-Paymentic-Time header */
|
|
106
|
+
time: string;
|
|
107
|
+
}
|
|
108
|
+
export interface PaymenticTransactionStatusChangedNotification extends PaymenticWebhookEnvelope {
|
|
109
|
+
event: "PAYMENT.TRANSACTION_STATUS_CHANGED";
|
|
110
|
+
transactionId: string;
|
|
111
|
+
pointId: string;
|
|
112
|
+
status: "CREATED" | "PENDING" | "PAID" | "CANCELED" | "EXPIRED" | "FAILED";
|
|
113
|
+
amount: string;
|
|
114
|
+
currency: "PLN" | "EUR";
|
|
115
|
+
commission?: string | null;
|
|
116
|
+
externalReferenceId?: string | null;
|
|
117
|
+
paymentMethod?: "BLIK" | "PBL" | "BNPL" | "CARD" | "MOBILE_WALLET" | null;
|
|
118
|
+
paymentChannel?: string | null;
|
|
119
|
+
}
|
|
120
|
+
export interface PaymenticBlikAliasStatusChangedNotification extends PaymenticWebhookEnvelope {
|
|
121
|
+
event: "PAYMENT.BLIK_ALIAS_STATUS_CHANGED";
|
|
122
|
+
aliasId: string;
|
|
123
|
+
pointId: string;
|
|
124
|
+
status: "CREATED" | "ACTIVE" | "UNREGISTERED" | "EXPIRED";
|
|
125
|
+
type: "UID" | "PAYID";
|
|
126
|
+
value: string;
|
|
127
|
+
expiresAt?: string | null;
|
|
128
|
+
}
|
|
129
|
+
export interface PaymenticRefundStatusChangedNotification extends PaymenticWebhookEnvelope {
|
|
130
|
+
event: "PAYMENT.REFUND_STATUS_CHANGED";
|
|
131
|
+
refundId: string;
|
|
132
|
+
transactionId: string;
|
|
133
|
+
pointId: string;
|
|
134
|
+
status: "CREATED" | "ACCEPTED" | "PENDING" | "DONE" | "REJECTED" | "CANCELLED";
|
|
135
|
+
amount: string;
|
|
136
|
+
externalReferenceId?: string | null;
|
|
137
|
+
}
|
|
138
|
+
export interface PaymenticTransactionBlikStatusChangedNotification extends PaymenticWebhookEnvelope {
|
|
139
|
+
event: "PAYMENT.TRANSACTION_BLIK_STATUS_CHANGED";
|
|
140
|
+
transactionId: string;
|
|
141
|
+
actionId: string;
|
|
142
|
+
externalStatus: "BLIK_AUTHORIZED" | "BLIK_CUSTOMER_DECLINED" | "BLIK_SYSTEM_DECLINED" | "BLIK_INSUFFICIENT_FUNDS" | "BLIK_TIMEOUT" | "BLIK_CUSTOMER_LIMIT";
|
|
143
|
+
externalId: string;
|
|
144
|
+
}
|
|
145
|
+
export type PaymenticWebhookNotification = PaymenticTransactionStatusChangedNotification | PaymenticBlikAliasStatusChangedNotification | PaymenticRefundStatusChangedNotification | PaymenticTransactionBlikStatusChangedNotification;
|
|
146
|
+
export type PaymenticWebhookEvent = PaymenticWebhookNotification["event"];
|
|
147
|
+
export {};
|
|
148
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iCAAiC;IAC9C,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC3B,GAAG,IAAI,CAAC;IACT,QAAQ,CAA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AAc,EACR,iBAAiB,GACjB,wBAAwB,GACxB,sBAAsB,GACtB,yBAAyB,GACzB,cAAc,GACd,qBAAqB,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,4BAA4B,GAClC,6CAA6C,GAC7C,2CAA2C,GAC3C,wCAAwC,GACxC,iDAAiD,CAAC;AAExD,MAAM,MAAM,qBAAqB,GAAG,4BAA4B,CAAC,OAAO,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fanth/paymentic-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for the Paymentic REST API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/fanthpl/paymentic-sdk.git"
|
|
31
|
+
},
|
|
32
|
+
"license": "ISC",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^26.1.1",
|
|
35
|
+
"cross-env": "^10.1.0",
|
|
36
|
+
"dotenv": "^17.4.2",
|
|
37
|
+
"prettier": "^3.9.6",
|
|
38
|
+
"tsup": "^8.5.1",
|
|
39
|
+
"tsx": "^4.23.1",
|
|
40
|
+
"typescript": "^7.0.2"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"axios": "^1.18.1"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsup && tsc --emitDeclarationOnly",
|
|
47
|
+
"type-check": "tsc --noEmit",
|
|
48
|
+
"prod": "cross-env NODE_ENV=production tsx .",
|
|
49
|
+
"dev": "tsx .",
|
|
50
|
+
"test": "tsx src/client.test.ts"
|
|
51
|
+
}
|
|
52
|
+
}
|