@waffo/pancake-ts 0.1.7 → 0.2.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/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  interface WaffoPancakeConfig {
2
- /** Merchant ID (X-Merchant-Id header) */
2
+ /** Merchant ID in `MER_{base62}` format (sent as X-Merchant-Id header) */
3
3
  merchantId: string;
4
4
  /** RSA private key in PEM format for request signing */
5
5
  privateKey: string;
6
- /** Base URL override (default: https://waffo-pancake-auth-service.vercel.app) */
6
+ /** Base URL override (default: https://api.waffo.ai) */
7
7
  baseUrl?: string;
8
8
  /** Custom fetch implementation (default: global fetch) */
9
9
  fetch?: typeof fetch;
@@ -115,10 +115,11 @@ declare enum OnetimeOrderStatus {
115
115
  * Subscription order status.
116
116
  *
117
117
  * State machine:
118
- * - pending -> active, canceled
118
+ * - pending -> active, canceled, closed (PSP CLOSE from never-activated)
119
119
  * - active -> canceling, past_due, canceled, expired
120
120
  * - canceling -> active, canceled
121
121
  * - past_due -> active, canceled
122
+ * - closed -> terminal (never-activated subscription closed by PSP)
122
123
  * - canceled -> terminal
123
124
  * - expired -> terminal
124
125
  *
@@ -128,8 +129,9 @@ declare enum SubscriptionOrderStatus {
128
129
  Pending = "pending",
129
130
  Active = "active",
130
131
  Canceling = "canceling",
131
- Canceled = "canceled",
132
132
  PastDue = "past_due",
133
+ Closed = "closed",
134
+ Canceled = "canceled",
133
135
  Expired = "expired"
134
136
  }
135
137
  /**
@@ -185,8 +187,10 @@ declare enum ErrorLayer {
185
187
  Store = "store",
186
188
  Product = "product",
187
189
  Order = "order",
190
+ Ticket = "ticket",
188
191
  GraphQL = "graphql",
189
192
  Resource = "resource",
193
+ /** SDK-specific layer for email delivery errors (not part of the service-side error layers). */
190
194
  Email = "email"
191
195
  }
192
196
  /**
@@ -289,11 +293,21 @@ interface CreateStoreParams {
289
293
  interface UpdateStoreParams {
290
294
  /** Store ID */
291
295
  id: string;
296
+ /** Store display name */
292
297
  name?: string;
298
+ /** Store status */
293
299
  status?: EntityStatus;
300
+ /** Store logo URL (set to `null` to remove) */
294
301
  logo?: string | null;
302
+ /** Support email address (set to `null` to remove) */
303
+ supportEmail?: string | null;
304
+ /** Store website URL (set to `null` to remove) */
305
+ website?: string | null;
306
+ /** Webhook configuration for test and production environments (set to `null` to remove) */
295
307
  webhookSettings?: WebhookSettings | null;
308
+ /** Notification preferences (set to `null` to remove) */
296
309
  notificationSettings?: NotificationSettings | null;
310
+ /** Checkout page theme configuration (set to `null` to remove) */
297
311
  checkoutSettings?: CheckoutSettings | null;
298
312
  }
299
313
  /** Parameters for deleting (soft-delete) a store. */
