@sakeetech/viva-payments-core 0.2.1
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 +21 -0
- package/README.md +413 -0
- package/dist/auth/http.d.ts +44 -0
- package/dist/auth/http.d.ts.map +1 -0
- package/dist/auth/http.js +80 -0
- package/dist/auth/http.js.map +1 -0
- package/dist/auth/index.d.ts +19 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +18 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/oauth2-strategy.d.ts +117 -0
- package/dist/auth/oauth2-strategy.d.ts.map +1 -0
- package/dist/auth/oauth2-strategy.js +217 -0
- package/dist/auth/oauth2-strategy.js.map +1 -0
- package/dist/auth/reseller-strategy.d.ts +65 -0
- package/dist/auth/reseller-strategy.d.ts.map +1 -0
- package/dist/auth/reseller-strategy.js +68 -0
- package/dist/auth/reseller-strategy.js.map +1 -0
- package/dist/auth/single-flight.d.ts +81 -0
- package/dist/auth/single-flight.d.ts.map +1 -0
- package/dist/auth/single-flight.js +160 -0
- package/dist/auth/single-flight.js.map +1 -0
- package/dist/auth/token-cache.d.ts +50 -0
- package/dist/auth/token-cache.d.ts.map +1 -0
- package/dist/auth/token-cache.js +59 -0
- package/dist/auth/token-cache.js.map +1 -0
- package/dist/errors/api-error.d.ts +15 -0
- package/dist/errors/api-error.d.ts.map +1 -0
- package/dist/errors/api-error.js +18 -0
- package/dist/errors/api-error.js.map +1 -0
- package/dist/errors/auth-error.d.ts +14 -0
- package/dist/errors/auth-error.d.ts.map +1 -0
- package/dist/errors/auth-error.js +17 -0
- package/dist/errors/auth-error.js.map +1 -0
- package/dist/errors/base.d.ts +59 -0
- package/dist/errors/base.d.ts.map +1 -0
- package/dist/errors/base.js +51 -0
- package/dist/errors/base.js.map +1 -0
- package/dist/errors/index.d.ts +18 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +16 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/mode-mismatch-error.d.ts +19 -0
- package/dist/errors/mode-mismatch-error.d.ts.map +1 -0
- package/dist/errors/mode-mismatch-error.js +22 -0
- package/dist/errors/mode-mismatch-error.js.map +1 -0
- package/dist/errors/rate-limit-error.d.ts +20 -0
- package/dist/errors/rate-limit-error.d.ts.map +1 -0
- package/dist/errors/rate-limit-error.js +20 -0
- package/dist/errors/rate-limit-error.js.map +1 -0
- package/dist/errors/validation-error.d.ts +14 -0
- package/dist/errors/validation-error.d.ts.map +1 -0
- package/dist/errors/validation-error.js +17 -0
- package/dist/errors/validation-error.js.map +1 -0
- package/dist/errors/webhook-error.d.ts +14 -0
- package/dist/errors/webhook-error.d.ts.map +1 -0
- package/dist/errors/webhook-error.js +17 -0
- package/dist/errors/webhook-error.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/isv/accounts.d.ts +38 -0
- package/dist/isv/accounts.d.ts.map +1 -0
- package/dist/isv/accounts.js +60 -0
- package/dist/isv/accounts.js.map +1 -0
- package/dist/isv/client.d.ts +187 -0
- package/dist/isv/client.d.ts.map +1 -0
- package/dist/isv/client.js +465 -0
- package/dist/isv/client.js.map +1 -0
- package/dist/isv/index.d.ts +52 -0
- package/dist/isv/index.d.ts.map +1 -0
- package/dist/isv/index.js +53 -0
- package/dist/isv/index.js.map +1 -0
- package/dist/isv/legacy-basic-client.d.ts +122 -0
- package/dist/isv/legacy-basic-client.d.ts.map +1 -0
- package/dist/isv/legacy-basic-client.js +281 -0
- package/dist/isv/legacy-basic-client.js.map +1 -0
- package/dist/isv/payments.d.ts +199 -0
- package/dist/isv/payments.d.ts.map +1 -0
- package/dist/isv/payments.js +385 -0
- package/dist/isv/payments.js.map +1 -0
- package/dist/isv/sources.d.ts +80 -0
- package/dist/isv/sources.d.ts.map +1 -0
- package/dist/isv/sources.js +112 -0
- package/dist/isv/sources.js.map +1 -0
- package/dist/isv/webhooks-api.d.ts +48 -0
- package/dist/isv/webhooks-api.d.ts.map +1 -0
- package/dist/isv/webhooks-api.js +66 -0
- package/dist/isv/webhooks-api.js.map +1 -0
- package/dist/legacy/client.d.ts +199 -0
- package/dist/legacy/client.d.ts.map +1 -0
- package/dist/legacy/client.js +351 -0
- package/dist/legacy/client.js.map +1 -0
- package/dist/legacy/index.d.ts +15 -0
- package/dist/legacy/index.d.ts.map +1 -0
- package/dist/legacy/index.js +14 -0
- package/dist/legacy/index.js.map +1 -0
- package/dist/observability/context.d.ts +30 -0
- package/dist/observability/context.d.ts.map +1 -0
- package/dist/observability/context.js +40 -0
- package/dist/observability/context.js.map +1 -0
- package/dist/observability/index.d.ts +15 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +11 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/logger.d.ts +81 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +127 -0
- package/dist/observability/logger.js.map +1 -0
- package/dist/observability/metrics.d.ts +37 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +40 -0
- package/dist/observability/metrics.js.map +1 -0
- package/dist/observability/redact.d.ts +21 -0
- package/dist/observability/redact.d.ts.map +1 -0
- package/dist/observability/redact.js +72 -0
- package/dist/observability/redact.js.map +1 -0
- package/dist/observability/tracer.d.ts +25 -0
- package/dist/observability/tracer.d.ts.map +1 -0
- package/dist/observability/tracer.js +18 -0
- package/dist/observability/tracer.js.map +1 -0
- package/dist/payments/client.d.ts +247 -0
- package/dist/payments/client.d.ts.map +1 -0
- package/dist/payments/client.js +488 -0
- package/dist/payments/client.js.map +1 -0
- package/dist/payments/index.d.ts +14 -0
- package/dist/payments/index.d.ts.map +1 -0
- package/dist/payments/index.js +13 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/refunds/fast-refund-client.d.ts +128 -0
- package/dist/refunds/fast-refund-client.d.ts.map +1 -0
- package/dist/refunds/fast-refund-client.js +138 -0
- package/dist/refunds/fast-refund-client.js.map +1 -0
- package/dist/refunds/index.d.ts +19 -0
- package/dist/refunds/index.d.ts.map +1 -0
- package/dist/refunds/index.js +17 -0
- package/dist/refunds/index.js.map +1 -0
- package/dist/refunds/strategy.d.ts +78 -0
- package/dist/refunds/strategy.d.ts.map +1 -0
- package/dist/refunds/strategy.js +75 -0
- package/dist/refunds/strategy.js.map +1 -0
- package/dist/types/auth.d.ts +80 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +12 -0
- package/dist/types/auth.js.map +1 -0
- package/dist/types/card-types.d.ts +48 -0
- package/dist/types/card-types.d.ts.map +1 -0
- package/dist/types/card-types.js +62 -0
- package/dist/types/card-types.js.map +1 -0
- package/dist/types/common.d.ts +160 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +70 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/isv-accounts.d.ts +109 -0
- package/dist/types/isv-accounts.d.ts.map +1 -0
- package/dist/types/isv-accounts.js +22 -0
- package/dist/types/isv-accounts.js.map +1 -0
- package/dist/types/isv-payments.d.ts +262 -0
- package/dist/types/isv-payments.d.ts.map +1 -0
- package/dist/types/isv-payments.js +19 -0
- package/dist/types/isv-payments.js.map +1 -0
- package/dist/types/status.d.ts +125 -0
- package/dist/types/status.d.ts.map +1 -0
- package/dist/types/status.js +19 -0
- package/dist/types/status.js.map +1 -0
- package/dist/types/webhook-events.d.ts +447 -0
- package/dist/types/webhook-events.d.ts.map +1 -0
- package/dist/types/webhook-events.js +76 -0
- package/dist/types/webhook-events.js.map +1 -0
- package/dist/webhooks/challenge-response.d.ts +28 -0
- package/dist/webhooks/challenge-response.d.ts.map +1 -0
- package/dist/webhooks/challenge-response.js +35 -0
- package/dist/webhooks/challenge-response.js.map +1 -0
- package/dist/webhooks/event-types.d.ts +44 -0
- package/dist/webhooks/event-types.d.ts.map +1 -0
- package/dist/webhooks/event-types.js +50 -0
- package/dist/webhooks/event-types.js.map +1 -0
- package/dist/webhooks/extract-client-ip.d.ts +40 -0
- package/dist/webhooks/extract-client-ip.d.ts.map +1 -0
- package/dist/webhooks/extract-client-ip.js +72 -0
- package/dist/webhooks/extract-client-ip.js.map +1 -0
- package/dist/webhooks/hmac-verify.d.ts +38 -0
- package/dist/webhooks/hmac-verify.d.ts.map +1 -0
- package/dist/webhooks/hmac-verify.js +92 -0
- package/dist/webhooks/hmac-verify.js.map +1 -0
- package/dist/webhooks/index.d.ts +19 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +19 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/ip-allowlist.d.ts +59 -0
- package/dist/webhooks/ip-allowlist.d.ts.map +1 -0
- package/dist/webhooks/ip-allowlist.js +147 -0
- package/dist/webhooks/ip-allowlist.js.map +1 -0
- package/dist/webhooks/status-lattice.d.ts +72 -0
- package/dist/webhooks/status-lattice.d.ts.map +1 -0
- package/dist/webhooks/status-lattice.js +208 -0
- package/dist/webhooks/status-lattice.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ISV Payment API request and response types.
|
|
3
|
+
*
|
|
4
|
+
* Covers: CreatePaymentOrder, RetrieveTransaction, RefundTransaction,
|
|
5
|
+
* CancelOrder. All amounts are in integer minor units (bigint) per plan P15.
|
|
6
|
+
*
|
|
7
|
+
* The ISV Payment API uses the same Smart Checkout order-creation endpoint
|
|
8
|
+
* as the standard Payment API but with an additional `merchantId` query
|
|
9
|
+
* parameter to scope the payment to a specific connected merchant.
|
|
10
|
+
*
|
|
11
|
+
* Type attribution: structure referenced from @nkhind/vivawallet-sdk with
|
|
12
|
+
* fresh hand-rolled definitions. No code copied.
|
|
13
|
+
*
|
|
14
|
+
* @see references/viva-docs/md/payment-isv-api.txt:1
|
|
15
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:158
|
|
16
|
+
* @see references/viva-docs/md/webhooks-for-payments.txt:248
|
|
17
|
+
*/
|
|
18
|
+
import type { CurrencyCode, MinorUnits, OrderCode, TransactionId } from './common.js';
|
|
19
|
+
/**
|
|
20
|
+
* Request body for ISV Create Payment Order.
|
|
21
|
+
*
|
|
22
|
+
* Sent as `POST /checkout/v2/orders?merchantId={merchantId}` with a bearer
|
|
23
|
+
* token. The `amount` field MUST be in integer minor units (e.g. 1234 for
|
|
24
|
+
* EUR 12.34). The `currencyCode` is the ISO 4217 numeric string.
|
|
25
|
+
*
|
|
26
|
+
* @see references/viva-docs/md/payment-isv-api.txt:1
|
|
27
|
+
*/
|
|
28
|
+
export interface CreateOrderRequest {
|
|
29
|
+
/**
|
|
30
|
+
* Payment amount in integer minor units.
|
|
31
|
+
* Wire format is a JSON integer; internally held as bigint.
|
|
32
|
+
* Example: 1234 for EUR 12.34.
|
|
33
|
+
*/
|
|
34
|
+
readonly amount: MinorUnits;
|
|
35
|
+
/**
|
|
36
|
+
* ISO 4217 numeric currency code string (e.g. "978" for EUR).
|
|
37
|
+
*
|
|
38
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:487
|
|
39
|
+
*/
|
|
40
|
+
readonly currencyCode: CurrencyCode;
|
|
41
|
+
/**
|
|
42
|
+
* Merchant-facing transaction reference (max 50 chars).
|
|
43
|
+
* Stored on the order and returned in webhook EventData.MerchantTrns.
|
|
44
|
+
*/
|
|
45
|
+
readonly merchantTrns?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Customer-facing transaction description shown on Smart Checkout page
|
|
48
|
+
* and bank statement (max 255 chars).
|
|
49
|
+
*/
|
|
50
|
+
readonly customerTrns?: string;
|
|
51
|
+
/** Customer email used for receipt and 3DS. */
|
|
52
|
+
readonly customerEmail?: string;
|
|
53
|
+
/** Customer phone number. */
|
|
54
|
+
readonly customerPhone?: string;
|
|
55
|
+
/** Customer full name. */
|
|
56
|
+
readonly customerFullName?: string;
|
|
57
|
+
/**
|
|
58
|
+
* URL to redirect the customer after successful payment.
|
|
59
|
+
* If omitted, Viva uses the source's configured success URL.
|
|
60
|
+
*/
|
|
61
|
+
readonly successUrl?: string;
|
|
62
|
+
/**
|
|
63
|
+
* URL to redirect the customer after payment failure.
|
|
64
|
+
* If omitted, Viva uses the source's configured failure URL.
|
|
65
|
+
*/
|
|
66
|
+
readonly failureUrl?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Arbitrary tags for reporting purposes (max 10 entries, each max 50 chars).
|
|
69
|
+
*
|
|
70
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:218
|
|
71
|
+
*/
|
|
72
|
+
readonly tags?: readonly string[];
|
|
73
|
+
/**
|
|
74
|
+
* Payment source code. Required for physical-location ISV sources.
|
|
75
|
+
* Omit to use the account default ("Default") source.
|
|
76
|
+
*
|
|
77
|
+
* @see references/viva-docs/md/payment-source-for-isv.txt:101
|
|
78
|
+
*/
|
|
79
|
+
readonly sourceCode?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Number of installments (1 = no installments).
|
|
82
|
+
* Must be agreed with Viva; not supported in all markets.
|
|
83
|
+
*/
|
|
84
|
+
readonly paymentTimeoutSeconds?: number;
|
|
85
|
+
/** Pre-selected payment method (e.g. 'card'). */
|
|
86
|
+
readonly preselectedPaymentMethod?: string;
|
|
87
|
+
/**
|
|
88
|
+
* ISV fee in integer minor units. ISV-mode only.
|
|
89
|
+
*
|
|
90
|
+
* Stripped from the wire body when `Payments.mode === 'merchant'` — only
|
|
91
|
+
* sent on `POST /checkout/v2/isv/orders` calls. Callers may set this on a
|
|
92
|
+
* single `CreateOrderRequest` regardless of mode; the client will drop it
|
|
93
|
+
* in merchant mode and forward it in ISV mode.
|
|
94
|
+
*
|
|
95
|
+
* @see references/viva-docs/md/isv-partner-program.txt:296
|
|
96
|
+
*/
|
|
97
|
+
readonly isvAmount?: MinorUnits;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Response from ISV Create Payment Order.
|
|
101
|
+
*
|
|
102
|
+
* On success (HTTP 200), Viva returns an `orderCode` which serves as the
|
|
103
|
+
* unique identifier of the created order. Build the Smart Checkout redirect
|
|
104
|
+
* URL as: `{smartCheckoutBaseUrl}?ref={orderCode}&color=%23{hex}`.
|
|
105
|
+
*
|
|
106
|
+
* @see references/viva-docs/md/payment-isv-api.txt:1
|
|
107
|
+
*/
|
|
108
|
+
export interface CreateOrderResponse {
|
|
109
|
+
/**
|
|
110
|
+
* Order code (int64) uniquely identifying this payment order globally.
|
|
111
|
+
* Used to build the Smart Checkout redirect URL and correlate webhooks.
|
|
112
|
+
* Stored as bigint to preserve precision.
|
|
113
|
+
*
|
|
114
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:176
|
|
115
|
+
*/
|
|
116
|
+
readonly orderCode: OrderCode;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Response from ISV Retrieve Transaction Details.
|
|
120
|
+
*
|
|
121
|
+
* Call as `GET /checkout/v2/transactions/{transactionId}?merchantId={merchantId}`.
|
|
122
|
+
* Per Viva docs, this SHOULD be called before updating local state on any
|
|
123
|
+
* webhook delivery.
|
|
124
|
+
*
|
|
125
|
+
* @see references/viva-docs/md/webhooks-for-payments.txt:248
|
|
126
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:119
|
|
127
|
+
*/
|
|
128
|
+
export interface RetrieveTransactionResponse {
|
|
129
|
+
/** Unique transaction identifier. */
|
|
130
|
+
readonly transactionId: TransactionId;
|
|
131
|
+
/** The order this transaction belongs to. */
|
|
132
|
+
readonly orderCode: OrderCode;
|
|
133
|
+
/**
|
|
134
|
+
* Transaction status letter from Viva.
|
|
135
|
+
* Use `VivaStatusLetter` from status.ts for the exhaustive set.
|
|
136
|
+
*
|
|
137
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:398
|
|
138
|
+
*/
|
|
139
|
+
readonly statusId: string;
|
|
140
|
+
/**
|
|
141
|
+
* Transaction amount in integer minor units.
|
|
142
|
+
* NOTE: Viva docs show `Amount` as `decimal` in some webhook payloads but
|
|
143
|
+
* the createOrder request uses integer minor units. Treat as minor units
|
|
144
|
+
* unless a live demo payment confirms otherwise.
|
|
145
|
+
*
|
|
146
|
+
* TODO(impl): verify Amount unit (minor int vs major decimal) against
|
|
147
|
+
* first real demo payment end-to-end.
|
|
148
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:345
|
|
149
|
+
*/
|
|
150
|
+
readonly amount: MinorUnits;
|
|
151
|
+
/** ISO 4217 numeric currency code. */
|
|
152
|
+
readonly currencyCode: CurrencyCode;
|
|
153
|
+
/** Merchant ID that owns this transaction. */
|
|
154
|
+
readonly merchantId: string;
|
|
155
|
+
/** Parent transaction ID if this is a refund. */
|
|
156
|
+
readonly parentId: TransactionId | null;
|
|
157
|
+
/** ISO 8601 timestamp when the transaction was inserted. */
|
|
158
|
+
readonly insDate: string;
|
|
159
|
+
/** Transaction type numeric identifier. */
|
|
160
|
+
readonly transactionTypeId: number;
|
|
161
|
+
/** Masked card number (e.g. "414746XXXXXX0133"). */
|
|
162
|
+
readonly cardNumber?: string;
|
|
163
|
+
/** Card type identifier (0=Visa, 1=Mastercard, etc.). */
|
|
164
|
+
readonly cardTypeId?: number;
|
|
165
|
+
/**
|
|
166
|
+
* Card scheme name derived from `cardTypeId` via
|
|
167
|
+
* {@link import('./card-types.js').resolveCardType resolveCardType}.
|
|
168
|
+
*
|
|
169
|
+
* Emitted as `'Visa' | 'MasterCard' | 'Maestro' | 'Amex' | 'Diners' |
|
|
170
|
+
* 'Discover' | 'JCB'` for known card schemes. `undefined` when the
|
|
171
|
+
* upstream `cardTypeId` is absent, `4` (Invalid), `5` (Unknown), or any
|
|
172
|
+
* value not in the documented mapping.
|
|
173
|
+
*
|
|
174
|
+
* Consumed by `resolveRefundStrategy()` in the refunds module to decide
|
|
175
|
+
* Fast vs Standard refund routing.
|
|
176
|
+
*
|
|
177
|
+
* @see ./card-types.ts
|
|
178
|
+
* @see ../refunds/strategy.ts
|
|
179
|
+
*/
|
|
180
|
+
readonly cardType?: string;
|
|
181
|
+
/** Customer email. */
|
|
182
|
+
readonly email?: string;
|
|
183
|
+
/** Customer full name. */
|
|
184
|
+
readonly fullName?: string;
|
|
185
|
+
/** Merchant-facing reference string. */
|
|
186
|
+
readonly merchantTrns?: string;
|
|
187
|
+
/** Customer-facing reference string. */
|
|
188
|
+
readonly customerTrns?: string;
|
|
189
|
+
/** Connected account ID if ISV scoped. */
|
|
190
|
+
readonly connectedAccountId?: string;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Request body for ISV Refund Transaction.
|
|
194
|
+
*
|
|
195
|
+
* Sent as `POST /checkout/v2/transactions/{transactionId}` with a bearer
|
|
196
|
+
* or reseller token. Partial refunds are supported by specifying `amount`.
|
|
197
|
+
* If `amount` is omitted, a full refund is issued.
|
|
198
|
+
*
|
|
199
|
+
* Per plan P18: validate `amount <= (captured - already_refunded)` before
|
|
200
|
+
* calling Viva. ISV fee reverses automatically on full/partial refund.
|
|
201
|
+
*
|
|
202
|
+
* @see references/viva-docs/md/isv-partner-program.txt:296
|
|
203
|
+
*/
|
|
204
|
+
export interface RefundRequest {
|
|
205
|
+
/**
|
|
206
|
+
* Refund amount in integer minor units.
|
|
207
|
+
* Must be <= (captured_amount - already_refunded_amount).
|
|
208
|
+
* Omit for a full refund.
|
|
209
|
+
*/
|
|
210
|
+
readonly amount?: MinorUnits;
|
|
211
|
+
/** Merchant reference for this refund. */
|
|
212
|
+
readonly merchantTrns?: string;
|
|
213
|
+
/** Customer reference for this refund. */
|
|
214
|
+
readonly customerTrns?: string;
|
|
215
|
+
/** Source code. Required for ISV refunds in some configurations. */
|
|
216
|
+
readonly sourceCode?: string;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Response from ISV Refund Transaction.
|
|
220
|
+
*
|
|
221
|
+
* Returned by the legacy `POST /api/transactions/{transactionId}` endpoint.
|
|
222
|
+
* Viva returns PascalCase field names; the SDK normalises to camelCase.
|
|
223
|
+
*
|
|
224
|
+
* Probe-verified 2026-04-25: the legacy endpoint is the ONLY supported refund path.
|
|
225
|
+
* `POST /checkout/v2/transactions/{id}` (v2/OAuth2) returns 405 on Viva sandbox.
|
|
226
|
+
*
|
|
227
|
+
* @see references/viva-docs/md/tut-create-recurring-payment.txt:288
|
|
228
|
+
*/
|
|
229
|
+
export interface RefundResponse {
|
|
230
|
+
/** ID of the newly created refund transaction. */
|
|
231
|
+
readonly transactionId: TransactionId;
|
|
232
|
+
/** Viva status identifier for the refund transaction. */
|
|
233
|
+
readonly statusId?: string;
|
|
234
|
+
/** Refunded amount in minor units (echoed from request). */
|
|
235
|
+
readonly amount?: MinorUnits;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Response from ISV Cancel Order.
|
|
239
|
+
*
|
|
240
|
+
* Sent as `DELETE /checkout/v2/orders/{orderCode}?merchantId={merchantId}`.
|
|
241
|
+
* Used for orders that have not yet been paid. Idempotent — cancelling an
|
|
242
|
+
* already-cancelled or captured order returns the existing Viva response.
|
|
243
|
+
*
|
|
244
|
+
* Note: per plan Q5, cancelOrder may require ResellerBasicAuthStrategy.
|
|
245
|
+
* Confirm during S2/S3 implementation.
|
|
246
|
+
*
|
|
247
|
+
* @see references/viva-docs/md/payment-isv-api.txt:1
|
|
248
|
+
*/
|
|
249
|
+
export interface CancelOrderResponse {
|
|
250
|
+
/** Order code of the cancelled order. */
|
|
251
|
+
readonly orderCode: OrderCode;
|
|
252
|
+
/**
|
|
253
|
+
* HTTP status code returned by Viva.
|
|
254
|
+
* Typically 200 on success.
|
|
255
|
+
*
|
|
256
|
+
* TODO(impl): verify exact response body shape for cancelOrder via demo.
|
|
257
|
+
* @see references/viva-docs/md/payment-isv-api.txt:1
|
|
258
|
+
*/
|
|
259
|
+
readonly errorCode: number;
|
|
260
|
+
readonly errorText: string;
|
|
261
|
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,CAAC,EAAE,MAAM,CAAC;CACtC;AAMD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B,0CAA0C;IAC1C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,0CAA0C;IAC1C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,oEAAoE;IACpE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;CAAC;AAMhC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ISV Payment API request and response types.
|
|
3
|
+
*
|
|
4
|
+
* Covers: CreatePaymentOrder, RetrieveTransaction, RefundTransaction,
|
|
5
|
+
* CancelOrder. All amounts are in integer minor units (bigint) per plan P15.
|
|
6
|
+
*
|
|
7
|
+
* The ISV Payment API uses the same Smart Checkout order-creation endpoint
|
|
8
|
+
* as the standard Payment API but with an additional `merchantId` query
|
|
9
|
+
* parameter to scope the payment to a specific connected merchant.
|
|
10
|
+
*
|
|
11
|
+
* Type attribution: structure referenced from @nkhind/vivawallet-sdk with
|
|
12
|
+
* fresh hand-rolled definitions. No code copied.
|
|
13
|
+
*
|
|
14
|
+
* @see references/viva-docs/md/payment-isv-api.txt:1
|
|
15
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:158
|
|
16
|
+
* @see references/viva-docs/md/webhooks-for-payments.txt:248
|
|
17
|
+
*/
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=isv-payments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isv-payments.js","sourceRoot":"","sources":["../../src/types/isv-payments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Viva transaction status letter mapping and plugin status enum.
|
|
3
|
+
*
|
|
4
|
+
* Implements plan P17: maps Viva's raw `StatusId` letter codes to the
|
|
5
|
+
* plugin's canonical `VivaTransactionStatus` enum. The M-family letters
|
|
6
|
+
* (M, MA, MI, ML, MS, MW) all map to `'disputed'` with the specific
|
|
7
|
+
* letter stored in `claim_substate`.
|
|
8
|
+
*
|
|
9
|
+
* Implements plan A9: adds `authorized → cancelled` transition
|
|
10
|
+
* (void-before-capture).
|
|
11
|
+
*
|
|
12
|
+
* The actual runtime `mapStatusLetter` function lives in S4
|
|
13
|
+
* (src/webhooks/status-lattice.ts). This file is types only.
|
|
14
|
+
*
|
|
15
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:398
|
|
16
|
+
* @see references/viva-docs/md/wh-sale-transactions.txt:210
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Viva `StatusId` string values as documented.
|
|
20
|
+
*
|
|
21
|
+
* Single-letter values:
|
|
22
|
+
* F = Finished (captured/completed)
|
|
23
|
+
* A = Active (authorized, awaiting capture)
|
|
24
|
+
* C = Captured
|
|
25
|
+
* E = Error (failed)
|
|
26
|
+
* R = Refunded
|
|
27
|
+
* X = Cancelled
|
|
28
|
+
*
|
|
29
|
+
* Claim/dispute multi-letter values:
|
|
30
|
+
* M = Claimed
|
|
31
|
+
* MA = Claim Awaiting Response
|
|
32
|
+
* MI = Claim In Progress
|
|
33
|
+
* ML = Claim Lost
|
|
34
|
+
* MS = Suspected Claimed
|
|
35
|
+
* MW = Claim Won
|
|
36
|
+
*
|
|
37
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:398
|
|
38
|
+
*/
|
|
39
|
+
export type VivaStatusLetter = 'F' | 'A' | 'C' | 'E' | 'R' | 'X' | 'M' | 'MA' | 'MI' | 'ML' | 'MS' | 'MW';
|
|
40
|
+
/**
|
|
41
|
+
* Plugin canonical transaction status enum.
|
|
42
|
+
*
|
|
43
|
+
* This is what viva_transaction.status stores in the database.
|
|
44
|
+
* Defined as string literals for direct SQL/JSON compatibility.
|
|
45
|
+
*
|
|
46
|
+
* Monotonic lattice (plan A9):
|
|
47
|
+
* initiated → authorized → captured → refunded (terminal)
|
|
48
|
+
* → cancelled (terminal)
|
|
49
|
+
* → disputed +substate (terminal from captured)
|
|
50
|
+
* → failed (terminal)
|
|
51
|
+
* authorized → cancelled (void-before-capture)
|
|
52
|
+
*
|
|
53
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:398
|
|
54
|
+
*/
|
|
55
|
+
export type VivaTransactionStatus = 'initiated' | 'authorized' | 'captured' | 'refunded' | 'cancelled' | 'failed' | 'disputed';
|
|
56
|
+
/**
|
|
57
|
+
* The claim sub-states for disputed transactions.
|
|
58
|
+
* Stored in viva_transaction.claim_substate when status = 'disputed'.
|
|
59
|
+
*
|
|
60
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:411
|
|
61
|
+
*/
|
|
62
|
+
export type VivaClaimSubstate = 'M' | 'MA' | 'MI' | 'ML' | 'MS' | 'MW';
|
|
63
|
+
/**
|
|
64
|
+
* Type-level mapping from VivaStatusLetter to VivaTransactionStatus.
|
|
65
|
+
* Used as documentation and compile-time reference for S4 implementors.
|
|
66
|
+
*
|
|
67
|
+
* Runtime function `mapStatusLetter(letter) → VivaTransactionStatus` lives in:
|
|
68
|
+
* packages/viva-payments-core/src/webhooks/status-lattice.ts
|
|
69
|
+
*
|
|
70
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:398
|
|
71
|
+
*/
|
|
72
|
+
export type StatusLetterToTransactionStatus = {
|
|
73
|
+
readonly F: 'captured';
|
|
74
|
+
readonly A: 'authorized';
|
|
75
|
+
readonly C: 'captured';
|
|
76
|
+
readonly E: 'failed';
|
|
77
|
+
readonly R: 'refunded';
|
|
78
|
+
readonly X: 'cancelled';
|
|
79
|
+
readonly M: 'disputed';
|
|
80
|
+
readonly MA: 'disputed';
|
|
81
|
+
readonly MI: 'disputed';
|
|
82
|
+
readonly ML: 'disputed';
|
|
83
|
+
readonly MS: 'disputed';
|
|
84
|
+
readonly MW: 'disputed';
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Status letters that map to the `'disputed'` plugin status.
|
|
88
|
+
* The specific letter MUST be preserved in `claim_substate`.
|
|
89
|
+
*
|
|
90
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:411
|
|
91
|
+
*/
|
|
92
|
+
export type ClaimStatusLetter = 'M' | 'MA' | 'MI' | 'ML' | 'MS' | 'MW';
|
|
93
|
+
/**
|
|
94
|
+
* Terminal statuses — once reached, no further transitions are allowed.
|
|
95
|
+
* The monotonic lattice in status-lattice.ts enforces this invariant.
|
|
96
|
+
*
|
|
97
|
+
* @see Plan P17, Plan A9
|
|
98
|
+
*/
|
|
99
|
+
export type TerminalVivaTransactionStatus = 'captured' | 'refunded' | 'cancelled' | 'failed' | 'disputed';
|
|
100
|
+
/**
|
|
101
|
+
* Non-terminal statuses — transitions out of these are allowed.
|
|
102
|
+
*/
|
|
103
|
+
export type NonTerminalVivaTransactionStatus = Exclude<VivaTransactionStatus, TerminalVivaTransactionStatus>;
|
|
104
|
+
/**
|
|
105
|
+
* A status transition — from a non-terminal state to any target state.
|
|
106
|
+
* The status-lattice runtime validates this against the allowed lattice.
|
|
107
|
+
*/
|
|
108
|
+
export interface StatusTransition {
|
|
109
|
+
readonly from: VivaTransactionStatus;
|
|
110
|
+
readonly to: VivaTransactionStatus;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Result of applying a status letter to the current lattice state.
|
|
114
|
+
* If `allowed` is false, the transition is a no-op and should be logged
|
|
115
|
+
* as a warning (backwards transition attempt).
|
|
116
|
+
*/
|
|
117
|
+
export type StatusTransitionResult = {
|
|
118
|
+
readonly allowed: true;
|
|
119
|
+
readonly nextStatus: VivaTransactionStatus;
|
|
120
|
+
readonly claimSubstate?: VivaClaimSubstate;
|
|
121
|
+
} | {
|
|
122
|
+
readonly allowed: false;
|
|
123
|
+
readonly reason: string;
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/types/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,gBAAgB,GACxB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,CAAC;AAMT;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,YAAY,GACZ,UAAU,GACV,UAAU,GACV,WAAW,GACX,QAAQ,GACR,UAAU,CAAC;AAEf;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAMvE;;;;;;;;GAQG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC;IACvB,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC;IACz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
|
|
1
|
+
/**
|
|
2
|
+
* Viva transaction status letter mapping and plugin status enum.
|
|
3
|
+
*
|
|
4
|
+
* Implements plan P17: maps Viva's raw `StatusId` letter codes to the
|
|
5
|
+
* plugin's canonical `VivaTransactionStatus` enum. The M-family letters
|
|
6
|
+
* (M, MA, MI, ML, MS, MW) all map to `'disputed'` with the specific
|
|
7
|
+
* letter stored in `claim_substate`.
|
|
8
|
+
*
|
|
9
|
+
* Implements plan A9: adds `authorized → cancelled` transition
|
|
10
|
+
* (void-before-capture).
|
|
11
|
+
*
|
|
12
|
+
* The actual runtime `mapStatusLetter` function lives in S4
|
|
13
|
+
* (src/webhooks/status-lattice.ts). This file is types only.
|
|
14
|
+
*
|
|
15
|
+
* @see references/viva-docs/md/wh-transaction-payment-created.txt:398
|
|
16
|
+
* @see references/viva-docs/md/wh-sale-transactions.txt:210
|
|
17
|
+
*/
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/types/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG"}
|