@waffo/pancake-ts 0.1.9 → 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
@@ -642,8 +642,94 @@ interface CheckoutSessionResult {
642
642
  /** Session expiration time (ISO 8601 UTC) */
643
643
  expiresAt: string;
644
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
+ }
645
731
  /**
646
- * Parameters for anonymous checkout (visitor → shopper).
732
+ * Parameters for anonymous checkout.
647
733
  *
648
734
  * The buyer enters the checkout page without a session token and fills in
649
735
  * billing details manually. No identity is provided upfront.
@@ -680,7 +766,7 @@ interface AnonymousCheckoutParams {
680
766
  metadata?: Record<string, string>;
681
767
  }
682
768
  /**
683
- * Parameters for authenticated checkout (customer).
769
+ * Parameters for authenticated checkout.
684
770
  *
685
771
  * The merchant provides a buyer identity; the SDK issues a session token
686
772
  * and appends it to the checkout URL as a URL fragment.
@@ -925,7 +1011,136 @@ declare class AuthResource {
925
1011
  }
926
1012
 
927
1013
  /**
928
- * Anonymous checkout visitor enters without a session token.
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.
929
1144
  *
930
1145
  * The buyer fills in billing details manually on the checkout page.
931
1146
  * Internally creates a checkout session and returns the redirect URL.
@@ -990,13 +1205,13 @@ declare class CheckoutAuthenticatedResource {
990
1205
  * Checkout resource — create checkout sessions for payments.
991
1206
  *
992
1207
  * Provides two convenience sub-resources for the common checkout flows:
993
- * - `anonymous` — visitor enters without identity (empty form)
994
- * - `authenticated` — merchant provides buyer identity (pre-filled form + token)
1208
+ * - `anonymous` — no buyer identity, empty form
1209
+ * - `authenticated` — merchant provides buyer identity, pre-filled form + token
995
1210
  *
996
1211
  * The low-level `createSession()` method is still available for full control.
997
1212
  *
998
1213
  * @example
999
- * // Anonymous checkout (visitor → shopper)
1214
+ * // Anonymous checkout (no identity)
1000
1215
  * const result = await client.checkout.anonymous.create({
1001
1216
  * storeId: "STO_xxx",
1002
1217
  * productId: "PROD_xxx",
@@ -1005,7 +1220,7 @@ declare class CheckoutAuthenticatedResource {
1005
1220
  * });
1006
1221
  *
1007
1222
  * @example
1008
- * // Authenticated checkout (customer)
1223
+ * // Authenticated checkout (with buyer identity)
1009
1224
  * const result = await client.checkout.authenticated.create({
1010
1225
  * storeId: "STO_xxx",
1011
1226
  * productId: "PROD_xxx",
@@ -1017,7 +1232,7 @@ declare class CheckoutAuthenticatedResource {
1017
1232
  */
