@waffo/pancake-ts 0.11.0 → 0.13.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/CHANGELOG.md +21 -0
- package/README.md +43 -42
- package/dist/index.cjs +147 -131
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +201 -174
- package/dist/index.d.ts +201 -174
- package/dist/index.js +147 -131
- package/dist/index.js.map +1 -1
- package/docs/api-reference.md +31 -28
- package/docs/webhook-guide.md +14 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -225,7 +225,7 @@ declare enum ErrorLayer {
|
|
|
225
225
|
Sdk = "sdk"
|
|
226
226
|
}
|
|
227
227
|
/**
|
|
228
|
-
* Parameters for issuing a
|
|
228
|
+
* Parameters for issuing a customer session token.
|
|
229
229
|
*
|
|
230
230
|
* Provide either `storeId` or `productId` (at least one required).
|
|
231
231
|
* When `productId` is given without `storeId`, the server derives the store from the product.
|
|
@@ -234,7 +234,7 @@ declare enum ErrorLayer {
|
|
|
234
234
|
*/
|
|
235
235
|
interface IssueSessionTokenParams {
|
|
236
236
|
/**
|
|
237
|
-
*
|
|
237
|
+
* Customer identity — encoded into the JWT payload for merchant-side customer
|
|
238
238
|
* identification. Accepts an email or any merchant-provided identifier string.
|
|
239
239
|
* To pre-fill the checkout page's email field, use `buyerEmail` on
|
|
240
240
|
* `checkout.authenticated.create`.
|
|
@@ -697,7 +697,7 @@ interface CancelSubscriptionResult {
|
|
|
697
697
|
status: `${SubscriptionOrderStatus}`;
|
|
698
698
|
}
|
|
699
699
|
/**
|
|
700
|
-
*
|
|
700
|
+
* Customer billing details for checkout.
|
|
701
701
|
* @see waffo-pancake-order-service/app/lib/types.ts
|
|
702
702
|
*/
|
|
703
703
|
interface BillingDetail {
|
|
@@ -714,6 +714,14 @@ interface BillingDetail {
|
|
|
714
714
|
/** Tax ID / VAT number (EU businesses: triggers reverse charge 0% when provided) */
|
|
715
715
|
taxId?: string;
|
|
716
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* Supported checkout cashier languages (IETF BCP 47 tags).
|
|
719
|
+
*
|
|
720
|
+
* The default language of the hosted checkout page. Pass one of these values as
|
|
721
|
+
* {@link CreateCheckoutSessionParams.language}; the customer can still switch language
|
|
722
|
+
* on the checkout page. Language×currency mismatches are rejected by the payment provider.
|
|
723
|
+
*/
|
|
724
|
+
type CashierLanguage = "en" | "pt-BR" | "es-MX" | "id-ID" | "vi-VN" | "ru-RU" | "en-KE" | "es-PE" | "es-CO" | "es-CL" | "zh-Hant-TW" | "zh-Hant-HK" | "th-TH" | "ja-JP" | "en-NG" | "ko-KR" | "en-HK" | "zh-Hans-HK" | "pl-PL" | "tr-TR" | "zh-Hans" | "ms-MY";
|
|
717
725
|
/**
|
|
718
726
|
* Parameters for creating a checkout session.
|
|
719
727
|
* @see waffo-pancake-order-service/app/lib/types.ts CreateCheckoutSessionRequest
|
|
@@ -727,7 +735,7 @@ interface CreateCheckoutSessionParams {
|
|
|
727
735
|
priceSnapshot?: PriceInfo;
|
|
728
736
|
/** Trial toggle override (subscription only) */
|
|
729
737
|
withTrial?: boolean;
|
|
730
|
-
/** Pre-filled
|
|
738
|
+
/** Pre-filled customer email */
|
|
731
739
|
buyerEmail?: string;
|
|
732
740
|
/** Pre-filled billing details */
|
|
733
741
|
billingDetail?: BillingDetail;
|
|
@@ -741,6 +749,11 @@ interface CreateCheckoutSessionParams {
|
|
|
741
749
|
metadata?: Record<string, string>;
|
|
742
750
|
/** Order-side business identifier (max 128 chars); inherited by orders, payments, refunds */
|
|
743
751
|
orderMerchantExternalId?: string;
|
|
752
|
+
/**
|
|
753
|
+
* Default language of the hosted checkout page ({@link CashierLanguage}, IETF BCP 47).
|
|
754
|
+
* The customer can switch language on the checkout page. Omit to let the provider infer.
|
|
755
|
+
*/
|
|
756
|
+
language?: CashierLanguage;
|
|
744
757
|
}
|
|
745
758
|
/** Result of creating a checkout session. */
|
|
746
759
|
interface CheckoutSessionResult {
|
|
@@ -751,7 +764,7 @@ interface CheckoutSessionResult {
|
|
|
751
764
|
/** Session expiration time (ISO 8601 UTC) */
|
|
752
765
|
expiresAt: string;
|
|
753
766
|
}
|
|
754
|
-
/** Parameters for canceling a one-time order (
|
|
767
|
+
/** Parameters for canceling a one-time order (customer-side). */
|
|
755
768
|
interface CancelOnetimeOrderParams {
|
|
756
769
|
/** Order ID */
|
|
757
770
|
orderId: string;
|
|
@@ -763,7 +776,7 @@ interface CancelOnetimeOrderResult {
|
|
|
763
776
|
/** Resulting status (`"canceled"`) */
|
|
764
777
|
status: string;
|
|
765
778
|
}
|
|
766
|
-
/** Parameters for reactivating a subscription (
|
|
779
|
+
/** Parameters for reactivating a subscription (customer-side). */
|
|
767
780
|
interface ReactivateSubscriptionParams {
|
|
768
781
|
/** Subscription order ID */
|
|
769
782
|
orderId: string;
|
|
@@ -787,12 +800,12 @@ interface RequestedAmount {
|
|
|
787
800
|
* multiple times; this is the shape of a single submission.
|
|
788
801
|
*/
|
|
789
802
|
interface RefundTicketVersionData {
|
|
790
|
-
/** Refund reason supplied by the
|
|
803
|
+
/** Refund reason supplied by the customer */
|
|
791
804
|
reason: string;
|
|
792
805
|
/** Requested refund amount; `null` if the version has no amount recorded */
|
|
793
806
|
requestedAmount: RequestedAmount | null;
|
|
794
807
|
}
|
|
795
|
-
/** Parameters for creating a refund ticket (
|
|
808
|
+
/** Parameters for creating a refund ticket (customer-side). */
|
|
796
809
|
interface CreateRefundTicketParams {
|
|
797
810
|
/** Payment ID to refund */
|
|
798
811
|
paymentId: string;
|
|
@@ -805,7 +818,7 @@ interface CreateRefundTicketParams {
|
|
|
805
818
|
/** Refund-ticket business-side identifier (max 128 chars); inherited by the executed refund on PSP success */
|
|
806
819
|
refundTicketMerchantExternalId?: string;
|
|
807
820
|
}
|
|
808
|
-
/** Parameters for resubmitting a rejected refund ticket (
|
|
821
|
+
/** Parameters for resubmitting a rejected refund ticket (customer-side). */
|
|
809
822
|
interface ResubmitRefundTicketParams {
|
|
810
823
|
/** Existing ticket ID */
|
|
811
824
|
ticketId: string;
|
|
@@ -858,7 +871,7 @@ interface RefundTicket {
|
|
|
858
871
|
/**
|
|
859
872
|
* Parameters for anonymous checkout.
|
|
860
873
|
*
|
|
861
|
-
* The
|
|
874
|
+
* The customer reaches the checkout page without a session token. Merchants may still
|
|
862
875
|
* pre-fill `buyerEmail` and `billingDetail`; omitting them leaves the form blank.
|
|
863
876
|
*
|
|
864
877
|
* Accepts every field of {@link CreateCheckoutSessionParams} — this wrapper simply
|
|
@@ -884,15 +897,15 @@ type AnonymousCheckoutParams = CreateCheckoutSessionParams;
|
|
|
884
897
|
* const result = await client.checkout.authenticated.create({
|
|
885
898
|
* productId: "PROD_xxx",
|
|
886
899
|
* currency: "USD",
|
|
887
|
-
* buyerIdentity: "user-123", // merchant-side
|
|
900
|
+
* buyerIdentity: "user-123", // merchant-side customer id (goes into JWT)
|
|
888
901
|
* buyerEmail: "customer@example.com", // pre-filled on the checkout page
|
|
889
902
|
* });
|
|
890
903
|
* // Redirect to result.checkoutUrl (includes #token=...)
|
|
891
904
|
*/
|
|
892
905
|
interface AuthenticatedCheckoutParams extends CreateCheckoutSessionParams {
|
|
893
906
|
/**
|
|
894
|
-
*
|
|
895
|
-
* payload for merchant-side
|
|
907
|
+
* Customer identity — sent to `issue-session-token` and encoded into the JWT
|
|
908
|
+
* payload for merchant-side customer identification. Accepts an email or any
|
|
896
909
|
* merchant-provided identifier string. Use `buyerEmail` to pre-fill the
|
|
897
910
|
* checkout page's email input.
|
|
898
911
|
*/
|
|
@@ -953,9 +966,9 @@ declare enum WebhookEventType {
|
|
|
953
966
|
SubscriptionActivated = "subscription.activated",
|
|
954
967
|
/** Subscription renewal payment succeeded */
|
|
955
968
|
SubscriptionPaymentSucceeded = "subscription.payment_succeeded",
|
|
956
|
-
/**
|
|
969
|
+
/** Customer initiated cancellation (expires at end of current period) */
|
|
957
970
|
SubscriptionCanceling = "subscription.canceling",
|
|
958
|
-
/**
|
|
971
|
+
/** Customer withdrew cancellation (subscription restored) */
|
|
959
972
|
SubscriptionUncanceled = "subscription.uncanceled",
|
|
960
973
|
/** Subscription product changed (upgrade/downgrade) */
|
|
961
974
|
SubscriptionUpdated = "subscription.updated",
|
|
@@ -977,7 +990,7 @@ interface WebhookEventData {
|
|
|
977
990
|
/** Order status (e.g., "completed", "active", "canceling") */
|
|
978
991
|
orderStatus?: string;
|
|
979
992
|
buyerEmail: string;
|
|
980
|
-
/** Merchant-provided
|
|
993
|
+
/** Merchant-provided customer identity from checkout session */
|
|
981
994
|
merchantProvidedBuyerIdentity?: string;
|
|
982
995
|
/** Order business identifier; present on order/payment + refund events (inherited from order) */
|
|
983
996
|
orderMerchantExternalId?: string;
|
|
@@ -1152,12 +1165,12 @@ declare class HttpClient {
|
|
|
1152
1165
|
post<T>(path: string, body: object, options?: PostOptions): Promise<PostResult<T>>;
|
|
1153
1166
|
}
|
|
1154
1167
|
|
|
1155
|
-
/** Authentication resource — issue session tokens for
|
|
1168
|
+
/** Authentication resource — issue session tokens for customers. */
|
|
1156
1169
|
declare class AuthResource {
|
|
1157
1170
|
private readonly http;
|
|
1158
1171
|
constructor(http: HttpClient);
|
|
1159
1172
|
/**
|
|
1160
|
-
* Issue a session token for a
|
|
1173
|
+
* Issue a session token for a customer.
|
|
1161
1174
|
*
|
|
1162
1175
|
* @param params - Token issuance parameters
|
|
1163
1176
|
* @returns Issued session token with expiration
|
|
@@ -1182,147 +1195,9 @@ declare class AuthResource {
|
|
|
1182
1195
|
}
|
|
1183
1196
|
|
|
1184
1197
|
/**
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
* Unlike {@link HttpClient} which signs requests with RSA-SHA256 (API Key auth),
|
|
1188
|
-
* this client attaches a session token as `Authorization: Bearer <token>` and
|
|
1189
|
-
* never sends an idempotency key (buyer session actions are not protected by
|
|
1190
|
-
* gateway idempotency in the current architecture).
|
|
1191
|
-
*
|
|
1192
|
-
* Not exported publicly — used internally by {@link BuyerSession}.
|
|
1193
|
-
*/
|
|
1194
|
-
declare class BuyerHttpClient {
|
|
1195
|
-
private readonly token;
|
|
1196
|
-
private readonly baseUrl;
|
|
1197
|
-
private readonly _fetch;
|
|
1198
|
-
constructor(token: string, config: Pick<WaffoPancakeConfig, "baseUrl" | "fetch">);
|
|
1199
|
-
/**
|
|
1200
|
-
* Send a Bearer-authenticated POST and return the full envelope plus HTTP status.
|
|
1201
|
-
*
|
|
1202
|
-
* Does NOT throw on `errors[]` or non-2xx status — caller inspects the result.
|
|
1203
|
-
* Throws {@link WaffoPancakeError} only when the response body is not valid JSON.
|
|
1204
|
-
*/
|
|
1205
|
-
post<T>(path: string, body: object): Promise<PostResult<T>>;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
/**
|
|
1209
|
-
* Buyer session — lets authenticated buyers manage their own orders and subscriptions.
|
|
1210
|
-
*
|
|
1211
|
-
* Created via `client.buyer(token)` using a session token issued by
|
|
1212
|
-
* `client.auth.issueSessionToken()`. All requests use Bearer token authentication.
|
|
1213
|
-
*
|
|
1214
|
-
* @example
|
|
1215
|
-
* const { token } = await client.auth.issueSessionToken({
|
|
1216
|
-
* storeId: "STO_xxx",
|
|
1217
|
-
* buyerIdentity: "customer@example.com",
|
|
1218
|
-
* });
|
|
1219
|
-
* const buyer = client.buyer(token);
|
|
1220
|
-
* await buyer.cancelSubscription({ orderId: "ORD_xxx" });
|
|
1221
|
-
*/
|
|
1222
|
-
declare class BuyerSession {
|
|
1223
|
-
private readonly http;
|
|
1224
|
-
/** GraphQL query access scoped to the buyer's data. */
|
|
1225
|
-
readonly graphql: BuyerGraphQL;
|
|
1226
|
-
constructor(http: BuyerHttpClient);
|
|
1227
|
-
/**
|
|
1228
|
-
* Cancel a subscription order.
|
|
1229
|
-
*
|
|
1230
|
-
* @param params - Order to cancel
|
|
1231
|
-
* @returns Order ID and resulting status
|
|
1232
|
-
*
|
|
1233
|
-
* @example
|
|
1234
|
-
* const { orderId, status } = await buyer.cancelSubscription({ orderId: "ORD_xxx" });
|
|
1235
|
-
* // status: "canceled" (was pending) or "canceling" (was active)
|
|
1236
|
-
*/
|
|
1237
|
-
cancelSubscription(params: CancelSubscriptionParams): Promise<CancelSubscriptionResult & {
|
|
1238
|
-
warnings?: Notice[];
|
|
1239
|
-
}>;
|
|
1240
|
-
/**
|
|
1241
|
-
* Cancel a one-time order (only while payment is still pending).
|
|
1242
|
-
*
|
|
1243
|
-
* @param params - Order to cancel
|
|
1244
|
-
* @returns Order ID and resulting status
|
|
1245
|
-
*
|
|
1246
|
-
* @example
|
|
1247
|
-
* const { orderId, status } = await buyer.cancelOnetimeOrder({ orderId: "ORD_xxx" });
|
|
1248
|
-
*/
|
|
1249
|
-
cancelOnetimeOrder(params: CancelOnetimeOrderParams): Promise<CancelOnetimeOrderResult & {
|
|
1250
|
-
warnings?: Notice[];
|
|
1251
|
-
}>;
|
|
1252
|
-
/**
|
|
1253
|
-
* Reactivate a subscription that is in `canceling` status.
|
|
1254
|
-
*
|
|
1255
|
-
* @param params - Order to reactivate
|
|
1256
|
-
* @returns Order ID and resulting status
|
|
1257
|
-
*
|
|
1258
|
-
* @example
|
|
1259
|
-
* const { orderId, status } = await buyer.reactivateSubscription({ orderId: "ORD_xxx" });
|
|
1260
|
-
* // status: "active"
|
|
1261
|
-
*/
|
|
1262
|
-
reactivateSubscription(params: ReactivateSubscriptionParams): Promise<ReactivateSubscriptionResult & {
|
|
1263
|
-
warnings?: Notice[];
|
|
1264
|
-
}>;
|
|
1265
|
-
/**
|
|
1266
|
-
* Submit a refund request for a payment.
|
|
1267
|
-
*
|
|
1268
|
-
* @param params - Refund ticket details
|
|
1269
|
-
* @returns Created refund ticket
|
|
1270
|
-
*
|
|
1271
|
-
* @example
|
|
1272
|
-
* const { ticket } = await buyer.createRefundTicket({
|
|
1273
|
-
* paymentId: "PAY_xxx",
|
|
1274
|
-
* reason: "Product not as described",
|
|
1275
|
-
* requestedAmount: { amount: "29.00", currency: "USD" },
|
|
1276
|
-
* refundTicketMerchantExternalId: "REF-2026-00891",
|
|
1277
|
-
* });
|
|
1278
|
-
*/
|
|
1279
|
-
createRefundTicket(params: CreateRefundTicketParams): Promise<{
|
|
1280
|
-
ticket: RefundTicket;
|
|
1281
|
-
warnings?: Notice[];
|
|
1282
|
-
}>;
|
|
1283
|
-
/**
|
|
1284
|
-
* Resubmit a previously rejected refund ticket with updated details.
|
|
1285
|
-
*
|
|
1286
|
-
* @param params - Updated ticket details
|
|
1287
|
-
* @returns Updated refund ticket
|
|
1288
|
-
*
|
|
1289
|
-
* @example
|
|
1290
|
-
* const { ticket } = await buyer.resubmitRefundTicket({
|
|
1291
|
-
* ticketId: "TKT_xxx",
|
|
1292
|
-
* paymentId: "PAY_xxx",
|
|
1293
|
-
* reason: "Updated reason with more detail",
|
|
1294
|
-
* requestedAmount: { amount: "29.00", currency: "USD" },
|
|
1295
|
-
* });
|
|
1296
|
-
*/
|
|
1297
|
-
resubmitRefundTicket(params: ResubmitRefundTicketParams): Promise<{
|
|
1298
|
-
ticket: RefundTicket;
|
|
1299
|
-
warnings?: Notice[];
|
|
1300
|
-
}>;
|
|
1301
|
-
}
|
|
1302
|
-
/**
|
|
1303
|
-
* GraphQL access scoped to the buyer's session token.
|
|
1304
|
-
*/
|
|
1305
|
-
declare class BuyerGraphQL {
|
|
1306
|
-
private readonly http;
|
|
1307
|
-
constructor(http: BuyerHttpClient);
|
|
1308
|
-
/**
|
|
1309
|
-
* Execute a GraphQL query scoped to the buyer's data.
|
|
1310
|
-
*
|
|
1311
|
-
* @param params - GraphQL query and variables
|
|
1312
|
-
* @returns GraphQL response
|
|
1313
|
-
*
|
|
1314
|
-
* @example
|
|
1315
|
-
* const result = await buyer.graphql.query({
|
|
1316
|
-
* query: `query { orders { id status } }`,
|
|
1317
|
-
* });
|
|
1318
|
-
*/
|
|
1319
|
-
query<T = Record<string, unknown>>(params: GraphQLParams): Promise<GraphQLResponse<T>>;
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
/**
|
|
1323
|
-
* Anonymous checkout — no buyer identity provided.
|
|
1198
|
+
* Anonymous checkout — no customer identity provided.
|
|
1324
1199
|
*
|
|
1325
|
-
* The
|
|
1200
|
+
* The customer reaches the checkout page without a session token. Merchants may still
|
|
1326
1201
|
* pre-fill `buyerEmail` and `billingDetail` on the page by passing them here.
|
|
1327
1202
|
* Internally creates a checkout session and returns the redirect URL.
|
|
1328
1203
|
*/
|
|
@@ -1332,11 +1207,11 @@ declare class CheckoutAnonymousResource {
|
|
|
1332
1207
|
/**
|
|
1333
1208
|
* Create an anonymous checkout session.
|
|
1334
1209
|
*
|
|
1335
|
-
* @param params - Checkout parameters (no
|
|
1210
|
+
* @param params - Checkout parameters (no customer identity required)
|
|
1336
1211
|
* @returns Session ID, checkout URL, and expiration
|
|
1337
1212
|
*
|
|
1338
1213
|
* @example
|
|
1339
|
-
* // Minimal —
|
|
1214
|
+
* // Minimal — customer fills everything on the page
|
|
1340
1215
|
* const result = await client.checkout.anonymous.create({
|
|
1341
1216
|
* productId: "PROD_xxx",
|
|
1342
1217
|
* currency: "USD",
|
|
@@ -1358,11 +1233,11 @@ declare class CheckoutAnonymousResource {
|
|
|
1358
1233
|
}
|
|
1359
1234
|
|
|
1360
1235
|
/**
|
|
1361
|
-
* Authenticated checkout — merchant provides
|
|
1236
|
+
* Authenticated checkout — merchant provides customer identity.
|
|
1362
1237
|
*
|
|
1363
1238
|
* Issues a session token, creates a checkout session, and returns a
|
|
1364
1239
|
* checkout URL with the token appended as a URL fragment (`#token=...`).
|
|
1365
|
-
* The checkout page reads the fragment to pre-fill
|
|
1240
|
+
* The checkout page reads the fragment to pre-fill customer information.
|
|
1366
1241
|
*/
|
|
1367
1242
|
declare class CheckoutAuthenticatedResource {
|
|
1368
1243
|
private readonly http;
|
|
@@ -1378,7 +1253,7 @@ declare class CheckoutAuthenticatedResource {
|
|
|
1378
1253
|
* `buyerIdentity` and `buyerEmail` are independent inputs: identity is for the JWT,
|
|
1379
1254
|
* email is for pre-filling the checkout page. The SDK forwards each to its own endpoint.
|
|
1380
1255
|
*
|
|
1381
|
-
* @param params - Checkout parameters including
|
|
1256
|
+
* @param params - Checkout parameters including customer identity
|
|
1382
1257
|
* @returns Session details with token-appended checkout URL
|
|
1383
1258
|
*
|
|
1384
1259
|
* @example
|
|
@@ -1400,8 +1275,8 @@ declare class CheckoutAuthenticatedResource {
|
|
|
1400
1275
|
* Checkout resource — create checkout sessions for payments.
|
|
1401
1276
|
*
|
|
1402
1277
|
* Provides two convenience sub-resources for the common checkout flows:
|
|
1403
|
-
* - `anonymous` — no
|
|
1404
|
-
* - `authenticated` — merchant provides
|
|
1278
|
+
* - `anonymous` — no customer identity, empty form
|
|
1279
|
+
* - `authenticated` — merchant provides customer identity, pre-filled form + token
|
|
1405
1280
|
*
|
|
1406
1281
|
* The low-level `createSession()` method is still available for full control.
|
|
1407
1282
|
*
|
|
@@ -1413,7 +1288,7 @@ declare class CheckoutAuthenticatedResource {
|
|
|
1413
1288
|
* });
|
|
1414
1289
|
*
|
|
1415
1290
|
* @example
|
|
1416
|
-
* // Authenticated checkout (with
|
|
1291
|
+
* // Authenticated checkout (with customer identity)
|
|
1417
1292
|
* const result = await client.checkout.authenticated.create({
|
|
1418
1293
|
* productId: "PROD_xxx",
|
|
1419
1294
|
* currency: "USD",
|
|
@@ -1424,9 +1299,9 @@ declare class CheckoutAuthenticatedResource {
|
|
|
1424
1299
|
*/
|
|
1425
1300
|
declare class CheckoutResource {
|
|
1426
1301
|
private readonly http;
|
|
1427
|
-
/** Anonymous checkout — no
|
|
1302
|
+
/** Anonymous checkout — no customer identity, empty form. */
|
|
1428
1303
|
readonly anonymous: CheckoutAnonymousResource;
|
|
1429
|
-
/** Authenticated checkout — merchant provides
|
|
1304
|
+
/** Authenticated checkout — merchant provides customer identity. */
|
|
1430
1305
|
readonly authenticated: CheckoutAuthenticatedResource;
|
|
1431
1306
|
constructor(http: HttpClient);
|
|
1432
1307
|
/**
|
|
@@ -1451,6 +1326,144 @@ declare class CheckoutResource {
|
|
|
1451
1326
|
}>;
|
|
1452
1327
|
}
|
|
1453
1328
|
|
|
1329
|
+
/**
|
|
1330
|
+
* Internal HTTP client for customer-side requests using Bearer token authentication.
|
|
1331
|
+
*
|
|
1332
|
+
* Unlike {@link HttpClient} which signs requests with RSA-SHA256 (API Key auth),
|
|
1333
|
+
* this client attaches a session token as `Authorization: Bearer <token>` and
|
|
1334
|
+
* never sends an idempotency key (customer session actions are not protected by
|
|
1335
|
+
* gateway idempotency in the current architecture).
|
|
1336
|
+
*
|
|
1337
|
+
* Not exported publicly — used internally by {@link CustomerSession}.
|
|
1338
|
+
*/
|
|
1339
|
+
declare class CustomerHttpClient {
|
|
1340
|
+
private readonly token;
|
|
1341
|
+
private readonly baseUrl;
|
|
1342
|
+
private readonly _fetch;
|
|
1343
|
+
constructor(token: string, config: Pick<WaffoPancakeConfig, "baseUrl" | "fetch">);
|
|
1344
|
+
/**
|
|
1345
|
+
* Send a Bearer-authenticated POST and return the full envelope plus HTTP status.
|
|
1346
|
+
*
|
|
1347
|
+
* Does NOT throw on `errors[]` or non-2xx status — caller inspects the result.
|
|
1348
|
+
* Throws {@link WaffoPancakeError} only when the response body is not valid JSON.
|
|
1349
|
+
*/
|
|
1350
|
+
post<T>(path: string, body: object): Promise<PostResult<T>>;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
/**
|
|
1354
|
+
* Customer session — lets authenticated customers manage their own orders and subscriptions.
|
|
1355
|
+
*
|
|
1356
|
+
* Created via `client.customer(token)` using a session token issued by
|
|
1357
|
+
* `client.auth.issueSessionToken()`. All requests use Bearer token authentication.
|
|
1358
|
+
*
|
|
1359
|
+
* @example
|
|
1360
|
+
* const { token } = await client.auth.issueSessionToken({
|
|
1361
|
+
* storeId: "STO_xxx",
|
|
1362
|
+
* buyerIdentity: "customer@example.com",
|
|
1363
|
+
* });
|
|
1364
|
+
* const customer = client.customer(token);
|
|
1365
|
+
* await customer.cancelSubscription({ orderId: "ORD_xxx" });
|
|
1366
|
+
*/
|
|
1367
|
+
declare class CustomerSession {
|
|
1368
|
+
private readonly http;
|
|
1369
|
+
/** GraphQL query access scoped to the customer's data. */
|
|
1370
|
+
readonly graphql: CustomerGraphQL;
|
|
1371
|
+
constructor(http: CustomerHttpClient);
|
|
1372
|
+
/**
|
|
1373
|
+
* Cancel a subscription order.
|
|
1374
|
+
*
|
|
1375
|
+
* @param params - Order to cancel
|
|
1376
|
+
* @returns Order ID and resulting status
|
|
1377
|
+
*
|
|
1378
|
+
* @example
|
|
1379
|
+
* const { orderId, status } = await customer.cancelSubscription({ orderId: "ORD_xxx" });
|
|
1380
|
+
* // status: "canceled" (was pending) or "canceling" (was active)
|
|
1381
|
+
*/
|
|
1382
|
+
cancelSubscription(params: CancelSubscriptionParams): Promise<CancelSubscriptionResult & {
|
|
1383
|
+
warnings?: Notice[];
|
|
1384
|
+
}>;
|
|
1385
|
+
/**
|
|
1386
|
+
* Cancel a one-time order (only while payment is still pending).
|
|
1387
|
+
*
|
|
1388
|
+
* @param params - Order to cancel
|
|
1389
|
+
* @returns Order ID and resulting status
|
|
1390
|
+
*
|
|
1391
|
+
* @example
|
|
1392
|
+
* const { orderId, status } = await customer.cancelOnetimeOrder({ orderId: "ORD_xxx" });
|
|
1393
|
+
*/
|
|
1394
|
+
cancelOnetimeOrder(params: CancelOnetimeOrderParams): Promise<CancelOnetimeOrderResult & {
|
|
1395
|
+
warnings?: Notice[];
|
|
1396
|
+
}>;
|
|
1397
|
+
/**
|
|
1398
|
+
* Reactivate a subscription that is in `canceling` status.
|
|
1399
|
+
*
|
|
1400
|
+
* @param params - Order to reactivate
|
|
1401
|
+
* @returns Order ID and resulting status
|
|
1402
|
+
*
|
|
1403
|
+
* @example
|
|
1404
|
+
* const { orderId, status } = await customer.reactivateSubscription({ orderId: "ORD_xxx" });
|
|
1405
|
+
* // status: "active"
|
|
1406
|
+
*/
|
|
1407
|
+
reactivateSubscription(params: ReactivateSubscriptionParams): Promise<ReactivateSubscriptionResult & {
|
|
1408
|
+
warnings?: Notice[];
|
|
1409
|
+
}>;
|
|
1410
|
+
/**
|
|
1411
|
+
* Submit a refund request for a payment.
|
|
1412
|
+
*
|
|
1413
|
+
* @param params - Refund ticket details
|
|
1414
|
+
* @returns Created refund ticket
|
|
1415
|
+
*
|
|
1416
|
+
* @example
|
|
1417
|
+
* const { ticket } = await customer.createRefundTicket({
|
|
1418
|
+
* paymentId: "PAY_xxx",
|
|
1419
|
+
* reason: "Product not as described",
|
|
1420
|
+
* requestedAmount: { amount: "29.00", currency: "USD" },
|
|
1421
|
+
* refundTicketMerchantExternalId: "REF-2026-00891",
|
|
1422
|
+
* });
|
|
1423
|
+
*/
|
|
1424
|
+
createRefundTicket(params: CreateRefundTicketParams): Promise<{
|
|
1425
|
+
ticket: RefundTicket;
|
|
1426
|
+
warnings?: Notice[];
|
|
1427
|
+
}>;
|
|
1428
|
+
/**
|
|
1429
|
+
* Resubmit a previously rejected refund ticket with updated details.
|
|
1430
|
+
*
|
|
1431
|
+
* @param params - Updated ticket details
|
|
1432
|
+
* @returns Updated refund ticket
|
|
1433
|
+
*
|
|
1434
|
+
* @example
|
|
1435
|
+
* const { ticket } = await customer.resubmitRefundTicket({
|
|
1436
|
+
* ticketId: "TKT_xxx",
|
|
1437
|
+
* paymentId: "PAY_xxx",
|
|
1438
|
+
* reason: "Updated reason with more detail",
|
|
1439
|
+
* requestedAmount: { amount: "29.00", currency: "USD" },
|
|
1440
|
+
* });
|
|
1441
|
+
*/
|
|
1442
|
+
resubmitRefundTicket(params: ResubmitRefundTicketParams): Promise<{
|
|
1443
|
+
ticket: RefundTicket;
|
|
1444
|
+
warnings?: Notice[];
|
|
1445
|
+
}>;
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* GraphQL access scoped to the customer's session token.
|
|
1449
|
+
*/
|
|
1450
|
+
declare class CustomerGraphQL {
|
|
1451
|
+
private readonly http;
|
|
1452
|
+
constructor(http: CustomerHttpClient);
|
|
1453
|
+
/**
|
|
1454
|
+
* Execute a GraphQL query scoped to the customer's data.
|
|
1455
|
+
*
|
|
1456
|
+
* @param params - GraphQL query and variables
|
|
1457
|
+
* @returns GraphQL response
|
|
1458
|
+
*
|
|
1459
|
+
* @example
|
|
1460
|
+
* const result = await customer.graphql.query({
|
|
1461
|
+
* query: `query { orders { id status } }`,
|
|
1462
|
+
* });
|
|
1463
|
+
*/
|
|
1464
|
+
query<T = Record<string, unknown>>(params: GraphQLParams): Promise<GraphQLResponse<T>>;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1454
1467
|
/** GraphQL query resource (Query only, no Mutations). */
|
|
1455
1468
|
declare class GraphQLResource {
|
|
1456
1469
|
private readonly http;
|
|
@@ -2026,24 +2039,38 @@ declare class WaffoPancake {
|
|
|
2026
2039
|
readonly webhooks: WebhooksResource;
|
|
2027
2040
|
constructor(config: WaffoPancakeConfig);
|
|
2028
2041
|
/**
|
|
2029
|
-
* Create a
|
|
2042
|
+
* Create a customer session for self-service operations.
|
|
2030
2043
|
*
|
|
2031
2044
|
* The returned session uses Bearer token authentication and provides
|
|
2032
2045
|
* methods for order cancellation, subscription management, refund tickets,
|
|
2033
2046
|
* and scoped GraphQL queries.
|
|
2034
2047
|
*
|
|
2035
2048
|
* @param token - Session token from `client.auth.issueSessionToken()`
|
|
2036
|
-
* @returns A
|
|
2049
|
+
* @returns A customer session with self-service methods
|
|
2037
2050
|
*
|
|
2038
2051
|
* @example
|
|
2039
2052
|
* const { token } = await client.auth.issueSessionToken({
|
|
2040
2053
|
* storeId: "STO_xxx",
|
|
2041
2054
|
* buyerIdentity: "customer@example.com",
|
|
2042
2055
|
* });
|
|
2043
|
-
* const
|
|
2044
|
-
* await
|
|
2056
|
+
* const customer = client.customer(token);
|
|
2057
|
+
* await customer.cancelSubscription({ orderId: "ORD_xxx" });
|
|
2058
|
+
*/
|
|
2059
|
+
customer(token: string): CustomerSession;
|
|
2060
|
+
/**
|
|
2061
|
+
* Create a customer session for self-service operations.
|
|
2062
|
+
*
|
|
2063
|
+
* @param token - Session token from `client.auth.issueSessionToken()`
|
|
2064
|
+
* @returns A customer session with self-service methods
|
|
2065
|
+
*
|
|
2066
|
+
* @example
|
|
2067
|
+
* ```typescript
|
|
2068
|
+
* const session = client.buyer(token); // prefer client.customer(token)
|
|
2069
|
+
* ```
|
|
2070
|
+
*
|
|
2071
|
+
* @deprecated Use {@link WaffoPancake.customer} instead.
|
|
2045
2072
|
*/
|
|
2046
|
-
buyer(token: string):
|
|
2073
|
+
buyer(token: string): CustomerSession;
|
|
2047
2074
|
}
|
|
2048
2075
|
|
|
2049
2076
|
/**
|
|
@@ -2122,4 +2149,4 @@ declare class WaffoPancakeError extends Error {
|
|
|
2122
2149
|
*/
|
|
2123
2150
|
declare function verifyWebhook<T = Record<string, unknown>>(payload: string, signatureHeader: string | undefined | null, options?: VerifyWebhookOptions): WebhookEvent<T>;
|
|
2124
2151
|
|
|
2125
|
-
export { type AddMerchantParams, type AddMerchantResult, type AddWebhookParams, type AnonymousCheckoutParams, type ApiError, type AuthenticatedCheckoutParams, type AuthenticatedCheckoutResult, type BillingDetail, BillingPeriod, type CancelOnetimeOrderParams, type CancelOnetimeOrderResult, type CancelSubscriptionParams, type CancelSubscriptionResult, type CheckoutSessionResult, type CheckoutSettings, type CheckoutThemeSettings, type CreateCheckoutSessionParams, type CreateOnetimeProductParams, type CreateRefundTicketParams, type CreateStoreParams, type CreateSubscriptionProductGroupParams, type CreateSubscriptionProductParams, type DeleteStoreParams, type DeleteSubscriptionProductGroupParams, EntityStatus, type Envelope, Environment, ErrorLayer, type GraphQLParams, type GraphQLResponse, type GroupRules, type IssueSessionTokenParams, type MediaItem, MediaType, type MerchantWritableNotificationSettings, type Notice, type NotificationSettings, OnetimeOrderStatus, type OnetimeProductDetail, PaymentStatus, type PostResult, type PriceInfo, type Prices, ProductVersionStatus, type PublishOnetimeProductParams, type PublishSubscriptionProductGroupParams, type PublishSubscriptionProductParams, type ReactivateSubscriptionParams, type ReactivateSubscriptionResult, RefundStatus, type RefundTicket, RefundTicketStatus, type RefundTicketVersionData, type RemoveMerchantParams, type RemoveMerchantResult, type RemoveWebhookParams, type RequestedAmount, type ResubmitRefundTicketParams, type SessionToken, type Store, StoreRole, type StoreWebhook, SubscriptionOrderStatus, type SubscriptionProductDetail, type SubscriptionProductGroup, TaxCategory, type UpdateOnetimeProductParams, type UpdateOnetimeStatusParams, type UpdateRoleParams, type UpdateRoleResult, type UpdateStoreParams, type UpdateSubscriptionProductGroupParams, type UpdateSubscriptionProductParams, type UpdateSubscriptionStatusParams, type UpdateWebhookParams, type VerifyWebhookOptions, WaffoPancake, type WaffoPancakeConfig, WaffoPancakeError, type WebhookChannel, type WebhookEvent, type WebhookEventData, WebhookEventType, type WebhookPublicKeys, verifyWebhook };
|
|
2152
|
+
export { type AddMerchantParams, type AddMerchantResult, type AddWebhookParams, type AnonymousCheckoutParams, type ApiError, type AuthenticatedCheckoutParams, type AuthenticatedCheckoutResult, type BillingDetail, BillingPeriod, type CancelOnetimeOrderParams, type CancelOnetimeOrderResult, type CancelSubscriptionParams, type CancelSubscriptionResult, type CashierLanguage, type CheckoutSessionResult, type CheckoutSettings, type CheckoutThemeSettings, type CreateCheckoutSessionParams, type CreateOnetimeProductParams, type CreateRefundTicketParams, type CreateStoreParams, type CreateSubscriptionProductGroupParams, type CreateSubscriptionProductParams, type DeleteStoreParams, type DeleteSubscriptionProductGroupParams, EntityStatus, type Envelope, Environment, ErrorLayer, type GraphQLParams, type GraphQLResponse, type GroupRules, type IssueSessionTokenParams, type MediaItem, MediaType, type MerchantWritableNotificationSettings, type Notice, type NotificationSettings, OnetimeOrderStatus, type OnetimeProductDetail, PaymentStatus, type PostResult, type PriceInfo, type Prices, ProductVersionStatus, type PublishOnetimeProductParams, type PublishSubscriptionProductGroupParams, type PublishSubscriptionProductParams, type ReactivateSubscriptionParams, type ReactivateSubscriptionResult, RefundStatus, type RefundTicket, RefundTicketStatus, type RefundTicketVersionData, type RemoveMerchantParams, type RemoveMerchantResult, type RemoveWebhookParams, type RequestedAmount, type ResubmitRefundTicketParams, type SessionToken, type Store, StoreRole, type StoreWebhook, SubscriptionOrderStatus, type SubscriptionProductDetail, type SubscriptionProductGroup, TaxCategory, type UpdateOnetimeProductParams, type UpdateOnetimeStatusParams, type UpdateRoleParams, type UpdateRoleResult, type UpdateStoreParams, type UpdateSubscriptionProductGroupParams, type UpdateSubscriptionProductParams, type UpdateSubscriptionStatusParams, type UpdateWebhookParams, type VerifyWebhookOptions, WaffoPancake, type WaffoPancakeConfig, WaffoPancakeError, type WebhookChannel, type WebhookEvent, type WebhookEventData, WebhookEventType, type WebhookPublicKeys, verifyWebhook };
|