@waffo/pancake-ts 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -5
- package/README.md +98 -12
- package/dist/index.cjs +343 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +259 -15
- package/dist/index.d.ts +259 -15
- package/dist/index.js +343 -6
- package/dist/index.js.map +1 -1
- package/docs/api-reference.md +92 -1
- package/package.json +1 -1
package/docs/api-reference.md
CHANGED
|
@@ -505,6 +505,88 @@ const { orderId, status } = await client.orders.cancelSubscription({
|
|
|
505
505
|
|
|
506
506
|
---
|
|
507
507
|
|
|
508
|
+
## Buyer Self-Service
|
|
509
|
+
|
|
510
|
+
Issue a session token and create a buyer session to let buyers manage their own orders.
|
|
511
|
+
|
|
512
|
+
### `client.buyer(token)`
|
|
513
|
+
|
|
514
|
+
Create a buyer session from a session token issued by `client.auth.issueSessionToken()`.
|
|
515
|
+
|
|
516
|
+
```typescript
|
|
517
|
+
const { token } = await client.auth.issueSessionToken({
|
|
518
|
+
storeId: "STO_xxx",
|
|
519
|
+
buyerIdentity: "customer@example.com",
|
|
520
|
+
});
|
|
521
|
+
const buyer = client.buyer(token);
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### `buyer.cancelSubscription(params)`
|
|
525
|
+
|
|
526
|
+
| Field | Type | Required | Description |
|
|
527
|
+
|-------|------|----------|-------------|
|
|
528
|
+
| `orderId` | `string` | Yes | Subscription order ID |
|
|
529
|
+
|
|
530
|
+
**Returns `CancelSubscriptionResult`**: `{ orderId, status }` — status is `"canceling"` (active) or `"canceled"` (pending)
|
|
531
|
+
|
|
532
|
+
### `buyer.cancelOnetimeOrder(params)`
|
|
533
|
+
|
|
534
|
+
| Field | Type | Required | Description |
|
|
535
|
+
|-------|------|----------|-------------|
|
|
536
|
+
| `orderId` | `string` | Yes | One-time order ID |
|
|
537
|
+
|
|
538
|
+
**Returns `CancelOnetimeOrderResult`**: `{ orderId, status }` — status is `"canceled"`
|
|
539
|
+
|
|
540
|
+
### `buyer.reactivateSubscription(params)`
|
|
541
|
+
|
|
542
|
+
| Field | Type | Required | Description |
|
|
543
|
+
|-------|------|----------|-------------|
|
|
544
|
+
| `orderId` | `string` | Yes | Subscription order ID (must be in `canceling` status) |
|
|
545
|
+
|
|
546
|
+
**Returns `ReactivateSubscriptionResult`**: `{ orderId, status }` — status is `"active"`
|
|
547
|
+
|
|
548
|
+
### `buyer.createRefundTicket(params)`
|
|
549
|
+
|
|
550
|
+
| Field | Type | Required | Description |
|
|
551
|
+
|-------|------|----------|-------------|
|
|
552
|
+
| `paymentId` | `string` | Yes | Payment ID to refund |
|
|
553
|
+
| `reason` | `string` | Yes | Reason for the refund request |
|
|
554
|
+
| `requestedAmount` | `RequestedAmount` | Yes | Refund amount (`{ amount, currency }`) |
|
|
555
|
+
| `metadata` | `Record<string, unknown>` | No | Custom metadata |
|
|
556
|
+
|
|
557
|
+
**`RequestedAmount`**:
|
|
558
|
+
|
|
559
|
+
| Field | Type | Description |
|
|
560
|
+
|-------|------|-------------|
|
|
561
|
+
| `amount` | `string` | Amount in display format (e.g., `"29.00"`) |
|
|
562
|
+
| `currency` | `string` | Currency code (ISO 4217) |
|
|
563
|
+
|
|
564
|
+
**Returns `{ ticket: RefundTicket }`**
|
|
565
|
+
|
|
566
|
+
### `buyer.resubmitRefundTicket(params)`
|
|
567
|
+
|
|
568
|
+
| Field | Type | Required | Description |
|
|
569
|
+
|-------|------|----------|-------------|
|
|
570
|
+
| `ticketId` | `string` | Yes | Existing ticket ID |
|
|
571
|
+
| `paymentId` | `string` | Yes | Payment ID |
|
|
572
|
+
| `reason` | `string` | Yes | Updated reason |
|
|
573
|
+
| `requestedAmount` | `RequestedAmount` | Yes | Updated refund amount |
|
|
574
|
+
|
|
575
|
+
**Returns `{ ticket: RefundTicket }`**
|
|
576
|
+
|
|
577
|
+
### `buyer.graphql.query<T>(params)`
|
|
578
|
+
|
|
579
|
+
Same parameters as `client.graphql.query<T>()` but scoped to the buyer's own data via session token.
|
|
580
|
+
|
|
581
|
+
| Field | Type | Required | Description |
|
|
582
|
+
|-------|------|----------|-------------|
|
|
583
|
+
| `query` | `string` | Yes | GraphQL query string |
|
|
584
|
+
| `variables` | `Record<string, unknown>` | No | Query variables |
|
|
585
|
+
|
|
586
|
+
**Returns `GraphQLResponse<T>`**: `{ data, errors? }`
|
|
587
|
+
|
|
588
|
+
---
|
|
589
|
+
|
|
508
590
|
## Checkout
|
|
509
591
|
|
|
510
592
|
Waffo supports two checkout modes based on whether the merchant knows the buyer's identity at checkout time:
|
|
@@ -512,7 +594,7 @@ Waffo supports two checkout modes based on whether the merchant knows the buyer'
|
|
|
512
594
|
- **Authenticated** — the merchant has a user system or collects buyer info before checkout. The buyer's identity is provided upfront, the checkout form is pre-filled, and a session token is automatically issued.
|
|
513
595
|
- **Anonymous** — the buyer arrives via a template store or shared link with no prior context. They fill in billing details manually on the checkout page.
|
|
514
596
|
|
|
515
|
-
> **Authenticated checkout is recommended.** The key advantage: the order is bound to the `buyerIdentity` you provide — a **merchant-controlled stable identifier**. Even if the buyer changes the email on the checkout form, the order stays tied to your identifier. In anonymous mode, the buyer self-reports their email, and a different address means a different user — **previous orders become unlinked** and **subscription trial periods can be exploited** (new email = new user = fresh trial). Additionally, anonymous checkout
|
|
597
|
+
> **Authenticated checkout is recommended.** The key advantage: the order is bound to the `buyerIdentity` you provide — a **merchant-controlled stable identifier**. Even if the buyer changes the email on the checkout form, the order stays tied to your identifier. In anonymous mode, the buyer self-reports their email, and a different address means a different user — **previous orders become unlinked** and **subscription trial periods can be exploited** (new email = new user = fresh trial). Additionally, anonymous checkout only supports creating orders — buyers cannot cancel orders, manage subscriptions, or submit refund tickets afterward.
|
|
516
598
|
|
|
517
599
|
For advanced use cases, the low-level `createSession()` is also available.
|
|
518
600
|
|
|
@@ -771,6 +853,15 @@ All exported type interfaces:
|
|
|
771
853
|
| `CancelSubscriptionParams` | Cancel subscription request |
|
|
772
854
|
| `CancelSubscriptionResult` | Cancel subscription response |
|
|
773
855
|
| `BillingDetail` | Buyer billing details (country, tax ID, etc.) |
|
|
856
|
+
| **Buyer Self-Service** | |
|
|
857
|
+
| `CancelOnetimeOrderParams` | Cancel one-time order request |
|
|
858
|
+
| `CancelOnetimeOrderResult` | Cancel one-time order response |
|
|
859
|
+
| `ReactivateSubscriptionParams` | Reactivate subscription request |
|
|
860
|
+
| `ReactivateSubscriptionResult` | Reactivate subscription response |
|
|
861
|
+
| `CreateRefundTicketParams` | Create refund ticket request |
|
|
862
|
+
| `ResubmitRefundTicketParams` | Resubmit refund ticket request |
|
|
863
|
+
| `RefundTicket` | Refund ticket entity |
|
|
864
|
+
| `RequestedAmount` | Refund amount (`{ amount, currency }`) |
|
|
774
865
|
| **Checkout** | |
|
|
775
866
|
| `AuthenticatedCheckoutParams` | Authenticated checkout request (with buyer identity) |
|
|
776
867
|
| `AuthenticatedCheckoutResult` | Authenticated checkout response (URL with token + expiry) |
|