1018
1233
  declare class CheckoutResource {
1019
1234
  private readonly http;
1020
- /** Anonymous checkout — visitor enters without a session token. */
1235
+ /** Anonymous checkout — no buyer identity, empty form. */
1021
1236
  readonly anonymous: CheckoutAnonymousResource;
1022
1237
  /** Authenticated checkout — merchant provides buyer identity. */
1023
1238
  readonly authenticated: CheckoutAuthenticatedResource;
@@ -1439,7 +1654,7 @@ declare class WebhooksResource {
1439
1654
  * const { product } = await client.onetimeProducts.create({
1440
1655
  * storeId: store.id, // "STO_..."
1441
1656
  * name: "E-Book",
1442
- * prices: { USD: { amount: 2900, taxCategory: "digital_goods" } },
1657
+ * prices: { USD: { amount: "29.00", taxCategory: "digital_goods" } },
1443
1658
  * });
1444
1659
  * // => product.id = "PROD_..."
1445
1660
  *
@@ -1471,6 +1686,7 @@ declare class WebhooksResource {
1471
1686
  */
1472
1687
  declare class WaffoPancake {
1473
1688
  private readonly http;
1689
+ private readonly config;
1474
1690
  readonly auth: AuthResource;
1475
1691
  readonly stores: StoresResource;
1476
1692
  readonly storeMerchants: StoreMerchantsResource;
@@ -1482,6 +1698,25 @@ declare class WaffoPancake {
1482
1698
  readonly graphql: GraphQLResource;
1483
1699
  readonly webhooks: WebhooksResource;
1484
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;
1485
1720
  }
1486
1721
 
1487
1722
  /**
@@ -1560,4 +1795,4 @@ declare class WaffoPancakeError extends Error {
1560
1795
  */
1561
1796
  declare function verifyWebhook<T = Record<string, unknown>>(payload: string, signatureHeader: string | undefined | null, options?: VerifyWebhookOptions): WebhookEvent<T>;
1562
1797
 
1563
- export { type AddMerchantParams, type AddMerchantResult, type AnonymousCheckoutParams, type ApiError, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AuthenticatedCheckoutParams, type AuthenticatedCheckoutResult, 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 };
package/dist/index.d.ts CHANGED
@@ -642,8 +642,94 @@ interface CheckoutSessionResult {
642
642
  /** Session expiration time (ISO 8601 UTC) */
643
643
  expiresAt: string;
644
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
+ }
645
731
  /**
646
- * Parameters for anonymous checkout (visitor → shopper).
732
+ * Parameters for anonymous checkout.
647
733
  *
648
734
  * The buyer enters the checkout page without a session token and fills in
649
735
  * billing details manually. No identity is provided upfront.
@@ -680,7 +766,7 @@ interface AnonymousCheckoutParams {
680
766
  metadata?: Record<string, string>;
681
767
  }
682
768
  /**
683
- * Parameters for authenticated checkout (customer).
769
+ * Parameters for authenticated checkout.
684
770
  *
685
771
  * The merchant provides a buyer identity; the SDK issues a session token
686
772
  * and appends it to the checkout URL as a URL fragment.
@@ -925,7 +1011,136 @@ declare class AuthResource {
925
1011
  }
926
1012
 
927
1013
  /**
928
- * Anonymous checkout visitor enters without a session token.
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.
929
1144
  *
930
1145
  * The buyer fills in billing details manually on the checkout page.
931
1146
  * Internally creates a checkout session and returns the redirect URL.
@@ -990,13 +1205,13 @@ declare class CheckoutAuthenticatedResource {
990
1205
  * Checkout resource — create checkout sessions for payments.
991
1206
  *
992
1207
  * Provides two convenience sub-resources for the common checkout flows:
993
- * - `anonymous` — visitor enters without identity (empty form)
994
- * - `authenticated` — merchant provides buyer identity (pre-filled form + token)
1208
+ * - `anonymous` — no buyer identity, empty form
1209
+ * - `authenticated` — merchant provides buyer identity, pre-filled form + token
995
1210
  *
996
1211
  * The low-level `createSession()` method is still available for full control.
997
1212
  *
998
1213
  * @example
999
- * // Anonymous checkout (visitor → shopper)
1214
+ * // Anonymous checkout (no identity)
1000
1215
  * const result = await client.checkout.anonymous.create({
1001
1216
  * storeId: "STO_xxx",
1002
1217
  * productId: "PROD_xxx",
@@ -1005,7 +1220,7 @@ declare class CheckoutAuthenticatedResource {
1005
1220
  * });
1006
1221
  *
1007
1222
  * @example
1008
- * // Authenticated checkout (customer)
1223
+ * // Authenticated checkout (with buyer identity)
1009
1224
  * const result = await client.checkout.authenticated.create({
1010
1225
  * storeId: "STO_xxx",
1011
1226
  * productId: "PROD_xxx",
@@ -1017,7 +1232,7 @@ declare class CheckoutAuthenticatedResource {
1017
1232
  */
1018
1233
  declare class CheckoutResource {
1019
1234
  private readonly http;
1020
- /** Anonymous checkout — visitor enters without a session token. */
1235
+ /** Anonymous checkout — no buyer identity, empty form. */
1021
1236
  readonly anonymous: CheckoutAnonymousResource;
1022
1237
  /** Authenticated checkout — merchant provides buyer identity. */
1023
1238
  readonly authenticated: CheckoutAuthenticatedResource;
@@ -1439,7 +1654,7 @@ declare class WebhooksResource {
1439
1654
  * const { product } = await client.onetimeProducts.create({
1440
1655
  * storeId: store.id, // "STO_..."
1441
1656
  * name: "E-Book",
1442
- * prices: { USD: { amount: 2900, taxCategory: "digital_goods" } },
1657
+ * prices: { USD: { amount: "29.00", taxCategory: "digital_goods" } },
1443
1658
  * });
1444
1659
  * // => product.id = "PROD_..."
1445
1660
  *
@@ -1471,6 +1686,7 @@ declare class WebhooksResource {
1471
1686
  */
1472
1687
  declare class WaffoPancake {
1473
1688
  private readonly http;
1689
+ private readonly config;
1474
1690
  readonly auth: AuthResource;
1475
1691
  readonly stores: StoresResource;
1476
1692
  readonly storeMerchants: StoreMerchantsResource;
@@ -1482,6 +1698,25 @@ declare class WaffoPancake {
1482
1698
  readonly graphql: GraphQLResource;
1483
1699
  readonly webhooks: WebhooksResource;
1484
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;
1485
1720
  }
1486
1721
 
1487
1722
  /**
@@ -1560,4 +1795,4 @@ declare class WaffoPancakeError extends Error {
1560
1795
  */
1561
1796
  declare function verifyWebhook<T = Record<string, unknown>>(payload: string, signatureHeader: string | undefined | null, options?: VerifyWebhookOptions): WebhookEvent<T>;
1562
1797
 
1563
- export { type AddMerchantParams, type AddMerchantResult, type AnonymousCheckoutParams, type ApiError, type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type AuthenticatedCheckoutParams, type AuthenticatedCheckoutResult, 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 };