@uveysservetoglu/kobil-payment 1.0.0 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # @uveysservetoglu/kobil-payment
2
2
 
3
- KOBIL Pay (mpay-merchant) client for Node.js / TypeScript, with automatic OAuth token
4
- management and typed models.
3
+ KOBIL Pay client for Node.js / TypeScript — the MiniApp API's `/v1/payments` (default) or the
4
+ legacy mpay-merchant API — with automatic OAuth token management and typed models.
5
5
 
6
6
  ```bash
7
7
  npm install @uveysservetoglu/kobil-payment
@@ -9,32 +9,50 @@ npm install @uveysservetoglu/kobil-payment
9
9
 
10
10
  ## Quick start
11
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
12
  ```ts
17
13
  import { PaymentClient, paymentGroup } from "@uveysservetoglu/kobil-payment";
18
14
 
15
+ // OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET and PAYMENT_MERCHANT_ID come from the environment.
19
16
  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
17
  defaultCurrency: "TRY",
28
18
  defaultMerchantCallback: "https://yourapi.com/payment-callback",
29
19
  });
30
20
  ```
31
21
 
32
- > **Amounts** are in the smallest currency unit (`1300` = 13.00 TRY). **Timeouts** in minutes.
22
+ > **Amounts** are in the smallest currency unit (`1300` = 13.00 TRY) and **timeouts** in minutes, in
23
+ > both API modes. Miniapp mode sends the amount as the API's decimal string (`{ value: "13.00",
24
+ > currency: "TRY" }`, decimals per ISO 4217 — see `formatMinorUnits`) and the timeout as
25
+ > `timeoutSeconds` (600–3600; omit it for the API's 15-minute default).
26
+
27
+ ## API mode
28
+
29
+ Pass `apiMode: "legacy"` (or set `KOBIL_API_MODE=legacy`) for the legacy mpay-merchant API; leave it
30
+ unset for the MiniApp API. See `@uveysservetoglu/kobil-core` for the shared settings.
31
+
32
+ | | Miniapp (default) | Legacy |
33
+ |---|---|---|
34
+ | Token | The MiniApp's own (`OIDC_CLIENT_ID` / `OIDC_CLIENT_SECRET`) | The **merchant** client's (`PAYMENT_MERCHANT_ID` / `PAYMENT_MERCHANT_SECRET`) |
35
+ | `merchantId` on the wire | `PAYMENT_MERCHANT_ID`, else the client id | `PAYMENT_MERCHANT_ID`, else the client id |
36
+ | Callback | **Required** on every operation (`merchantCallback` or `defaultMerchantCallback`) | Optional |
37
+ | Idempotency | `Idempotency-Key` header | `idempotencyId` in the body |
38
+ | Also needs | — | `PAYMENT_BASE`, `PAYMENT_TENANT_ID`, `PAYMENT_MERCHANT_NAME` |
39
+
40
+ ### Legacy: payment has its own client
41
+
42
+ In legacy mode **payment authenticates as the merchant client, not as the MiniApp.** They are two
43
+ registrations with their own ids, secrets and tenants, and the payment API checks which one the token
44
+ was issued for — a MiniApp token is refused with `PAY_WRONG_CLIENT`. So the token is fetched with
45
+ `PAYMENT_MERCHANT_ID` / `PAYMENT_MERCHANT_SECRET`, and that id is also the `merchantId`: the API
46
+ requires `merchantId === merchantServiceUUID === the merchant client id`. `PAYMENT_TENANT_ID` is a
47
+ **different tenant from mPower's** — mixing them up is the other common failure.
48
+
49
+ The MiniApp API takes one token for every operation and names the merchant in the body instead.
50
+ Pass `clientId` / `clientSecret` explicitly to override either choice.
33
51
 
34
52
  ## The six operations
35
53
 
36
54
  ```ts
