@uveysservetoglu/kobil-payment 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -0
- package/dist/client.d.ts +46 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +153 -0
- package/dist/client.js.map +1 -0
- package/dist/content.d.ts +9 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +16 -0
- package/dist/content.js.map +1 -0
- package/dist/error.d.ts +5 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +9 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# @uveysservetoglu/kobil-payment
|
|
2
|
+
|
|
3
|
+
KOBIL Pay (mpay-merchant) client for Node.js / TypeScript, with automatic OAuth token
|
|
4
|
+
management and typed models.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @uveysservetoglu/kobil-payment
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Quick start
|
|
11
|
+
|
|
12
|
+
OAuth credentials (`tokenEndpoint`, `clientId`, `clientSecret`) are shared across KOBIL
|
|
13
|
+
modules and read from `KOBIL_*` env vars if you don't pass them. `merchantId` defaults to
|
|
14
|
+
`clientId`.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { PaymentClient, paymentGroup } from "@uveysservetoglu/kobil-payment";
|
|
18
|
+
|
|
19
|
+
const payment = new PaymentClient({
|
|
20
|
+
// credentials (or via KOBIL_TOKEN_ENDPOINT / KOBIL_CLIENT_ID / KOBIL_CLIENT_SECRET):
|
|
21
|
+
tokenEndpoint: process.env.KOBIL_TOKEN_ENDPOINT!,
|
|
22
|
+
clientId: process.env.KOBIL_CLIENT_ID!,
|
|
23
|
+
clientSecret: process.env.KOBIL_CLIENT_SECRET!,
|
|
24
|
+
// payment-specific:
|
|
25
|
+
paymentBaseUrl: "https://pay.cloud.kobil.com/mpay-merchant/create/transaction",
|
|
26
|
+
merchantName: "ISPARK",
|
|
27
|
+
defaultCurrency: "TRY",
|
|
28
|
+
defaultMerchantCallback: "https://yourapi.com/payment-callback",
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
> **Amounts** are in the smallest currency unit (`1300` = 13.00 TRY). **Timeouts** in minutes.
|
|
33
|
+
|
|
34
|
+
## The six operations
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// 1. Regular payment (immediate charge)
|
|
38
|
+
const res = await payment.createTransaction({
|
|
39
|
+
userId,
|
|
40
|
+
amount: 1300,
|
|
41
|
+
paymentContent: paymentGroup(["Service Amount", "10.0 TL"], ["Tax Amount", "3.0 TL"]),
|
|
42
|
+
});
|
|
43
|
+
// res.transactionId ; parsePaymentStatus(res) === "new"
|
|
44
|
+
|
|
45
|
+
// 2. Pre-authorization (hold funds)
|
|
46
|
+
const pre = await payment.createPreAuthTransaction({ userId, amount: 1300 });
|
|
47
|
+
// pre.nextAction holds the post-auth handle
|
|
48
|
+
|
|
49
|
+
// 3. Post-authorization (settle final amount)
|
|
50
|
+
await payment.postAuth({ transactionId: pre.transactionId!, amount: 40 });
|
|
51
|
+
|
|
52
|
+
// 4. Status
|
|
53
|
+
const status = await payment.getStatus({ transactionId });
|
|
54
|
+
|
|
55
|
+
// 5. Cancel (void)
|
|
56
|
+
await payment.cancel({ transactionId, userId, cancellationMessage: "Iptal" });
|
|
57
|
+
|
|
58
|
+
// 6. Refund (partial or full)
|
|
59
|
+
await payment.refund({ transactionId, userId, amount: 5555, currency: "USD" });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
JavaScript usage is identical (`const { PaymentClient } = require("@uveysservetoglu/kobil-payment")`).
|
|
63
|
+
|
|
64
|
+
## Errors
|
|
65
|
+
|
|
66
|
+
All operations throw `KobilPaymentError` (extends `KobilError`) with `statusCode` and
|
|
67
|
+
`responseBody` when available.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { KobilPaymentError } from "@uveysservetoglu/kobil-payment";
|
|
71
|
+
try {
|
|
72
|
+
await payment.createTransaction({ userId, amount: 1300 });
|
|
73
|
+
} catch (e) {
|
|
74
|
+
if (e instanceof KobilPaymentError) console.error(e.statusCode, e.responseBody);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { KobilCredentials, KobilError, KobilServiceClient, TokenProvider } from "@uveysservetoglu/kobil-core";
|
|
2
|
+
import { CancelInput, CreateTransactionInput, PostAuthInput, RefundInput, StatusInput, TransactionResult } from "./types";
|
|
3
|
+
export interface PaymentClientOptions extends Partial<KobilCredentials> {
|
|
4
|
+
/** Base transaction URL; `/postauth`, `/status`, `/void`, `/refund` are derived from it. */
|
|
5
|
+
paymentBaseUrl: string;
|
|
6
|
+
/** Merchant id. Optional: defaults to `clientId`. */
|
|
7
|
+
merchantId?: string;
|
|
8
|
+
/** Must match `merchantId`; defaults to it. */
|
|
9
|
+
merchantServiceUuid?: string;
|
|
10
|
+
merchantName: string;
|
|
11
|
+
tenantId?: string;
|
|
12
|
+
/** Default ISO currency code. Default: "TRY". */
|
|
13
|
+
defaultCurrency?: string;
|
|
14
|
+
defaultMerchantCallback?: string;
|
|
15
|
+
/** Default transaction timeout in minutes. Default: 59. */
|
|
16
|
+
defaultTransactionTimeoutMinutes?: number;
|
|
17
|
+
/** Wire protocol version. Default: 1. */
|
|
18
|
+
version?: number;
|
|
19
|
+
/** Reuse a shared token provider (e.g. across modules). If omitted, one is created from credentials/env. */
|
|
20
|
+
tokenProvider?: TokenProvider;
|
|
21
|
+
}
|
|
22
|
+
/** Client for the KOBIL Pay (mpay-merchant) API. */
|
|
23
|
+
export declare class PaymentClient extends KobilServiceClient {
|
|
24
|
+
private readonly baseUrl;
|
|
25
|
+
private readonly clientId;
|
|
26
|
+
private readonly merchantName;
|
|
27
|
+
private readonly merchantIdOption?;
|
|
28
|
+
private readonly merchantServiceUuidOption?;
|
|
29
|
+
private readonly tenantId?;
|
|
30
|
+
private readonly defaultCurrency;
|
|
31
|
+
private readonly defaultMerchantCallback?;
|
|
32
|
+
private readonly defaultTimeout;
|
|
33
|
+
private readonly version;
|
|
34
|
+
constructor(options: PaymentClientOptions);
|
|
35
|
+
protected makeError(message: string, statusCode?: number, responseBody?: string, cause?: unknown): KobilError;
|
|
36
|
+
createTransaction(input: CreateTransactionInput, signal?: AbortSignal): Promise<TransactionResult>;
|
|
37
|
+
createPreAuthTransaction(input: CreateTransactionInput, signal?: AbortSignal): Promise<TransactionResult>;
|
|
38
|
+
private createInternal;
|
|
39
|
+
postAuth(input: PostAuthInput, signal?: AbortSignal): Promise<TransactionResult>;
|
|
40
|
+
getStatus(input: StatusInput, signal?: AbortSignal): Promise<TransactionResult>;
|
|
41
|
+
cancel(input: CancelInput, signal?: AbortSignal): Promise<TransactionResult>;
|
|
42
|
+
refund(input: RefundInput, signal?: AbortSignal): Promise<TransactionResult>;
|
|
43
|
+
private merchantId;
|
|
44
|
+
private merchantServiceUuid;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,aAAa,EAEd,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,aAAa,EACb,WAAW,EACX,WAAW,EACX,iBAAiB,EAClB,MAAM,SAA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,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIlG,wBAAwB,CAAC,KAAK,EAAE,sBAAsB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIzG,OAAO,CAAC,cAAc;IAoBtB,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAYhF,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAS/E,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAgB5E,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAoB5E,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,mBAAmB;CAK5B"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaymentClient = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const kobil_core_1 = require("@uveysservetoglu/kobil-core");
|
|
6
|
+
const error_1 = require("./error");
|
|
7
|
+
/** Client for the KOBIL Pay (mpay-merchant) API. */
|
|
8
|
+
class PaymentClient extends kobil_core_1.KobilServiceClient {
|
|
9
|
+
baseUrl;
|
|
10
|
+
clientId;
|
|
11
|
+
merchantName;
|
|
12
|
+
merchantIdOption;
|
|
13
|
+
merchantServiceUuidOption;
|
|
14
|
+
tenantId;
|
|
15
|
+
defaultCurrency;
|
|
16
|
+
defaultMerchantCallback;
|
|
17
|
+
defaultTimeout;
|
|
18
|
+
version;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
const credentials = (0, kobil_core_1.credentialsFromEnv)({
|
|
21
|
+
tokenEndpoint: options.tokenEndpoint,
|
|
22
|
+
clientId: options.clientId,
|
|
23
|
+
clientSecret: options.clientSecret,
|
|
24
|
+
tokenAuthMode: options.tokenAuthMode,
|
|
25
|
+
defaultTokenTtlSeconds: options.defaultTokenTtlSeconds,
|
|
26
|
+
tokenExpirySkewSeconds: options.tokenExpirySkewSeconds,
|
|
27
|
+
});
|
|
28
|
+
super(options.tokenProvider ?? new kobil_core_1.DefaultTokenProvider(credentials));
|
|
29
|
+
if (!options.paymentBaseUrl)
|
|
30
|
+
throw new kobil_core_1.KobilError("paymentBaseUrl is required.");
|
|
31
|
+
if (!options.merchantName)
|
|
32
|
+
throw new kobil_core_1.KobilError("merchantName is required.");
|
|
33
|
+
this.baseUrl = options.paymentBaseUrl.replace(/\/+$/, "");
|
|
34
|
+
this.clientId = credentials.clientId;
|
|
35
|
+
this.merchantName = options.merchantName;
|
|
36
|
+
this.merchantIdOption = options.merchantId;
|
|
37
|
+
this.merchantServiceUuidOption = options.merchantServiceUuid;
|
|
38
|
+
this.tenantId = options.tenantId;
|
|
39
|
+
this.defaultCurrency = options.defaultCurrency ?? "TRY";
|
|
40
|
+
this.defaultMerchantCallback = options.defaultMerchantCallback;
|
|
41
|
+
this.defaultTimeout = options.defaultTransactionTimeoutMinutes ?? 59;
|
|
42
|
+
this.version = options.version ?? 1;
|
|
43
|
+
}
|
|
44
|
+
makeError(message, statusCode, responseBody, cause) {
|
|
45
|
+
return new error_1.KobilPaymentError(message, { statusCode, responseBody, cause });
|
|
46
|
+
}
|
|
47
|
+
createTransaction(input, signal) {
|
|
48
|
+
return this.createInternal(input, false, signal);
|
|
49
|
+
}
|
|
50
|
+
createPreAuthTransaction(input, signal) {
|
|
51
|
+
return this.createInternal(input, true, signal);
|
|
52
|
+
}
|
|
53
|
+
createInternal(input, preAuth, signal) {
|
|
54
|
+
if (!input.userId)
|
|
55
|
+
throw new error_1.KobilPaymentError("userId cannot be empty.");
|
|
56
|
+
const body = {
|
|
57
|
+
version: this.version,
|
|
58
|
+
idempotencyId: input.idempotencyId ?? (0, crypto_1.randomUUID)(),
|
|
59
|
+
userId: input.userId,
|
|
60
|
+
merchantId: this.merchantId(),
|
|
61
|
+
merchantServiceUUID: this.merchantServiceUuid(),
|
|
62
|
+
merchantName: this.merchantName,
|
|
63
|
+
merchantCallback: input.merchantCallback ?? this.defaultMerchantCallback,
|
|
64
|
+
transactionTimeout: input.transactionTimeoutMinutes ?? this.defaultTimeout,
|
|
65
|
+
tenantId: this.tenantId,
|
|
66
|
+
amount: input.amount,
|
|
67
|
+
currency: (input.currency ?? this.defaultCurrency).toUpperCase(),
|
|
68
|
+
paymentContent: input.paymentContent,
|
|
69
|
+
};
|
|
70
|
+
if (preAuth)
|
|
71
|
+
body.paymentTenantType = "preAuth";
|
|
72
|
+
return this.sendJson("POST", this.baseUrl, prune(body), signal);
|
|
73
|
+
}
|
|
74
|
+
postAuth(input, signal) {
|
|
75
|
+
if (!input.transactionId)
|
|
76
|
+
throw new error_1.KobilPaymentError("transactionId cannot be empty.");
|
|
77
|
+
const query = new URLSearchParams({
|
|
78
|
+
id: input.transactionId,
|
|
79
|
+
idempotencyId: input.idempotencyId ?? (0, crypto_1.randomUUID)(),
|
|
80
|
+
amount: String(input.amount),
|
|
81
|
+
});
|
|
82
|
+
const callback = input.merchantCallback ?? this.defaultMerchantCallback;
|
|
83
|
+
if (callback)
|
|
84
|
+
query.set("merchantCallback", callback);
|
|
85
|
+
return this.sendJson("GET", `${this.baseUrl}/postauth?${query.toString()}`, undefined, signal);
|
|
86
|
+
}
|
|
87
|
+
getStatus(input, signal) {
|
|
88
|
+
if (!input.transactionId)
|
|
89
|
+
throw new error_1.KobilPaymentError("transactionId cannot be empty.");
|
|
90
|
+
return this.sendJson("POST", `${this.baseUrl}/status`, prune({
|
|
91
|
+
merchantId: this.merchantId(),
|
|
92
|
+
merchantCallback: input.merchantCallback ?? this.defaultMerchantCallback,
|
|
93
|
+
transactionId: input.transactionId,
|
|
94
|
+
}), signal);
|
|
95
|
+
}
|
|
96
|
+
cancel(input, signal) {
|
|
97
|
+
if (!input.transactionId)
|
|
98
|
+
throw new error_1.KobilPaymentError("transactionId cannot be empty.");
|
|
99
|
+
if (!input.userId)
|
|
100
|
+
throw new error_1.KobilPaymentError("userId cannot be empty.");
|
|
101
|
+
return this.sendJson("POST", `${this.baseUrl}/void`, prune({
|
|
102
|
+
version: this.version,
|
|
103
|
+
userId: input.userId,
|
|
104
|
+
idempotencyId: input.idempotencyId ?? (0, crypto_1.randomUUID)(),
|
|
105
|
+
merchantServiceUUID: this.merchantServiceUuid(),
|
|
106
|
+
merchantCallback: input.merchantCallback ?? this.defaultMerchantCallback,
|
|
107
|
+
transactionTimeout: input.transactionTimeoutMinutes ?? this.defaultTimeout,
|
|
108
|
+
merchantId: this.merchantId(),
|
|
109
|
+
paymentTransactionId: input.transactionId,
|
|
110
|
+
cancellationMessage: input.cancellationMessage,
|
|
111
|
+
}), signal);
|
|
112
|
+
}
|
|
113
|
+
refund(input, signal) {
|
|
114
|
+
if (!input.transactionId)
|
|
115
|
+
throw new error_1.KobilPaymentError("transactionId cannot be empty.");
|
|
116
|
+
if (!input.userId)
|
|
117
|
+
throw new error_1.KobilPaymentError("userId cannot be empty.");
|
|
118
|
+
const serviceUuid = this.merchantServiceUuid();
|
|
119
|
+
return this.sendJson("POST", `${this.baseUrl}/refund`, prune({
|
|
120
|
+
version: this.version,
|
|
121
|
+
userId: input.userId,
|
|
122
|
+
idempotencyId: input.idempotencyId ?? (0, crypto_1.randomUUID)(),
|
|
123
|
+
merchantServiceUUID: serviceUuid,
|
|
124
|
+
merchantCallback: input.merchantCallback ?? this.defaultMerchantCallback,
|
|
125
|
+
transactionTimeout: input.transactionTimeoutMinutes ?? this.defaultTimeout,
|
|
126
|
+
merchantId: this.merchantId(),
|
|
127
|
+
merchantUserId: input.userId,
|
|
128
|
+
paymentTransactionId: input.transactionId,
|
|
129
|
+
amount: input.amount,
|
|
130
|
+
currency: (input.currency ?? this.defaultCurrency).toUpperCase(),
|
|
131
|
+
merchantServiceProviderId: serviceUuid,
|
|
132
|
+
}), signal);
|
|
133
|
+
}
|
|
134
|
+
merchantId() {
|
|
135
|
+
return this.merchantIdOption && this.merchantIdOption.length > 0 ? this.merchantIdOption : this.clientId;
|
|
136
|
+
}
|
|
137
|
+
merchantServiceUuid() {
|
|
138
|
+
return this.merchantServiceUuidOption && this.merchantServiceUuidOption.length > 0
|
|
139
|
+
? this.merchantServiceUuidOption
|
|
140
|
+
: this.merchantId();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.PaymentClient = PaymentClient;
|
|
144
|
+
/** Removes undefined/null properties so optional fields are omitted from the JSON body. */
|
|
145
|
+
function prune(obj) {
|
|
146
|
+
const out = {};
|
|
147
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
148
|
+
if (value !== undefined && value !== null)
|
|
149
|
+
out[key] = value;
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AACpC,4DAOqC;AACrC,mCAA4C;AA8B5C,oDAAoD;AACpD,MAAa,aAAc,SAAQ,+BAAkB;IAClC,OAAO,CAAS;IAChB,QAAQ,CAAS;IACjB,YAAY,CAAS;IACrB,gBAAgB,CAAU;IAC1B,yBAAyB,CAAU;IACnC,QAAQ,CAAU;IAClB,eAAe,CAAS;IACxB,uBAAuB,CAAU;IACjC,cAAc,CAAS;IACvB,OAAO,CAAS;IAEjC,YAAY,OAA6B;QACvC,MAAM,WAAW,GAAG,IAAA,+BAAkB,EAAC;YACrC,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,QAAQ,EAAE,OAAO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
|
|
|
1
|
+
import { PaymentContent } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Builds a single group of key/value lines.
|
|
4
|
+
* @example paymentGroup(["Service Amount", "10.0 TL"], ["Tax Amount", "3.0 TL"])
|
|
5
|
+
*/
|
|
6
|
+
export declare function paymentGroup(...items: [string, unknown][]): PaymentContent;
|
|
7
|
+
/** Builds multiple groups of key/value lines. */
|
|
8
|
+
export declare function paymentGroups(...groups: [string, unknown][][]): PaymentContent;
|
|
9
|
+
//# sourceMappingURL=content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,cAAc,CAE1E;AAED,iDAAiD;AACjD,wBAAgB,aAAa,CAAC,GAAG,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,cAAc,CAE9E"}
|
package/dist/content.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paymentGroup = paymentGroup;
|
|
4
|
+
exports.paymentGroups = paymentGroups;
|
|
5
|
+
/**
|
|
6
|
+
* Builds a single group of key/value lines.
|
|
7
|
+
* @example paymentGroup(["Service Amount", "10.0 TL"], ["Tax Amount", "3.0 TL"])
|
|
8
|
+
*/
|
|
9
|
+
function paymentGroup(...items) {
|
|
10
|
+
return [items.map(([key, value]) => ({ key, value }))];
|
|
11
|
+
}
|
|
12
|
+
/** Builds multiple groups of key/value lines. */
|
|
13
|
+
function paymentGroups(...groups) {
|
|
14
|
+
return groups.map((group) => group.map(([key, value]) => ({ key, value })));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":";;AAMA,oCAEC;AAGD,sCAEC;AAXD;;;GAGG;AACH,SAAgB,YAAY,CAAC,GAAG,KAA0B;IACxD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,iDAAiD;AACjD,SAAgB,aAAa,CAAC,GAAG,MAA6B;IAC5D,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,6CAA6C;AAC7C,qBAAa,iBAAkB,SAAQ,UAAU;CAAG"}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KobilPaymentError = void 0;
|
|
4
|
+
const kobil_core_1 = require("@uveysservetoglu/kobil-core");
|
|
5
|
+
/** Thrown when a payment operation fails. */
|
|
6
|
+
class KobilPaymentError extends kobil_core_1.KobilError {
|
|
7
|
+
}
|
|
8
|
+
exports.KobilPaymentError = KobilPaymentError;
|
|
9
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAAA,4DAAyD;AAEzD,6CAA6C;AAC7C,MAAa,iBAAkB,SAAQ,uBAAU;CAAG;AAApD,8CAAoD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { PaymentClient } from "./client";
|
|
2
|
+
export type { PaymentClientOptions } from "./client";
|
|
3
|
+
export { KobilPaymentError } from "./error";
|
|
4
|
+
export { paymentGroup, paymentGroups } from "./content";
|
|
5
|
+
export { parsePaymentStatus } from "./types";
|
|
6
|
+
export type { CreateTransactionInput, PostAuthInput, StatusInput, CancelInput, RefundInput, TransactionResult, PaymentContent, PaymentContentItem, PaymentStatus, } from "./types";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,YAAY,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,YAAY,EACV,sBAAsB,EACtB,aAAa,EACb,WAAW,EACX,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,aAAa,GACd,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePaymentStatus = exports.paymentGroups = exports.paymentGroup = exports.KobilPaymentError = exports.PaymentClient = void 0;
|
|
4
|
+
var client_1 = require("./client");
|
|
5
|
+
Object.defineProperty(exports, "PaymentClient", { enumerable: true, get: function () { return client_1.PaymentClient; } });
|
|
6
|
+
var error_1 = require("./error");
|
|
7
|
+
Object.defineProperty(exports, "KobilPaymentError", { enumerable: true, get: function () { return error_1.KobilPaymentError; } });
|
|
8
|
+
var content_1 = require("./content");
|
|
9
|
+
Object.defineProperty(exports, "paymentGroup", { enumerable: true, get: function () { return content_1.paymentGroup; } });
|
|
10
|
+
Object.defineProperty(exports, "paymentGroups", { enumerable: true, get: function () { return content_1.paymentGroups; } });
|
|
11
|
+
var types_1 = require("./types");
|
|
12
|
+
Object.defineProperty(exports, "parsePaymentStatus", { enumerable: true, get: function () { return types_1.parsePaymentStatus; } });
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAyC;AAAhC,uGAAA,aAAa,OAAA;AAEtB,iCAA4C;AAAnC,0GAAA,iBAAiB,OAAA;AAC1B,qCAAwD;AAA/C,uGAAA,YAAY,OAAA;AAAE,wGAAA,aAAa,OAAA;AACpC,iCAA6C;AAApC,2GAAA,kBAAkB,OAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** A single key/value line shown to the payer. */
|
|
2
|
+
export interface PaymentContentItem {
|
|
3
|
+
key: string;
|
|
4
|
+
value: unknown;
|
|
5
|
+
}
|
|
6
|
+
/** Payment content is a list of groups, each group a list of key/value lines. */
|
|
7
|
+
export type PaymentContent = PaymentContentItem[][];
|
|
8
|
+
export interface CreateTransactionInput {
|
|
9
|
+
userId: string;
|
|
10
|
+
/** Amount in the smallest currency unit (e.g. 1300 = 13.00 TRY). */
|
|
11
|
+
amount: number;
|
|
12
|
+
currency?: string;
|
|
13
|
+
merchantCallback?: string;
|
|
14
|
+
transactionTimeoutMinutes?: number;
|
|
15
|
+
idempotencyId?: string;
|
|
16
|
+
paymentContent?: PaymentContent;
|
|
17
|
+
}
|
|
18
|
+
export interface PostAuthInput {
|
|
19
|
+
transactionId: string;
|
|
20
|
+
/** Final amount to settle, in the smallest currency unit. */
|
|
21
|
+
amount: number;
|
|
22
|
+
merchantCallback?: string;
|
|
23
|
+
idempotencyId?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface StatusInput {
|
|
26
|
+
transactionId: string;
|
|
27
|
+
merchantCallback?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface CancelInput {
|
|
30
|
+
transactionId: string;
|
|
31
|
+
userId: string;
|
|
32
|
+
cancellationMessage?: string;
|
|
33
|
+
merchantCallback?: string;
|
|
34
|
+
transactionTimeoutMinutes?: number;
|
|
35
|
+
idempotencyId?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface RefundInput {
|
|
38
|
+
transactionId: string;
|
|
39
|
+
userId: string;
|
|
40
|
+
/** Amount to refund, in the smallest currency unit. */
|
|
41
|
+
amount: number;
|
|
42
|
+
currency?: string;
|
|
43
|
+
cancellationMessage?: string;
|
|
44
|
+
merchantCallback?: string;
|
|
45
|
+
transactionTimeoutMinutes?: number;
|
|
46
|
+
idempotencyId?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface TransactionResult {
|
|
49
|
+
transactionId?: string;
|
|
50
|
+
operationId?: string;
|
|
51
|
+
status?: string;
|
|
52
|
+
message?: string;
|
|
53
|
+
/** Present on pre-auth: URL/handle to continue with post-auth. */
|
|
54
|
+
nextAction?: string;
|
|
55
|
+
transactionStatus?: string;
|
|
56
|
+
transactionMessage?: string;
|
|
57
|
+
gateway?: string;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
}
|
|
60
|
+
export type PaymentStatus = "new" | "processing" | "processing_3d_secure" | "processing_digital" | "finished" | "cancelled" | "closed" | "timeout" | "error" | "void" | "refund" | "unknown";
|
|
61
|
+
/** Returns the strongly-typed status, preferring `transactionStatus` then `status`. */
|
|
62
|
+
export declare function parsePaymentStatus(result: TransactionResult): PaymentStatus;
|
|
63
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,iFAAiF;AACjF,MAAM,MAAM,cAAc,GAAG,kBAAkB,EAAE,EAAE,CAAC;AAEpD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,aAAa,GACrB,KAAK,GACL,YAAY,GACZ,sBAAsB,GACtB,oBAAoB,GACpB,UAAU,GACV,WAAW,GACX,QAAQ,GACR,SAAS,GACT,OAAO,GACP,MAAM,GACN,QAAQ,GACR,SAAS,CAAC;AAEd,uFAAuF;AACvF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,CAO3E"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePaymentStatus = parsePaymentStatus;
|
|
4
|
+
/** Returns the strongly-typed status, preferring `transactionStatus` then `status`. */
|
|
5
|
+
function parsePaymentStatus(result) {
|
|
6
|
+
const known = [
|
|
7
|
+
"new", "processing", "processing_3d_secure", "processing_digital",
|
|
8
|
+
"finished", "cancelled", "closed", "timeout", "error", "void", "refund",
|
|
9
|
+
];
|
|
10
|
+
const raw = (result.transactionStatus ?? result.status ?? "").toLowerCase();
|
|
11
|
+
return known.includes(raw) ? raw : "unknown";
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAkFA,gDAOC;AARD,uFAAuF;AACvF,SAAgB,kBAAkB,CAAC,MAAyB;IAC1D,MAAM,KAAK,GAAoB;QAC7B,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,oBAAoB;QACjE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ;KACxE,CAAC;IACF,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5E,OAAQ,KAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,GAAqB,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uveysservetoglu/kobil-payment",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "KOBIL Pay (mpay-merchant) client for Node.js: create/pre-auth/post-auth, status, cancel and refund transactions with automatic OAuth token management.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"kobil",
|
|
13
|
+
"payment",
|
|
14
|
+
"mpay",
|
|
15
|
+
"oauth2"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/uveysservetoglu/kobil-sdks"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@uveysservetoglu/kobil-core": "^1.0.0"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc -b"
|
|
26
|
+
}
|
|
27
|
+
}
|