@@ -342,22 +356,22 @@ interface UpdateRoleResult {
342
356
  /**
343
357
  * Price for a single currency.
344
358
  *
345
- * Amounts are stored in the smallest currency unit (e.g. cents, yen)
346
- * to avoid floating-point precision issues.
359
+ * Amounts are represented as display strings (e.g., "9.99" for USD, "1000" for JPY).
360
+ * The server handles conversion to/from smallest currency units internally.
347
361
  *
348
362
  * @see waffo-pancake-product-service/app/lib/resources/types.ts
349
363
  *
350
364
  * @example
351
365
  * // USD $9.99
352
- * { amount: 999, taxCategory: "saas" }
366
+ * { amount: "9.99", taxCategory: "saas" }
353
367
  *
354
368
  * @example
355
369
  * // JPY ¥1000
356
370
  * { amount: 1000, taxCategory: "software" }
357
371
  */
358
372
  interface PriceInfo {
359
- /** Price amount in smallest currency unit */
360
- amount: number;
373
+ /** Price amount as display string (e.g., "9.99" for USD, "1000" for JPY) */
374
+ amount: string;
361
375
  /** Tax category */
362
376
  taxCategory: TaxCategory;
363
377
  }
@@ -368,7 +382,7 @@ interface PriceInfo {
368
382
  *
369
383
  * @example
370
384
  * {
371
- * "USD": { amount: 999, taxCategory: "saas" },
385
+ * "USD": { amount: "9.99", taxCategory: "saas" },
372
386
  * "EUR": { amount: 899, taxCategory: "saas" }
373
387
  * }
374
388
  */
@@ -628,6 +642,190 @@ interface CheckoutSessionResult {
628
642
  /** Session expiration time (ISO 8601 UTC) */
629
643
  expiresAt: string;
630
644
  }
645
+ /** Parameters for canceling a one-time order (buyer-side). */
646
+ interface CancelOnetimeOrderParams {
647
+ /** Order ID */
648
+ orderId: string;
649
+ }
650
+ /** Result of canceling a one-time order. */
651
+ interface CancelOnetimeOrderResult {
652
+ /** Order ID */
653
+ orderId: string;
654
+ /** Resulting status (`"canceled"`) */
655
+ status: string;
656
+ }
657
+ /** Parameters for reactivating a subscription (buyer-side). */
658
+ interface ReactivateSubscriptionParams {
659
+ /** Subscription order ID */
660
+ orderId: string;
661
+ }
662
+ /** Result of reactivating a subscription. */
663
+ interface ReactivateSubscriptionResult {
664
+ /** Order ID */
665
+ orderId: string;
666
+ /** Resulting status (`"active"`) */
667
+ status: string;
668
+ }
669
+ /** Requested refund amount. */
670
+ interface RequestedAmount {
671
+ /** Refund amount in display format (e.g., `"29.00"`) */
672
+ amount: string;
673
+ /** Currency code (ISO 4217) */
674
+ currency: string;
675
+ }
676
+ /** Parameters for creating a refund ticket (buyer-side). */
677
+ interface CreateRefundTicketParams {
678
+ /** Payment ID to refund */
679
+ paymentId: string;
680
+ /** Reason for the refund request */
681
+ reason: string;
682
+ /** Requested refund amount */
683
+ requestedAmount: RequestedAmount;
684
+ /** Custom metadata */
685
+ metadata?: Record<string, unknown>;
686
+ }
687
+ /** Parameters for resubmitting a rejected refund ticket (buyer-side). */
688
+ interface ResubmitRefundTicketParams {
689
+ /** Existing ticket ID */
690
+ ticketId: string;
691
+ /** Payment ID */
692
+ paymentId: string;
693
+ /** Updated reason */
694
+ reason: string;
695
+ /** Updated requested amount */
696
+ requestedAmount: RequestedAmount;
697
+ }
698
+ /** Refund ticket entity returned from create/resubmit operations. */
699
+ interface RefundTicket {
700
+ /** Ticket ID */
701
+ id: string;
702
+ /** Ticket type (e.g., `"refund"`) */
703
+ type: string;
704
+ /** Ticket status (e.g., `"pending"`, `"approved"`, `"rejected"`) */
705
+ status: string;
706
+ /** Associated payment ID */
707
+ subjectId: string;
708
+ /** Submitter identifier (email or merchant ID) */
709
+ submitterId: string;
710
+ /** Submitter type (e.g., `"customer"`, `"merchant"`) */
711
+ submitterType: string;
712
+ /** Current version ID */
713
+ currentVersionId: string;
714
+ /** Reviewer ID (null if not yet reviewed) */
715
+ reviewerId: string | null;
716
+ /** Review timestamp (ISO 8601, null if not yet reviewed) */
717
+ reviewedAt: string | null;
718
+ /** Reviewer's note */
719
+ reviewNote: string | null;
720
+ /** Rejection reason (null if approved or pending) */
721
+ rejectReason: string | null;
722
+ /** Execution timestamp (ISO 8601, null if not yet executed) */
723
+ executedAt: string | null;
724
+ /** Custom metadata */
725
+ metadata: Record<string, unknown>;
726
+ /** Current version number */
727
+ versionNumber: number;
728
+ /** Current version data (includes reason, amount, etc.) */
729
+ versionData: Record<string, unknown>;
730
+ }
731
+ /**
732
+ * Parameters for anonymous checkout.
733
+ *
734
+ * The buyer enters the checkout page without a session token and fills in
735
+ * billing details manually. No identity is provided upfront.
736
+ *
737
+ * @example
738
+ * const result = await client.checkout.anonymous.create({
739
+ * storeId: "STO_xxx",
740
+ * productId: "PROD_xxx",
741
+ * productType: "onetime",
742
+ * currency: "USD",
743
+ * });
744
+ * // Redirect to result.checkoutUrl
745
+ */
746
+ interface AnonymousCheckoutParams {
747
+ /** Store ID */
748
+ storeId: string;
749
+ /** Product ID */
750
+ productId: string;
751
+ /** Product type */
752
+ productType: `${CheckoutSessionProductType}`;
753
+ /** Currency code (ISO 4217) */
754
+ currency: string;
755
+ /** Optional price snapshot override (reads from DB if omitted) */
756
+ priceSnapshot?: PriceInfo;
757
+ /** Trial toggle override (subscription only) */
758
+ withTrial?: boolean;
759
+ /** Redirect URL after successful payment */
760
+ successUrl?: string;
761
+ /** Session expiration in seconds (default: 45 minutes) */
762
+ expiresInSeconds?: number;
763
+ /** Dark mode override (true=dark, false=light, omit=use store default) */
764
+ darkMode?: boolean;
765
+ /** Custom metadata */
766
+ metadata?: Record<string, string>;
767
+ }
768
+ /**
769
+ * Parameters for authenticated checkout.
770
+ *
771
+ * The merchant provides a buyer identity; the SDK issues a session token
772
+ * and appends it to the checkout URL as a URL fragment.
773
+ *
774
+ * @example
775
+ * const result = await client.checkout.authenticated.create({
776
+ * storeId: "STO_xxx",
777
+ * productId: "PROD_xxx",
778
+ * productType: "onetime",
779
+ * currency: "USD",
780
+ * buyerIdentity: "customer@example.com",
781
+ * });
782
+ * // Redirect to result.checkoutUrl (includes #token=...)
783
+ */
784
+ interface AuthenticatedCheckoutParams {
785
+ /** Store ID */
786
+ storeId: string;
787
+ /** Product ID */
788
+ productId: string;
789
+ /** Product type */
790
+ productType: `${CheckoutSessionProductType}`;
791
+ /** Currency code (ISO 4217) */
792
+ currency: string;
793
+ /** Buyer identity (email or merchant-provided identifier) */
794
+ buyerIdentity: string;
795
+ /** Pre-filled buyer email (defaults to `buyerIdentity` when omitted) */
796
+ buyerEmail?: string;
797
+ /** Pre-filled billing details */
798
+ billingDetail?: BillingDetail;
799
+ /** Optional price snapshot override (reads from DB if omitted) */
800
+ priceSnapshot?: PriceInfo;
801
+ /** Trial toggle override (subscription only) */
802
+ withTrial?: boolean;
803
+ /** Redirect URL after successful payment */
804
+ successUrl?: string;
805
+ /** Session expiration in seconds (default: 45 minutes) */
806
+ expiresInSeconds?: number;
807
+ /** Dark mode override (true=dark, false=light, omit=use store default) */
808
+ darkMode?: boolean;
809
+ /** Custom metadata */
810
+ metadata?: Record<string, string>;
811
+ }
812
+ /**
813
+ * Result of an authenticated checkout creation.
814
+ *
815
+ * Extends the base session result with the issued token details.
816
+ */
817
+ interface AuthenticatedCheckoutResult {
818
+ /** Session ID */
819
+ sessionId: string;
820
+ /** Checkout URL with session token appended as URL fragment (`#token=...`) */
821
+ checkoutUrl: string;
822
+ /** Session expiration time (ISO 8601 UTC) */
823
+ expiresAt: string;
824
+ /** Issued JWT token */
825
+ token: string;
826
+ /** Token expiration time (ISO 8601 UTC) */
827
+ tokenExpiresAt: string;
828
+ }
631
829
  /** Parameters for a GraphQL query. */
632
830
  interface GraphQLParams {
633
831
  /** GraphQL query string */
@@ -681,10 +879,10 @@ interface WebhookEventData {
681
879
  orderId: string;
682
880
  buyerEmail: string;
683
881
  currency: string;
684
- /** Amount in smallest currency unit */
685
- amount: number;
686
- /** Tax amount in smallest currency unit */
687
- taxAmount: number;
882
+ /** Amount as display string (e.g., "9.99" for USD, "1000" for JPY) */
883
+ amount: string;
884
+ /** Tax amount as display string (e.g., "0.91" for USD) */
885
+ taxAmount: string;
688
886
  productName: string;
689
887
  }
690
888
  /**
@@ -697,8 +895,8 @@ interface WebhookEventData {
697
895
  * id: "550e8400-...",
698
896
  * timestamp: "2026-03-10T08:30:00.000Z",
699
897
  * eventType: "order.completed",
700
- * eventId: "pay_660e8400-...",
701
- * storeId: "770e8400-...",
898
+ * eventId: "PAY_5xK9mRtYvWnPqLsJ3hBfDe",
899
+ * storeId: "STO_2aUyqjCzEIiEcYMKj7TZtw",
702
900
  * mode: "prod",
703
901
  * data: { orderId: "...", buyerEmail: "...", currency: "USD", amount: 2900, taxAmount: 290, productName: "Pro Plan" }
704
902
  * }
@@ -766,6 +964,9 @@ interface VerifyWebhookOptions {
766
964
  /**
767
965
  * Internal HTTP client that auto-signs requests and attaches idempotency keys.
768
966
  *
967
+ * The `X-Merchant-Id` header is sent in `MER_{base62}` format as provided by the user.
968
+ * The gateway decodes it to a raw UUID before forwarding to downstream services.
969
+ *
769
970
  * Not exported publicly — used by resource classes via {@link WaffoPancake}.
770
971
  */
771
972
  declare class HttpClient {
@@ -802,27 +1003,253 @@ declare class AuthResource {
802
1003
  *
803
1004
  * @example
804
1005
  * const { token, expiresAt } = await client.auth.issueSessionToken({
805
- * storeId: "store_xxx",
1006
+ * storeId: "STO_xxx",
806
1007
  * buyerIdentity: "customer@example.com",
807
1008
  * });
808
1009
  */
809
1010
  issueSessionToken(params: IssueSessionTokenParams): Promise<SessionToken>;
810
1011
  }
811
1012
 
812
- /** Checkout resource — create checkout sessions for payments. */
1013
+ /**
1014
+ * Internal HTTP client for buyer-side requests using Bearer token authentication.
1015
+ *
1016
+ * Unlike {@link HttpClient} which signs requests with RSA-SHA256 (API Key auth),
1017
+ * this client attaches a session token as `Authorization: Bearer <token>`.
1018
+ *
1019
+ * Not exported publicly — used internally by {@link BuyerSession}.
1020
+ */
1021
+ declare class BuyerHttpClient {
1022
+ private readonly token;
1023
+ private readonly baseUrl;
1024
+ private readonly _fetch;
1025
+ constructor(token: string, config: Pick<WaffoPancakeConfig, "baseUrl" | "fetch">);
1026
+ /**
1027
+ * Send a Bearer-authenticated POST request and return the parsed `data` field.
1028
+ *
1029
+ * @param path - API path
1030
+ * @param body - Request body object
1031
+ * @returns Parsed `data` field from the response
1032
+ * @throws {WaffoPancakeError} When the API returns errors
1033
+ */
1034
+ post<T>(path: string, body: object): Promise<T>;
1035
+ }
1036
+
1037
+ /**
1038
+ * Buyer session — lets authenticated buyers manage their own orders and subscriptions.
1039
+ *
1040
+ * Created via `client.buyer(token)` using a session token issued by
1041
+ * `client.auth.issueSessionToken()`. All requests use Bearer token authentication.
1042
+ *
1043
+ * @example
1044
+ * const { token } = await client.auth.issueSessionToken({
1045
+ * storeId: "STO_xxx",
1046
+ * buyerIdentity: "customer@example.com",
1047
+ * });
1048
+ * const buyer = client.buyer(token);
1049
+ * await buyer.cancelSubscription({ orderId: "ORD_xxx" });
1050
+ */
1051
+ declare class BuyerSession {
1052
+ private readonly http;
1053
+ /** GraphQL query access scoped to the buyer's data. */
1054
+ readonly graphql: BuyerGraphQL;
1055
+ constructor(http: BuyerHttpClient);
1056
+ /**
1057
+ * Cancel a subscription order.
1058
+ *
1059
+ * @param params - Order to cancel
1060
+ * @returns Order ID and resulting status
1061
+ *
1062
+ * @example
1063
+ * const { orderId, status } = await buyer.cancelSubscription({ orderId: "ORD_xxx" });
1064
+ * // status: "canceled" (was pending) or "canceling" (was active)
1065
+ */
1066
+ cancelSubscription(params: CancelSubscriptionParams): Promise<CancelSubscriptionResult>;
1067
+ /**
1068
+ * Cancel a one-time order (only while payment is still pending).
1069
+ *
1070
+ * @param params - Order to cancel
1071
+ * @returns Order ID and resulting status
1072
+ *
1073
+ * @example
1074
+ * const { orderId, status } = await buyer.cancelOnetimeOrder({ orderId: "ORD_xxx" });
1075
+ */
1076
+ cancelOnetimeOrder(params: CancelOnetimeOrderParams): Promise<CancelOnetimeOrderResult>;
1077
+ /**
1078
+ * Reactivate a subscription that is in `canceling` status.
1079
+ *
1080
+ * @param params - Order to reactivate
1081
+ * @returns Order ID and resulting status
1082
+ *
1083
+ * @example
1084
+ * const { orderId, status } = await buyer.reactivateSubscription({ orderId: "ORD_xxx" });
1085
+ * // status: "active"
1086
+ */
1087
+ reactivateSubscription(params: ReactivateSubscriptionParams): Promise<ReactivateSubscriptionResult>;
1088
+ /**
1089
+ * Submit a refund request for a payment.
1090
+ *
1091
+ * @param params - Refund ticket details
1092
+ * @returns Created refund ticket
1093
+ *
1094
+ * @example
1095
+ * const { ticket } = await buyer.createRefundTicket({
1096
+ * paymentId: "PAY_xxx",
1097
+ * reason: "Product not as described",
1098
+ * requestedAmount: { amount: "29.00", currency: "USD" },
1099
+ * });
1100
+ */
1101
+ createRefundTicket(params: CreateRefundTicketParams): Promise<{
1102
+ ticket: RefundTicket;
1103
+ }>;
1104
+ /**
1105
+ * Resubmit a previously rejected refund ticket with updated details.
1106
+ *
1107
+ * @param params - Updated ticket details
1108
+ * @returns Updated refund ticket
1109
+ *
1110
+ * @example
1111
+ * const { ticket } = await buyer.resubmitRefundTicket({
1112
+ * ticketId: "TKT_xxx",
1113
+ * paymentId: "PAY_xxx",
1114
+ * reason: "Updated reason with more detail",
1115
+ * requestedAmount: { amount: "29.00", currency: "USD" },
1116
+ * });
1117
+ */
1118
+ resubmitRefundTicket(params: ResubmitRefundTicketParams): Promise<{
1119
+ ticket: RefundTicket;
1120
+ }>;
1121
+ }
1122
+ /**
1123
+ * GraphQL access scoped to the buyer's session token.
1124
+ */
1125
+ declare class BuyerGraphQL {
1126
+ private readonly http;
1127
+ constructor(http: BuyerHttpClient);
1128
+ /**
1129
+ * Execute a GraphQL query scoped to the buyer's data.
1130
+ *
1131
+ * @param params - GraphQL query and variables
1132
+ * @returns GraphQL response
1133
+ *
1134
+ * @example
1135
+ * const result = await buyer.graphql.query({
1136
+ * query: `query { orders { id status } }`,
1137
+ * });
1138
+ */
1139
+ query<T = Record<string, unknown>>(params: GraphQLParams): Promise<GraphQLResponse<T>>;
1140
+ }
1141
+
1142
+ /**
1143
+ * Anonymous checkout — no buyer identity provided.
1144
+ *
1145
+ * The buyer fills in billing details manually on the checkout page.
1146
+ * Internally creates a checkout session and returns the redirect URL.
1147
+ */
1148
+ declare class CheckoutAnonymousResource {
1149
+ private readonly http;
1150
+ constructor(http: HttpClient);
1151
+ /**
1152
+ * Create an anonymous checkout session.
1153
+ *
1154
+ * @param params - Checkout parameters (no buyer identity required)
1155
+ * @returns Session ID, checkout URL, and expiration
1156
+ *
1157
+ * @example
1158
+ * const result = await client.checkout.anonymous.create({
1159
+ * storeId: "STO_xxx",
1160
+ * productId: "PROD_xxx",
1161
+ * productType: "onetime",
1162
+ * currency: "USD",
1163
+ * });
1164
+ * // Redirect to result.checkoutUrl
1165
+ */
1166
+ create(params: AnonymousCheckoutParams): Promise<CheckoutSessionResult>;
1167
+ }
1168
+
1169
+ /**
1170
+ * Authenticated checkout — merchant provides buyer identity.
1171
+ *
1172
+ * Issues a session token, creates a checkout session, and returns a
1173
+ * checkout URL with the token appended as a URL fragment (`#token=...`).
1174
+ * The checkout page reads the fragment to pre-fill buyer information.
1175
+ */
1176
+ declare class CheckoutAuthenticatedResource {
1177
+ private readonly http;
1178
+ constructor(http: HttpClient);
1179
+ /**
1180
+ * Create an authenticated checkout session.
1181
+ *
1182
+ * Behavior:
1183
+ * - Issues a session token via `issue-session-token`
1184
+ * - Creates a checkout session via `create-session`
1185
+ * - Appends the token to the checkout URL as a URL fragment
1186
+ * - Defaults `buyerEmail` to `buyerIdentity` when omitted
1187
+ *
1188
+ * @param params - Checkout parameters including buyer identity
1189
+ * @returns Session details with token-appended checkout URL
1190
+ *
1191
+ * @example
1192
+ * const result = await client.checkout.authenticated.create({
1193
+ * storeId: "STO_xxx",
1194
+ * productId: "PROD_xxx",
1195
+ * productType: "onetime",
1196
+ * currency: "USD",
1197
+ * buyerIdentity: "customer@example.com",
1198
+ * });
1199
+ * // Redirect to result.checkoutUrl (includes #token=...)
1200
+ */
1201
+ create(params: AuthenticatedCheckoutParams): Promise<AuthenticatedCheckoutResult>;
1202
+ }
1203
+
1204
+ /**
1205
+ * Checkout resource — create checkout sessions for payments.
1206
+ *
1207
+ * Provides two convenience sub-resources for the common checkout flows:
1208
+ * - `anonymous` — no buyer identity, empty form
1209
+ * - `authenticated` — merchant provides buyer identity, pre-filled form + token
1210
+ *
1211
+ * The low-level `createSession()` method is still available for full control.
1212
+ *
1213
+ * @example
1214
+ * // Anonymous checkout (no identity)
1215
+ * const result = await client.checkout.anonymous.create({
1216
+ * storeId: "STO_xxx",
1217
+ * productId: "PROD_xxx",
1218
+ * productType: "onetime",
1219
+ * currency: "USD",
1220
+ * });
1221
+ *
1222
+ * @example
1223
+ * // Authenticated checkout (with buyer identity)
1224
+ * const result = await client.checkout.authenticated.create({
1225
+ * storeId: "STO_xxx",
1226
+ * productId: "PROD_xxx",
1227
+ * productType: "onetime",
1228
+ * currency: "USD",
1229
+ * buyerIdentity: "customer@example.com",
1230
+ * });
1231
+ * // result.checkoutUrl includes #token=...
1232
+ */
813
1233
  declare class CheckoutResource {
814
1234
  private readonly http;
1235
+ /** Anonymous checkout — no buyer identity, empty form. */
1236
+ readonly anonymous: CheckoutAnonymousResource;
1237
+ /** Authenticated checkout — merchant provides buyer identity. */
1238
+ readonly authenticated: CheckoutAuthenticatedResource;
815
1239
  constructor(http: HttpClient);
816
1240
  /**
817
- * Create a checkout session. Returns a URL to redirect the customer to.
1241
+ * Create a checkout session (low-level). Returns a URL to redirect the customer to.
1242
+ *
1243
+ * For most use cases, prefer `checkout.anonymous.create()` or
1244
+ * `checkout.authenticated.create()` which handle the full flow automatically.
818
1245
  *
819
1246
  * @param params - Checkout session parameters
820
1247
  * @returns Session ID, checkout URL, and expiration
821
1248
  *
822
1249
  * @example
823
1250
  * const session = await client.checkout.createSession({
824
- * storeId: "store_xxx",
825
- * productId: "prod_xxx",
1251
+ * storeId: "STO_xxx",
1252
+ * productId: "PROD_xxx",
826
1253
  * productType: "onetime",
827
1254
  * currency: "USD",
828
1255
  * buyerEmail: "customer@example.com",
@@ -851,7 +1278,7 @@ declare class GraphQLResource {
851
1278
  * @example
852
1279
  * const result = await client.graphql.query({
853
1280
  * query: `query ($id: ID!) { onetimeProduct(id: $id) { id name prices } }`,
854
- * variables: { id: "prod_xxx" },
1281
+ * variables: { id: "PROD_xxx" },
855
1282
  * });
856
1283
  */
857
1284
  query<T = Record<string, unknown>>(params: GraphQLParams): Promise<GraphQLResponse<T>>;
@@ -869,9 +1296,9 @@ declare class OnetimeProductsResource {
869
1296
  *
870
1297
  * @example
871
1298
  * const { product } = await client.onetimeProducts.create({
872
- * storeId: "store_xxx",
1299
+ * storeId: "STO_xxx",
873
1300
  * name: "E-Book",
874
- * prices: { USD: { amount: 2900, taxCategory: "digital_goods" } },
1301
+ * prices: { USD: { amount: "29.00", taxCategory: "digital_goods" } },
875
1302
  * });
876
1303
  */
877
1304
  create(params: CreateOnetimeProductParams): Promise<{
@@ -885,9 +1312,9 @@ declare class OnetimeProductsResource {
885
1312
  *
886
1313
  * @example
887
1314
  * const { product } = await client.onetimeProducts.update({
888
- * id: "prod_xxx",
1315
+ * id: "PROD_xxx",
889
1316
  * name: "E-Book v2",
890
- * prices: { USD: { amount: 3900, taxCategory: "digital_goods" } },
1317
+ * prices: { USD: { amount: "39.00", taxCategory: "digital_goods" } },
891
1318
  * });
892
1319
  */
893
1320
  update(params: UpdateOnetimeProductParams): Promise<{
@@ -900,7 +1327,7 @@ declare class OnetimeProductsResource {
900
1327
  * @returns Published product detail
901
1328
  *
902
1329
  * @example
903
- * const { product } = await client.onetimeProducts.publish({ id: "prod_xxx" });
1330
+ * const { product } = await client.onetimeProducts.publish({ id: "PROD_xxx" });
904
1331
  */
905
1332
  publish(params: PublishOnetimeProductParams): Promise<{
906
1333
  product: OnetimeProductDetail;
@@ -913,7 +1340,7 @@ declare class OnetimeProductsResource {
913
1340
  *
914
1341
  * @example
915
1342
  * const { product } = await client.onetimeProducts.updateStatus({
916
- * id: "prod_xxx",
1343
+ * id: "PROD_xxx",
917
1344
  * status: ProductVersionStatus.Inactive,
918
1345
  * });
919
1346
  */
@@ -937,7 +1364,7 @@ declare class OrdersResource {
937
1364
  *
938
1365
  * @example
939
1366
  * const { orderId, status } = await client.orders.cancelSubscription({
940
- * orderId: "order_xxx",
1367
+ * orderId: "ORD_xxx",
941
1368
  * });
942
1369
  * // status: "canceled" or "canceling"
943
1370
  */
@@ -956,7 +1383,7 @@ declare class StoreMerchantsResource {
956
1383
  *
957
1384
  * @example
958
1385
  * const result = await client.storeMerchants.add({
959
- * storeId: "store_xxx",
1386
+ * storeId: "STO_xxx",
960
1387
  * email: "member@example.com",
961
1388
  * role: "admin",
962
1389
  * });
@@ -970,8 +1397,8 @@ declare class StoreMerchantsResource {
970
1397
  *
971
1398
  * @example
972
1399
  * const result = await client.storeMerchants.remove({
973
- * storeId: "store_xxx",
974
- * merchantId: "merchant_xxx",
1400
+ * storeId: "STO_xxx",
1401
+ * merchantId: "MER_xxx",
975
1402
  * });
976
1403
  */
977
1404
  remove(params: RemoveMerchantParams): Promise<RemoveMerchantResult>;
@@ -983,8 +1410,8 @@ declare class StoreMerchantsResource {
983
1410
  *
984
1411
  * @example
985
1412
  * const result = await client.storeMerchants.updateRole({
986
- * storeId: "store_xxx",
987
- * merchantId: "merchant_xxx",
1413
+ * storeId: "STO_xxx",
1414
+ * merchantId: "MER_xxx",
988
1415
  * role: "member",
989
1416
  * });
990
1417
  */
@@ -1015,7 +1442,7 @@ declare class StoresResource {
1015
1442
  *
1016
1443
  * @example
1017
1444
  * const { store } = await client.stores.update({
1018
- * id: "store_xxx",
1445
+ * id: "STO_xxx",
1019
1446
  * name: "Updated Name",
1020
1447
  * });
1021
1448
  */
@@ -1029,7 +1456,7 @@ declare class StoresResource {
1029
1456
  * @returns Deleted store entity (with `deletedAt` set)
1030
1457
  *
1031
1458
  * @example
1032
- * const { store } = await client.stores.delete({ id: "store_xxx" });
1459
+ * const { store } = await client.stores.delete({ id: "STO_xxx" });
1033
1460
  */
1034
1461
  delete(params: DeleteStoreParams): Promise<{
1035
1462
  store: Store;
@@ -1048,10 +1475,10 @@ declare class SubscriptionProductGroupsResource {
1048
1475
  *
1049
1476
  * @example
1050
1477
  * const { group } = await client.subscriptionProductGroups.create({
1051
- * storeId: "store_xxx",
1478
+ * storeId: "STO_xxx",
1052
1479
  * name: "Pro Plans",
1053
1480
  * rules: { sharedTrial: true },
1054
- * productIds: ["prod_aaa", "prod_bbb"],
1481
+ * productIds: ["PROD_aaa", "PROD_bbb"],
1055
1482
  * });
1056
1483
  */
1057
1484
  create(params: CreateSubscriptionProductGroupParams): Promise<{
@@ -1065,8 +1492,8 @@ declare class SubscriptionProductGroupsResource {
1065
1492
  *
1066
1493
  * @example
1067
1494
  * const { group } = await client.subscriptionProductGroups.update({
1068
- * id: "group_xxx",
1069
- * productIds: ["prod_aaa", "prod_bbb", "prod_ccc"],
1495
+ * id: "GRP_xxx",
1496
+ * productIds: ["PROD_aaa", "PROD_bbb", "PROD_ccc"],
1070
1497
  * });
1071
1498
  */
1072
1499
  update(params: UpdateSubscriptionProductGroupParams): Promise<{
@@ -1079,7 +1506,7 @@ declare class SubscriptionProductGroupsResource {
1079
1506
  * @returns Deleted group entity
1080
1507
  *
1081
1508
  * @example
1082
- * const { group } = await client.subscriptionProductGroups.delete({ id: "group_xxx" });
1509
+ * const { group } = await client.subscriptionProductGroups.delete({ id: "GRP_xxx" });
1083
1510
  */
1084
1511
  delete(params: DeleteSubscriptionProductGroupParams): Promise<{
1085
1512
  group: SubscriptionProductGroup;
@@ -1091,7 +1518,7 @@ declare class SubscriptionProductGroupsResource {
1091
1518
  * @returns Published group entity
1092
1519
  *
1093
1520
  * @example
1094
- * const { group } = await client.subscriptionProductGroups.publish({ id: "group_xxx" });
1521
+ * const { group } = await client.subscriptionProductGroups.publish({ id: "GRP_xxx" });
1095
1522
  */
1096
1523
  publish(params: PublishSubscriptionProductGroupParams): Promise<{
1097
1524
  group: SubscriptionProductGroup;
@@ -1110,10 +1537,10 @@ declare class SubscriptionProductsResource {
1110
1537
  *
1111
1538
  * @example
1112
1539
  * const { product } = await client.subscriptionProducts.create({
1113
- * storeId: "store_xxx",
1540
+ * storeId: "STO_xxx",
1114
1541
  * name: "Pro Plan",
1115
1542
  * billingPeriod: "monthly",
1116
- * prices: { USD: { amount: 999, taxCategory: "saas" } },
1543
+ * prices: { USD: { amount: "9.99", taxCategory: "saas" } },
1117
1544
  * });
1118
1545
  */
1119
1546
  create(params: CreateSubscriptionProductParams): Promise<{
@@ -1127,10 +1554,10 @@ declare class SubscriptionProductsResource {
1127
1554
  *
1128
1555
  * @example
1129
1556
  * const { product } = await client.subscriptionProducts.update({
1130
- * id: "prod_xxx",
1557
+ * id: "PROD_xxx",
1131
1558
  * name: "Pro Plan v2",
1132
1559
  * billingPeriod: "monthly",
1133
- * prices: { USD: { amount: 1499, taxCategory: "saas" } },
1560
+ * prices: { USD: { amount: "14.99", taxCategory: "saas" } },
1134
1561
  * });
1135
1562
  */
1136
1563
  update(params: UpdateSubscriptionProductParams): Promise<{
@@ -1143,7 +1570,7 @@ declare class SubscriptionProductsResource {
1143
1570
  * @returns Published product detail
1144
1571
  *
1145
1572
  * @example
1146
- * const { product } = await client.subscriptionProducts.publish({ id: "prod_xxx" });
1573
+ * const { product } = await client.subscriptionProducts.publish({ id: "PROD_xxx" });
1147
1574
  */
1148
1575
  publish(params: PublishSubscriptionProductParams): Promise<{
1149
1576
  product: SubscriptionProductDetail;
@@ -1156,7 +1583,7 @@ declare class SubscriptionProductsResource {
1156
1583
  *
1157
1584
  * @example
1158
1585
  * const { product } = await client.subscriptionProducts.updateStatus({
1159
- * id: "prod_xxx",
1586
+ * id: "PROD_xxx",
1160
1587
  * status: ProductVersionStatus.Active,
1161
1588
  * });
1162
1589
  */
@@ -1215,19 +1642,21 @@ declare class WebhooksResource {
1215
1642
  * import { WaffoPancake } from "@waffo/pancake-ts";
1216
1643
  *
1217
1644
  * const client = new WaffoPancake({
1218
- * merchantId: process.env.WAFFO_MERCHANT_ID!,
1645
+ * merchantId: "MER_2D5F8G3H1K4M6N9P0Q7R8S", // MER_{base62} format
1219
1646
  * privateKey: process.env.WAFFO_PRIVATE_KEY!,
1220
1647
  * });
1221
1648
  *
1222
- * // Create a store
1649
+ * // Create a store — IDs are returned in {prefix}_{base62} format
1223
1650
  * const { store } = await client.stores.create({ name: "My Store" });
1651
+ * // => store.id = "STO_..."
1224
1652
  *
1225
1653
  * // Create a product
1226
1654
  * const { product } = await client.onetimeProducts.create({
1227
- * storeId: store.id,
1655
+ * storeId: store.id, // "STO_..."
1228
1656
  * name: "E-Book",
1229
- * prices: { USD: { amount: 2900, taxCategory: "digital_goods" } },
1657
+ * prices: { USD: { amount: "29.00", taxCategory: "digital_goods" } },
1230
1658
  * });
1659
+ * // => product.id = "PROD_..."
1231
1660
  *
1232
1661
  * // Create a checkout session
1233
1662
  * const session = await client.checkout.createSession({
@@ -1257,6 +1686,7 @@ declare class WebhooksResource {
1257
1686
  */
1258
1687
  declare class WaffoPancake {
1259
1688
  private readonly http;
1689
+ private readonly config;
1260
1690
  readonly auth: AuthResource;
1261
1691
  readonly stores: StoresResource;
1262
1692
  readonly storeMerchants: StoreMerchantsResource;
@@ -1268,6 +1698,25 @@ declare class WaffoPancake {
1268
1698
  readonly graphql: GraphQLResource;
1269
1699
  readonly webhooks: WebhooksResource;
1270
1700
  constructor(config: WaffoPancakeConfig);
1701
+ /**
1702
+ * Create a buyer session for self-service operations.
1703
+ *
1704
+ * The returned session uses Bearer token authentication and provides
1705
+ * methods for order cancellation, subscription management, refund tickets,
1706
+ * and scoped GraphQL queries.
1707
+ *
1708
+ * @param token - Session token from `client.auth.issueSessionToken()`
1709
+ * @returns A buyer session with self-service methods
1710
+ *
1711
+ * @example
1712
+ * const { token } = await client.auth.issueSessionToken({
1713
+ * storeId: "STO_xxx",
1714
+ * buyerIdentity: "customer@example.com",
1715
+ * });
1716
+ * const buyer = client.buyer(token);
1717
+ * await buyer.cancelSubscription({ orderId: "ORD_xxx" });
1718
+ */
1719
+ buyer(token: string): BuyerSession;
1271
1720
  }
1272
1721
 
1273
1722
  /**
@@ -1346,4 +1795,4 @@ declare class WaffoPancakeError extends Error {
1346
1795
  */
1347
1796
  declare function verifyWebhook<T = Record<string, unknown>>(payload: string, signatureHeader: string | undefined | null, options?: VerifyWebhookOptions): WebhookEvent<T>;
1348
1797
 
1349
- export { type AddMerchantParams, type AddMerchantResult, type ApiError, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type BillingDetail, BillingPeriod, type CancelSubscriptionParams, type CancelSubscriptionResult, CheckoutSessionProductType, type CheckoutSessionResult, type CheckoutSettings, type CheckoutThemeSettings, type CreateCheckoutSessionParams, type CreateOnetimeProductParams, type CreateStoreParams, type CreateSubscriptionProductGroupParams, type CreateSubscriptionProductParams, type DeleteStoreParams, type DeleteSubscriptionProductGroupParams, EntityStatus, Environment, ErrorLayer, type GraphQLParams, type GraphQLResponse, type GroupRules, type IssueSessionTokenParams, type MediaItem, MediaType, type NotificationSettings, OnetimeOrderStatus, type OnetimeProductDetail, PaymentStatus, type PriceInfo, type Prices, ProductVersionStatus, type PublishOnetimeProductParams, type PublishSubscriptionProductGroupParams, type PublishSubscriptionProductParams, RefundStatus, RefundTicketStatus, type RemoveMerchantParams, type RemoveMerchantResult, type SessionToken, type Store, StoreRole, SubscriptionOrderStatus, type SubscriptionProductDetail, type SubscriptionProductGroup, TaxCategory, type UpdateOnetimeProductParams, type UpdateOnetimeStatusParams, type UpdateRoleParams, type UpdateRoleResult, type UpdateStoreParams, type UpdateSubscriptionProductGroupParams, type UpdateSubscriptionProductParams, type UpdateSubscriptionStatusParams, type VerifyWebhookOptions, WaffoPancake, type WaffoPancakeConfig, WaffoPancakeError, type WebhookEvent, type WebhookEventData, WebhookEventType, type WebhookPublicKeys, type WebhookSettings, verifyWebhook };
1798
+ export { type AddMerchantParams, type AddMerchantResult, type AnonymousCheckoutParams, type ApiError, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AuthenticatedCheckoutParams, type AuthenticatedCheckoutResult, type BillingDetail, BillingPeriod, type CancelOnetimeOrderParams, type CancelOnetimeOrderResult, type CancelSubscriptionParams, type CancelSubscriptionResult, CheckoutSessionProductType, type CheckoutSessionResult, type CheckoutSettings, type CheckoutThemeSettings, type CreateCheckoutSessionParams, type CreateOnetimeProductParams, type CreateRefundTicketParams, type CreateStoreParams, type CreateSubscriptionProductGroupParams, type CreateSubscriptionProductParams, type DeleteStoreParams, type DeleteSubscriptionProductGroupParams, EntityStatus, Environment, ErrorLayer, type GraphQLParams, type GraphQLResponse, type GroupRules, type IssueSessionTokenParams, type MediaItem, MediaType, type NotificationSettings, OnetimeOrderStatus, type OnetimeProductDetail, PaymentStatus, type PriceInfo, type Prices, ProductVersionStatus, type PublishOnetimeProductParams, type PublishSubscriptionProductGroupParams, type PublishSubscriptionProductParams, type ReactivateSubscriptionParams, type ReactivateSubscriptionResult, RefundStatus, type RefundTicket, RefundTicketStatus, type RemoveMerchantParams, type RemoveMerchantResult, type RequestedAmount, type ResubmitRefundTicketParams, type SessionToken, type Store, StoreRole, SubscriptionOrderStatus, type SubscriptionProductDetail, type SubscriptionProductGroup, TaxCategory, type UpdateOnetimeProductParams, type UpdateOnetimeStatusParams, type UpdateRoleParams, type UpdateRoleResult, type UpdateStoreParams, type UpdateSubscriptionProductGroupParams, type UpdateSubscriptionProductParams, type UpdateSubscriptionStatusParams, type VerifyWebhookOptions, WaffoPancake, type WaffoPancakeConfig, WaffoPancakeError, type WebhookEvent, type WebhookEventData, WebhookEventType, type WebhookPublicKeys, type WebhookSettings, verifyWebhook };