37
- // 1. Regular payment (immediate charge)
55
+ // 1. Regular payment
38
56
  const res = await payment.createTransaction({
39
57
  userId,
40
58
  amount: 1300,
@@ -42,36 +60,43 @@ const res = await payment.createTransaction({
42
60
  });
43
61
  // res.transactionId ; parsePaymentStatus(res) === "new"
44
62
 
45
- // 2. Pre-authorization (hold funds)
63
+ // 2. Pre-authorization (hold funds) — keep the idempotency key
46
64
  const pre = await payment.createPreAuthTransaction({ userId, amount: 1300 });
47
- // pre.nextAction holds the post-auth handle
48
65
 
49
- // 3. Post-authorization (settle final amount)
50
- await payment.postAuth({ transactionId: pre.transactionId!, amount: 40 });
66
+ // 3. Post-authorization (settle; omit amount to capture the full hold)
67
+ await payment.postAuth({ transactionId: pre.transactionId!, amount: 40, idempotencyId: pre.idempotencyKey });
51
68
 
52
- // 4. Status
69
+ // 4. Status (the resolved status goes to the callback; miniapp mode also returns a snapshot)
53
70
  const status = await payment.getStatus({ transactionId });
54
71
 
55
72
  // 5. Cancel (void)
56
- await payment.cancel({ transactionId, userId, cancellationMessage: "Iptal" });
73
+ await payment.cancel({ transactionId, userId, reason: "Customer cancelled" });
57
74
 
58
- // 6. Refund (partial or full)
59
- await payment.refund({ transactionId, userId, amount: 5555, currency: "USD" });
75
+ // 6. Refund (partial or full; several partial refunds are allowed)
76
+ await payment.refund({ transactionId, userId, amount: 5555, currency: "USD", reason: "Returned" });
60
77
  ```
61
78
 
79
+ **Capturing a pre-authorization in miniapp mode** needs the pre-authorization's idempotency key —
80
+ the API uses it to tie the two together. Every result carries the key it was sent with as
81
+ `idempotencyKey`; store the pre-authorization's next to its `transactionId` and pass it to `postAuth`.
82
+
83
+ `reason` (alias `cancellationMessage`) is required for cancel and refund in miniapp mode. Results
84
+ carry `transactionId` in both modes; in miniapp mode it mirrors the API's `paymentId`, and
85
+ `createdAt` is set. `parsePaymentStatus` knows both APIs' statuses.
86
+
62
87
  JavaScript usage is identical (`const { PaymentClient } = require("@uveysservetoglu/kobil-payment")`).
63
88
 
64
89
  ## Errors
65
90
 
66
- All operations throw `KobilPaymentError` (extends `KobilError`) with `statusCode` and
67
- `responseBody` when available.
91
+ All operations reject with `KobilPaymentError` (extends `KobilError`) carrying `statusCode` and
92
+ `responseBody`, plus `errorCode` / `subsystem` / `traceId` from the MiniApp API's error envelope.
68
93
 
69
94
  ```ts
70
95
  import { KobilPaymentError } from "@uveysservetoglu/kobil-payment";
71
96
  try {
72
97
  await payment.createTransaction({ userId, amount: 1300 });
73
98
  } catch (e) {
74
- if (e instanceof KobilPaymentError) console.error(e.statusCode, e.responseBody);
99
+ if (e instanceof KobilPaymentError) console.error(e.statusCode, e.errorCode, e.traceId, e.responseBody);
75
100
  }
76
101
  ```
77
102
 
@@ -0,0 +1,11 @@
1
+ /** Number of decimal places the currency uses (ISO 4217 minor unit). */
2
+ export declare function currencyExponent(currency: string): number;
3
+ /**
4
+ * Renders an amount in the smallest currency unit as the MiniApp API's decimal string, with exactly the
5
+ * currency's number of decimals: `formatMinorUnits(1300, "TRY") === "13.00"`, `(1300, "JPY") === "1300"`.
6
+ *
7
+ * The SDK takes minor units in both API modes so code does not change with the mode; this is the
8
+ * conversion the miniapp mode applies. Integer arithmetic on the digits — no floating point.
9
+ */
10
+ export declare function formatMinorUnits(amount: number, currency: string): string;
11
+ //# sourceMappingURL=amount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amount.d.ts","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":"AAaA,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQzE"}
package/dist/amount.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.currencyExponent = currencyExponent;
4
+ exports.formatMinorUnits = formatMinorUnits;
5
+ const error_1 = require("./error");
6
+ /**
7
+ * ISO 4217 minor-unit exponents that differ from the usual 2. Every currency not listed has two decimal
8
+ * places (TRY, EUR, USD, GBP, …).
9
+ */
10
+ const EXPONENTS = {
11
+ BIF: 0, CLP: 0, DJF: 0, GNF: 0, ISK: 0, JPY: 0, KMF: 0, KRW: 0, PYG: 0, RWF: 0,
12
+ UGX: 0, UYI: 0, VND: 0, VUV: 0, XAF: 0, XOF: 0, XPF: 0,
13
+ BHD: 3, IQD: 3, JOD: 3, KWD: 3, LYD: 3, OMR: 3, TND: 3,
14
+ CLF: 4, UYW: 4,
15
+ };
16
+ /** Number of decimal places the currency uses (ISO 4217 minor unit). */
17
+ function currencyExponent(currency) {
18
+ return EXPONENTS[currency.toUpperCase()] ?? 2;
19
+ }
20
+ /**
21
+ * Renders an amount in the smallest currency unit as the MiniApp API's decimal string, with exactly the
22
+ * currency's number of decimals: `formatMinorUnits(1300, "TRY") === "13.00"`, `(1300, "JPY") === "1300"`.
23
+ *
24
+ * The SDK takes minor units in both API modes so code does not change with the mode; this is the
25
+ * conversion the miniapp mode applies. Integer arithmetic on the digits — no floating point.
26
+ */
27
+ function formatMinorUnits(amount, currency) {
28
+ if (!Number.isSafeInteger(amount) || amount < 0) {
29
+ throw new error_1.KobilPaymentError(`amount must be a non-negative integer in minor units, got ${amount}.`);
30
+ }
31
+ const exponent = currencyExponent(currency);
32
+ if (exponent === 0)
33
+ return String(amount);
34
+ const digits = String(amount).padStart(exponent + 1, "0");
35
+ return `${digits.slice(0, -exponent)}.${digits.slice(-exponent)}`;
36
+ }
37
+ //# sourceMappingURL=amount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amount.js","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":";;AAcA,4CAEC;AASD,4CAQC;AAjCD,mCAA4C;AAE5C;;;GAGG;AACH,MAAM,SAAS,GAA2B;IACxC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE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K,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AACpE,CAAC"}
package/dist/client.d.ts CHANGED
@@ -1,26 +1,43 @@
1
- import { KobilCredentials, KobilError, KobilServiceClient, TokenProvider } from "@uveysservetoglu/kobil-core";
1
+ import { ApiMode, KobilApiOptions, KobilCredentials, KobilError, KobilServiceClient, TokenProvider } from "@uveysservetoglu/kobil-core";
2
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`. */
3
+ export interface PaymentClientOptions extends Partial<KobilCredentials>, KobilApiOptions {
4
+ /**
5
+ * Legacy mode: base transaction URL; `/postauth`, `/status`, `/void`, `/refund` are derived from it.
6
+ * Derived from `PAYMENT_BASE` when omitted.
7
+ */
8
+ paymentBaseUrl?: string;
9
+ /**
10
+ * The merchant id sent on the wire. Falls back to `PAYMENT_MERCHANT_ID`, then to `clientId`.
11
+ * In legacy mode it is also the client the token is fetched for (see the constructor).
12
+ */
7
13
  merchantId?: string;
8
- /** Must match `merchantId`; defaults to it. */
14
+ /** Legacy mode: must match `merchantId`; defaults to it. */
9
15
  merchantServiceUuid?: string;
10
- merchantName: string;
16
+ /** Legacy mode: merchant name shown to the payer. Falls back to `PAYMENT_MERCHANT_NAME`. */
17
+ merchantName?: string;
18
+ /** Legacy mode: payment tenant — a different tenant from mPower's. Falls back to `PAYMENT_TENANT_ID`. */
11
19
  tenantId?: string;
12
20
  /** Default ISO currency code. Default: "TRY". */
13
21
  defaultCurrency?: string;
22
+ /** Default result callback. Every miniapp-mode operation needs one (here or per request). */
14
23
  defaultMerchantCallback?: string;
15
- /** Default transaction timeout in minutes. Default: 59. */
24
+ /**
25
+ * Default transaction timeout in minutes. Legacy default: 59. Miniapp mode sends it as `timeoutSeconds`
26
+ * only when set, so the API's own default (15 minutes) applies otherwise.
27
+ */
16
28
  defaultTransactionTimeoutMinutes?: number;
17
- /** Wire protocol version. Default: 1. */
29
+ /** Legacy mode: wire protocol version. Default: 1. */
18
30
  version?: number;
19
31
  /** Reuse a shared token provider (e.g. across modules). If omitted, one is created from credentials/env. */
20
32
  tokenProvider?: TokenProvider;
21
33
  }
22
- /** Client for the KOBIL Pay (mpay-merchant) API. */
34
+ /**
35
+ * Client for KOBIL Pay: the MiniApp API's `/v1/payments` (default) or the legacy mpay-merchant API.
36
+ * Inputs are the same in both modes — amounts in minor units, timeouts in minutes — and are converted
37
+ * to the selected API's shape.
38
+ */
23
39
  export declare class PaymentClient extends KobilServiceClient {
40
+ readonly apiMode: ApiMode;
24
41
  private readonly baseUrl;
25
42
  private readonly clientId;
26
43
  private readonly merchantName;
@@ -29,17 +46,36 @@ export declare class PaymentClient extends KobilServiceClient {
29
46
  private readonly tenantId?;
30
47
  private readonly defaultCurrency;
31
48
  private readonly defaultMerchantCallback?;
32
- private readonly defaultTimeout;
49
+ private readonly defaultTimeoutOption?;
33
50
  private readonly version;
34
- constructor(options: PaymentClientOptions);
51
+ constructor(options?: PaymentClientOptions);
35
52
  protected makeError(message: string, statusCode?: number, responseBody?: string, cause?: unknown): KobilError;
53
+ /** Regular payment: the amount is charged once the user confirms. */
36
54
  createTransaction(input: CreateTransactionInput, signal?: AbortSignal): Promise<TransactionResult>;
55
+ /** Pre-authorization: holds the amount until {@link postAuth}. Keep the result's `idempotencyKey`. */
37
56
  createPreAuthTransaction(input: CreateTransactionInput, signal?: AbortSignal): Promise<TransactionResult>;
38
57
  private createInternal;
58
+ /**
59
+ * Settles a pre-authorization (full amount when `amount` is omitted, partial otherwise).
60
+ *
61
+ * Miniapp mode correlates the capture with the pre-authorization through the idempotency key, so pass
62
+ * the pre-authorization result's `idempotencyKey` as `idempotencyId`.
63
+ */
39
64
  postAuth(input: PostAuthInput, signal?: AbortSignal): Promise<TransactionResult>;
65
+ /**
66
+ * Asks for the transaction's status. The resolved status is delivered to the callback; miniapp mode
67
+ * also returns a snapshot of it in the response.
68
+ */
40
69
  getStatus(input: StatusInput, signal?: AbortSignal): Promise<TransactionResult>;
70
+ /** Cancels (voids) a transaction that is still in process. */
41
71
  cancel(input: CancelInput, signal?: AbortSignal): Promise<TransactionResult>;
72
+ /** Refunds a completed transaction, fully or partially. Several partial refunds are allowed. */
42
73
  refund(input: RefundInput, signal?: AbortSignal): Promise<TransactionResult>;
74
+ private paymentUrl;
75
+ /** MiniApp results name the id `paymentId`; mirror it as `transactionId` so callers read one field. */
76
+ private normalize;
77
+ private requireCallback;
78
+ private legacyTimeout;
43
79
  private merchantId;
44
80
  private merchantServiceUuid;
45
81
  }
@@ -1 +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,SAAS,CAAC;AAEjB,MAAM,WAAW,oBAAqB,SAAQ,OAAO,CAAC,gBAAgB,CAAC;IACrE,4FAA4F;IAC5F,cAAc,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,2DAA2D;IAC3D,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAC1C,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4GAA4G;IAC5G,aAAa,CA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M,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA0ClF,OAAO,CAAC,UAAU;IAIlB,uGAAuG;IACvG,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,mBAAmB;CAK5B"}
package/dist/client.js CHANGED
@@ -3,9 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PaymentClient = void 0;
4
4
  const crypto_1 = require("crypto");
5
5
  const kobil_core_1 = require("@uveysservetoglu/kobil-core");
6
+ const amount_1 = require("./amount");
6
7
  const error_1 = require("./error");
7
- /** Client for the KOBIL Pay (mpay-merchant) API. */
8
+ /**
9
+ * Client for KOBIL Pay: the MiniApp API's `/v1/payments` (default) or the legacy mpay-merchant API.
10
+ * Inputs are the same in both modes — amounts in minor units, timeouts in minutes — and are converted
11
+ * to the selected API's shape.
12
+ */
8
13
  class PaymentClient extends kobil_core_1.KobilServiceClient {
14
+ apiMode;
9
15
  baseUrl;
10
16
  clientId;
11
17
  merchantName;
@@ -14,122 +20,239 @@ class PaymentClient extends kobil_core_1.KobilServiceClient {
14
20
  tenantId;
15
21
  defaultCurrency;
16
22
  defaultMerchantCallback;
17
- defaultTimeout;
23
+ defaultTimeoutOption;
18
24
  version;
19
- constructor(options) {
25
+ constructor(options = {}) {
26
+ const apiMode = (0, kobil_core_1.resolveApiMode)(options.apiMode);
27
+ /**
28
+ * Legacy: payment authenticates as the **merchant** client, not as the MiniApp.
29
+ *
30
+ * They are two registrations with their own ids, secrets and tenants, and the payment API checks
31
+ * it: a token issued for the MiniApp's client is refused with `PAY_WRONG_CLIENT`. So the merchant
32
+ * credentials are what this client's token is fetched with, and `PAYMENT_MERCHANT_ID` doubles as
33
+ * the `merchantId` sent on the wire — the API requires those to be the same value.
34
+ *
35
+ * MiniApp API: one token — the MiniApp's own — serves every operation, and the merchant is named in
36
+ * the request body instead. So the shared `OIDC_*` credentials are used and `merchantId` only travels
37
+ * on the wire.
38
+ *
39
+ * `clientId`/`clientSecret` override either choice.
40
+ */
41
+ const legacy = apiMode === "legacy";
20
42
  const credentials = (0, kobil_core_1.credentialsFromEnv)({
21
43
  tokenEndpoint: options.tokenEndpoint,
22
- clientId: options.clientId,
23
- clientSecret: options.clientSecret,
44
+ clientId: legacy ? options.clientId ?? options.merchantId ?? process.env.PAYMENT_MERCHANT_ID : options.clientId,
45
+ clientSecret: legacy ? options.clientSecret ?? process.env.PAYMENT_MERCHANT_SECRET : options.clientSecret,
24
46
  tokenAuthMode: options.tokenAuthMode,
25
47
  defaultTokenTtlSeconds: options.defaultTokenTtlSeconds,
26
48
  tokenExpirySkewSeconds: options.tokenExpirySkewSeconds,
27
- });
49
+ }, { apiMode, apiBaseUrl: options.apiBaseUrl, realm: options.realm });
28
50
  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(/\/+$/, "");
51
+ this.apiMode = apiMode;
52
+ if (legacy) {
53
+ const baseUrl = options.paymentBaseUrl || (0, kobil_core_1.paymentTransactionEndpoint)(process.env.PAYMENT_BASE);
54
+ if (!baseUrl)
55
+ throw new kobil_core_1.KobilError("No payment endpoint: set PAYMENT_BASE (or pass paymentBaseUrl).");
56
+ const merchantName = options.merchantName ?? process.env.PAYMENT_MERCHANT_NAME;
57
+ if (!merchantName)
58
+ throw new kobil_core_1.KobilError("No merchant name: set PAYMENT_MERCHANT_NAME (or pass merchantName).");
59
+ this.baseUrl = baseUrl.replace(/\/+$/, "");
60
+ this.merchantName = merchantName;
61
+ }
62
+ else {
63
+ this.baseUrl = `${(0, kobil_core_1.miniappApiBase)(options.apiBaseUrl)}/v1/payments`;
64
+ this.merchantName = options.merchantName ?? process.env.PAYMENT_MERCHANT_NAME ?? "";
65
+ }
34
66
  this.clientId = credentials.clientId;
35
- this.merchantName = options.merchantName;
36
- this.merchantIdOption = options.merchantId;
67
+ this.merchantIdOption = options.merchantId ?? process.env.PAYMENT_MERCHANT_ID;
37
68
  this.merchantServiceUuidOption = options.merchantServiceUuid;
38
- this.tenantId = options.tenantId;
69
+ this.tenantId = options.tenantId ?? process.env.PAYMENT_TENANT_ID;
39
70
  this.defaultCurrency = options.defaultCurrency ?? "TRY";
40
71
  this.defaultMerchantCallback = options.defaultMerchantCallback;
41
- this.defaultTimeout = options.defaultTransactionTimeoutMinutes ?? 59;
72
+ this.defaultTimeoutOption = options.defaultTransactionTimeoutMinutes;
42
73
  this.version = options.version ?? 1;
43
74
  }
44
75
  makeError(message, statusCode, responseBody, cause) {
45
76
  return new error_1.KobilPaymentError(message, { statusCode, responseBody, cause });
46
77
  }
78
+ /** Regular payment: the amount is charged once the user confirms. */
47
79
  createTransaction(input, signal) {
48
80
  return this.createInternal(input, false, signal);
49
81
  }
82
+ /** Pre-authorization: holds the amount until {@link postAuth}. Keep the result's `idempotencyKey`. */
50
83
  createPreAuthTransaction(input, signal) {
51
84
  return this.createInternal(input, true, signal);
52
85
  }
53
- createInternal(input, preAuth, signal) {
86
+ async createInternal(input, preAuth, signal) {
54
87
  if (!input.userId)
55
88
  throw new error_1.KobilPaymentError("userId cannot be empty.");
89
+ const idempotencyKey = input.idempotencyId ?? (0, crypto_1.randomUUID)();
90
+ const currency = (input.currency ?? this.defaultCurrency).toUpperCase();
91
+ if (this.apiMode === "miniapp") {
92
+ const timeoutMinutes = input.transactionTimeoutMinutes ?? this.defaultTimeoutOption;
93
+ const res = await this.sendJson("POST", `${this.baseUrl}/${preAuth ? "startPreAuth" : "start"}`, prune({
94
+ userId: input.userId,
95
+ merchantId: this.merchantId(),
96
+ amount: { value: (0, amount_1.formatMinorUnits)(input.amount, currency), currency },
97
+ callbackUrl: this.requireCallback(input.merchantCallback),
98
+ paymentContent: stringifyContent(input.paymentContent),
99
+ timeoutSeconds: timeoutMinutes === undefined ? undefined : timeoutMinutes * 60,
100
+ }), signal, { "idempotency-key": idempotencyKey });
101
+ return this.normalize(res, idempotencyKey);
102
+ }
56
103
  const body = {
57
104
  version: this.version,
58
- idempotencyId: input.idempotencyId ?? (0, crypto_1.randomUUID)(),
105
+ idempotencyId: idempotencyKey,
59
106
  userId: input.userId,
60
107
  merchantId: this.merchantId(),
61
108
  merchantServiceUUID: this.merchantServiceUuid(),
62
109
  merchantName: this.merchantName,
63
110
  merchantCallback: input.merchantCallback ?? this.defaultMerchantCallback,
64
- transactionTimeout: input.transactionTimeoutMinutes ?? this.defaultTimeout,
111
+ transactionTimeout: input.transactionTimeoutMinutes ?? this.legacyTimeout(),
65
112
  tenantId: this.tenantId,
66
113
  amount: input.amount,
67
- currency: (input.currency ?? this.defaultCurrency).toUpperCase(),
114
+ currency,
68
115
  paymentContent: input.paymentContent,
69
116
  };
70
117
  if (preAuth)
71
118
  body.paymentTenantType = "preAuth";
72
- return this.sendJson("POST", this.baseUrl, prune(body), signal);
119
+ const res = await this.sendJson("POST", this.baseUrl, prune(body), signal);
120
+ return { ...res, idempotencyKey };
73
121
  }
74
- postAuth(input, signal) {
122
+ /**
123
+ * Settles a pre-authorization (full amount when `amount` is omitted, partial otherwise).
124
+ *
125
+ * Miniapp mode correlates the capture with the pre-authorization through the idempotency key, so pass
126
+ * the pre-authorization result's `idempotencyKey` as `idempotencyId`.
127
+ */
128
+ async postAuth(input, signal) {
75
129
  if (!input.transactionId)
76
130
  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
- });
131
+ if (this.apiMode === "miniapp") {
132
+ if (!input.idempotencyId) {
133
+ throw new error_1.KobilPaymentError("postAuth needs idempotencyId in miniapp mode: pass the idempotencyKey returned by createPreAuthTransaction.");
134
+ }
135
+ const currency = (input.currency ?? this.defaultCurrency).toUpperCase();
136
+ const res = await this.sendJson("POST", `${this.paymentUrl(input.transactionId)}/capture`, prune({
137
+ callbackUrl: this.requireCallback(input.merchantCallback),
138
+ amount: input.amount === undefined ? undefined : { value: (0, amount_1.formatMinorUnits)(input.amount, currency), currency },
139
+ }), signal, { "idempotency-key": input.idempotencyId });
140
+ return this.normalize(res, input.idempotencyId);
141
+ }
142
+ const idempotencyKey = input.idempotencyId ?? (0, crypto_1.randomUUID)();
143
+ const query = new URLSearchParams({ id: input.transactionId, idempotencyId: idempotencyKey });
144
+ if (input.amount !== undefined)
145
+ query.set("amount", String(input.amount));
82
146
  const callback = input.merchantCallback ?? this.defaultMerchantCallback;
83
147
  if (callback)
84
148
  query.set("merchantCallback", callback);
85
- return this.sendJson("GET", `${this.baseUrl}/postauth?${query.toString()}`, undefined, signal);
149
+ const res = await this.sendJson("GET", `${this.baseUrl}/postauth?${query.toString()}`, undefined, signal);
150
+ return { ...res, idempotencyKey };
86
151
  }
87
- getStatus(input, signal) {
152
+ /**
153
+ * Asks for the transaction's status. The resolved status is delivered to the callback; miniapp mode
154
+ * also returns a snapshot of it in the response.
155
+ */
156
+ async getStatus(input, signal) {
88
157
  if (!input.transactionId)
89
158
  throw new error_1.KobilPaymentError("transactionId cannot be empty.");
159
+ if (this.apiMode === "miniapp") {
160
+ const res = await this.sendJson("POST", `${this.paymentUrl(input.transactionId)}/checkStatus`, { merchantId: this.merchantId(), callbackUrl: this.requireCallback(input.merchantCallback) }, signal);
161
+ return this.normalize(res);
162
+ }
90
163
  return this.sendJson("POST", `${this.baseUrl}/status`, prune({
91
164
  merchantId: this.merchantId(),
92
165
  merchantCallback: input.merchantCallback ?? this.defaultMerchantCallback,
93
166
  transactionId: input.transactionId,
94
167
  }), signal);
95
168
  }
96
- cancel(input, signal) {
169
+ /** Cancels (voids) a transaction that is still in process. */
170
+ async cancel(input, signal) {
97
171
  if (!input.transactionId)
98
172
  throw new error_1.KobilPaymentError("transactionId cannot be empty.");
99
173
  if (!input.userId)
100
174
  throw new error_1.KobilPaymentError("userId cannot be empty.");
101
- return this.sendJson("POST", `${this.baseUrl}/void`, prune({
175
+ const idempotencyKey = input.idempotencyId ?? (0, crypto_1.randomUUID)();
176
+ const reason = input.reason ?? input.cancellationMessage;
177
+ if (this.apiMode === "miniapp") {
178
+ const res = await this.sendJson("POST", `${this.paymentUrl(input.transactionId)}/cancel`, {
179
+ userId: input.userId,
180
+ merchantId: this.merchantId(),
181
+ callbackUrl: this.requireCallback(input.merchantCallback),
182
+ reason: requireReason(reason),
183
+ }, signal, { "idempotency-key": idempotencyKey });
184
+ return this.normalize(res, idempotencyKey);
185
+ }
186
+ const res = await this.sendJson("POST", `${this.baseUrl}/void`, prune({
102
187
  version: this.version,
103
188
  userId: input.userId,
104
- idempotencyId: input.idempotencyId ?? (0, crypto_1.randomUUID)(),
189
+ idempotencyId: idempotencyKey,
105
190
  merchantServiceUUID: this.merchantServiceUuid(),
106
191
  merchantCallback: input.merchantCallback ?? this.defaultMerchantCallback,
107
- transactionTimeout: input.transactionTimeoutMinutes ?? this.defaultTimeout,
192
+ transactionTimeout: input.transactionTimeoutMinutes ?? this.legacyTimeout(),
108
193
  merchantId: this.merchantId(),
109
194
  paymentTransactionId: input.transactionId,
110
- cancellationMessage: input.cancellationMessage,
195
+ cancellationMessage: reason,
111
196
  }), signal);
197
+ return { ...res, idempotencyKey };
112
198
  }
113
- refund(input, signal) {
199
+ /** Refunds a completed transaction, fully or partially. Several partial refunds are allowed. */
200
+ async refund(input, signal) {
114
201
  if (!input.transactionId)
115
202
  throw new error_1.KobilPaymentError("transactionId cannot be empty.");
116
203
  if (!input.userId)
117
204
  throw new error_1.KobilPaymentError("userId cannot be empty.");
205
+ const idempotencyKey = input.idempotencyId ?? (0, crypto_1.randomUUID)();
206
+ const currency = (input.currency ?? this.defaultCurrency).toUpperCase();
207
+ const reason = input.reason ?? input.cancellationMessage;
208
+ if (this.apiMode === "miniapp") {
209
+ const res = await this.sendJson("POST", `${this.paymentUrl(input.transactionId)}/refund`, {
210
+ userId: input.userId,
211
+ merchantId: this.merchantId(),
212
+ amount: { value: (0, amount_1.formatMinorUnits)(input.amount, currency), currency },
213
+ callbackUrl: this.requireCallback(input.merchantCallback),
214
+ reason: requireReason(reason),
215
+ }, signal, { "idempotency-key": idempotencyKey });
216
+ return this.normalize(res, idempotencyKey);
217
+ }
118
218
  const serviceUuid = this.merchantServiceUuid();
119
- return this.sendJson("POST", `${this.baseUrl}/refund`, prune({
219
+ const res = await this.sendJson("POST", `${this.baseUrl}/refund`, prune({
120
220
  version: this.version,
121
221
  userId: input.userId,
122
- idempotencyId: input.idempotencyId ?? (0, crypto_1.randomUUID)(),
222
+ idempotencyId: idempotencyKey,
123
223
  merchantServiceUUID: serviceUuid,
124
224
  merchantCallback: input.merchantCallback ?? this.defaultMerchantCallback,
125
- transactionTimeout: input.transactionTimeoutMinutes ?? this.defaultTimeout,
225
+ transactionTimeout: input.transactionTimeoutMinutes ?? this.legacyTimeout(),
126
226
  merchantId: this.merchantId(),
127
227
  merchantUserId: input.userId,
128
228
  paymentTransactionId: input.transactionId,
129
229
  amount: input.amount,
130
- currency: (input.currency ?? this.defaultCurrency).toUpperCase(),
230
+ currency,
131
231
  merchantServiceProviderId: serviceUuid,
132
232
  }), signal);
233
+ return { ...res, idempotencyKey };
234
+ }
235
+ paymentUrl(transactionId) {
236
+ return `${this.baseUrl}/${encodeURIComponent(transactionId)}`;
237
+ }
238
+ /** MiniApp results name the id `paymentId`; mirror it as `transactionId` so callers read one field. */
239
+ normalize(res, idempotencyKey) {
240
+ const out = { ...res };
241
+ if (out.transactionId === undefined && out.paymentId !== undefined)
242
+ out.transactionId = out.paymentId;
243
+ if (idempotencyKey !== undefined)
244
+ out.idempotencyKey = idempotencyKey;
245
+ return out;
246
+ }
247
+ requireCallback(callback) {
248
+ const url = callback ?? this.defaultMerchantCallback;
249
+ if (!url) {
250
+ throw new error_1.KobilPaymentError("No callback URL: the MiniApp API requires one for every payment operation — pass merchantCallback or set defaultMerchantCallback.");
251
+ }
252
+ return url;
253
+ }
254
+ legacyTimeout() {
255
+ return this.defaultTimeoutOption ?? 59;
133
256
  }
134
257
  merchantId() {
135
258
  return this.merchantIdOption && this.merchantIdOption.length > 0 ? this.merchantIdOption : this.clientId;
@@ -141,6 +264,16 @@ class PaymentClient extends kobil_core_1.KobilServiceClient {
141
264
  }
142
265
  }
143
266
  exports.PaymentClient = PaymentClient;
267
+ function requireReason(reason) {
268
+ if (!reason) {
269
+ throw new error_1.KobilPaymentError("A reason is required in miniapp mode: pass reason (or cancellationMessage).");
270
+ }
271
+ return reason;
272
+ }
273
+ /** The MiniApp API takes display values as strings. */
274
+ function stringifyContent(content) {
275
+ return content?.map((group) => group.map(({ key, value }) => ({ key, value: String(value) })));
276
+ }
144
277
  /** Removes undefined/null properties so optional fields are omitted from the JSON body. */
145
278
  function prune(obj) {
146
279
  const out = {};
@@ -1 +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,CAAC,QAAQ;YAC1B,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;YACtD,sBAAsB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C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACjG,CAAC;AAED,2FAA2F;AAC3F,SAAS,KAAK,CAAC,GAA4B;IACzC,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC9D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { PaymentClient } from "./client";
2
2
  export type { PaymentClientOptions } from "./client";
3
3
  export { KobilPaymentError } from "./error";
4
4
  export { paymentGroup, paymentGroups } from "./content";
5
+ export { currencyExponent, formatMinorUnits } from "./amount";
5
6
  export { parsePaymentStatus } from "./types";
6
7
  export type { CreateTransactionInput, PostAuthInput, StatusInput, CancelInput, RefundInput, TransactionResult, PaymentContent, PaymentContentItem, PaymentStatus, } from "./types";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC9D,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 CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parsePaymentStatus = exports.paymentGroups = exports.paymentGroup = exports.KobilPaymentError = exports.PaymentClient = void 0;
3
+ exports.parsePaymentStatus = exports.formatMinorUnits = exports.currencyExponent = exports.paymentGroups = exports.paymentGroup = exports.KobilPaymentError = exports.PaymentClient = void 0;
4
4
  var client_1 = require("./client");
5
5
  Object.defineProperty(exports, "PaymentClient", { enumerable: true, get: function () { return client_1.PaymentClient; } });
6
6
  var error_1 = require("./error");
@@ -8,6 +8,9 @@ Object.defineProperty(exports, "KobilPaymentError", { enumerable: true, get: fun
8
8
  var content_1 = require("./content");
9
9
  Object.defineProperty(exports, "paymentGroup", { enumerable: true, get: function () { return content_1.paymentGroup; } });
10
10
  Object.defineProperty(exports, "paymentGroups", { enumerable: true, get: function () { return content_1.paymentGroups; } });
11
+ var amount_1 = require("./amount");
12
+ Object.defineProperty(exports, "currencyExponent", { enumerable: true, get: function () { return amount_1.currencyExponent; } });
13
+ Object.defineProperty(exports, "formatMinorUnits", { enumerable: true, get: function () { return amount_1.formatMinorUnits; } });
11
14
  var types_1 = require("./types");
12
15
  Object.defineProperty(exports, "parsePaymentStatus", { enumerable: true, get: function () { return types_1.parsePaymentStatus; } });
13
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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"}
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,mCAA8D;AAArD,0GAAA,gBAAgB,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAC3C,iCAA6C;AAApC,2GAAA,kBAAkB,OAAA"}
package/dist/types.d.ts CHANGED
@@ -1,36 +1,54 @@
1
1
  /** A single key/value line shown to the payer. */
2
2
  export interface PaymentContentItem {
3
3
  key: string;
4
+ /** Sent as-is in legacy mode; converted to a string in miniapp mode (max 128 characters). */
4
5
  value: unknown;
5
6
  }
6
7
  /** Payment content is a list of groups, each group a list of key/value lines. */
7
8
  export type PaymentContent = PaymentContentItem[][];
8
9
  export interface CreateTransactionInput {
9
10
  userId: string;
10
- /** Amount in the smallest currency unit (e.g. 1300 = 13.00 TRY). */
11
+ /** Amount in the smallest currency unit (e.g. 1300 = 13.00 TRY), in both API modes. */
11
12
  amount: number;
12
13
  currency?: string;
14
+ /** Result callback. Required in miniapp mode (here or as `defaultMerchantCallback`). */
13
15
  merchantCallback?: string;
16
+ /** Minutes. Miniapp mode sends it as `timeoutSeconds` (600–3600 s); omit it there for the 15-minute default. */
14
17
  transactionTimeoutMinutes?: number;
18
+ /**
19
+ * Idempotency key. Generated when omitted and returned as `idempotencyKey` on the result — keep the
20
+ * pre-authorization's: miniapp mode needs it again for `postAuth`.
21
+ */
15
22
  idempotencyId?: string;
16
23
  paymentContent?: PaymentContent;
17
24
  }
18
25
  export interface PostAuthInput {
19
26
  transactionId: string;
20
- /** Final amount to settle, in the smallest currency unit. */
21
- amount: number;
27
+ /** Final amount to settle, in the smallest currency unit. Omit to capture the full pre-authorized amount. */
28
+ amount?: number;
29
+ /** Currency of `amount` (miniapp mode). Defaults to the client's default currency. */
30
+ currency?: string;
22
31
  merchantCallback?: string;
32
+ /**
33
+ * Legacy mode: a fresh key for this request (generated when omitted).
34
+ * Miniapp mode: **required** — the `idempotencyKey` of the pre-authorization being captured.
35
+ */
23
36
  idempotencyId?: string;
24
37
  }
25
38
  export interface StatusInput {
26
39
  transactionId: string;
40
+ /** Required in miniapp mode (here or as `defaultMerchantCallback`): the fresh status is POSTed there. */
27
41
  merchantCallback?: string;
28
42
  }
29
43
  export interface CancelInput {
30
44
  transactionId: string;
31
45
  userId: string;
46
+ /** Reason for the cancellation. Required in miniapp mode (as `reason` or `cancellationMessage`). */
32
47
  cancellationMessage?: string;
48
+ /** Alias of `cancellationMessage`, matching the MiniApp API's name. */
49
+ reason?: string;
33
50
  merchantCallback?: string;
51
+ /** Legacy mode only. */
34
52
  transactionTimeoutMinutes?: number;
35
53
  idempotencyId?: string;
36
54
  }
@@ -40,16 +58,30 @@ export interface RefundInput {
40
58
  /** Amount to refund, in the smallest currency unit. */
41
59
  amount: number;
42
60
  currency?: string;
61
+ /** Reason for the refund. Required in miniapp mode (as `reason` or `cancellationMessage`). */
43
62
  cancellationMessage?: string;
63
+ /** Alias of `cancellationMessage`, matching the MiniApp API's name. */
64
+ reason?: string;
44
65
  merchantCallback?: string;
66
+ /** Legacy mode only. */
45
67
  transactionTimeoutMinutes?: number;
46
68
  idempotencyId?: string;
47
69
  }
48
70
  export interface TransactionResult {
71
+ /**
72
+ * The transaction id. In miniapp mode this mirrors `paymentId` (the refund's own id for a refund, the
73
+ * settlement id for a capture), so code written against either mode reads the same field.
74
+ */
49
75
  transactionId?: string;
76
+ /** MiniApp API's transaction id. */
77
+ paymentId?: string;
50
78
  operationId?: string;
51
79
  status?: string;
52
80
  message?: string;
81
+ /** MiniApp API: when the operation was accepted (ISO 8601). */
82
+ createdAt?: string;
83
+ /** The idempotency key the request was sent with. Keep a pre-authorization's for `postAuth`. */
84
+ idempotencyKey?: string;
53
85
  /** Present on pre-auth: URL/handle to continue with post-auth. */
54
86
  nextAction?: string;
55
87
  transactionStatus?: string;
@@ -57,7 +89,7 @@ export interface TransactionResult {
57
89
  gateway?: string;
58
90
  [key: string]: unknown;
59
91
  }
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`. */
92
+ export type PaymentStatus = "new" | "processing" | "processing_3d_secure" | "processing_digital" | "finished" | "cancelled" | "closed" | "timeout" | "error" | "void" | "refund" | "inquiring" | "cancellation" | "notification" | "requiresRefund" | "failed" | "unknown";
93
+ /** Returns the strongly-typed status, preferring `transactionStatus` then `status`. Case-insensitive. */
62
94
  export declare function parsePaymentStatus(result: TransactionResult): PaymentStatus;
63
95
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;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C;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gGAAgG;IAChG,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,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,WAAW,GACX,cAAc,GACd,cAAc,GACd,gBAAgB,GAChB,QAAQ,GACR,SAAS,CAAC;AAUd,yGAAyG;AACzG,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,CAG3E"}
package/dist/types.js CHANGED
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parsePaymentStatus = parsePaymentStatus;
4
- /** Returns the strongly-typed status, preferring `transactionStatus` then `status`. */
4
+ const KNOWN_STATUSES = [
5
+ "new", "processing", "processing_3d_secure", "processing_digital",
6
+ "finished", "cancelled", "closed", "timeout", "error", "void", "refund",
7
+ "inquiring", "cancellation", "notification", "requiresRefund", "failed",
8
+ ];
9
+ const STATUS_BY_LOWERCASE = new Map(KNOWN_STATUSES.map((s) => [s.toLowerCase(), s]));
10
+ /** Returns the strongly-typed status, preferring `transactionStatus` then `status`. Case-insensitive. */
5
11
  function parsePaymentStatus(result) {
6
- const known = [
7
- "new", "processing", "processing_3d_secure", "processing_digital",
8
- "finished", "cancelled", "closed", "timeout", "error", "void", "refund",
9
- ];
10
12
  const raw = (result.transactionStatus ?? result.status ?? "").toLowerCase();
11
- return known.includes(raw) ? raw : "unknown";
13
+ return STATUS_BY_LOWERCASE.get(raw) ?? "unknown";
12
14
  }
13
15
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +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"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AA+HA,gDAGC;AAZD,MAAM,cAAc,GAAoB;IACtC,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,oBAAoB;IACjE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ;IACvE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ;CACxE,CAAC;AAEF,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAErF,yGAAyG;AACzG,SAAgB,kBAAkB,CAAC,MAAyB;IAC1D,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5E,OAAO,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC;AACnD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uveysservetoglu/kobil-payment",
3
- "version": "1.0.0",
3
+ "version": "3.0.0",
4
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
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,7 @@
19
19
  "url": "https://github.com/uveysservetoglu/kobil-sdks"
20
20
  },
21
21
  "dependencies": {
22
- "@uveysservetoglu/kobil-core": "^1.0.0"
22
+ "@uveysservetoglu/kobil-core": "^3.0.0"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsc -b"