@hanzo/commerce 7.6.0 → 7.6.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.
Files changed (2) hide show
  1. package/client.ts +35 -35
  2. package/package.json +1 -1
package/client.ts CHANGED
@@ -390,13 +390,13 @@ export class Commerce {
390
390
  // -----------------------------------------------------------------------
391
391
 
392
392
  async getBalance(user: string, currency = 'usd', token?: string): Promise<Balance> {
393
- return this.request<Balance>('/api/v1/billing/balance', {
393
+ return this.request<Balance>('/v1/billing/balance', {
394
394
  params: { user, currency }, token,
395
395
  })
396
396
  }
397
397
 
398
398
  async getAllBalances(user: string, token?: string): Promise<Record<string, Balance>> {
399
- return this.request<Record<string, Balance>>('/api/v1/billing/balance/all', {
399
+ return this.request<Record<string, Balance>>('/v1/billing/balance/all', {
400
400
  params: { user }, token,
401
401
  })
402
402
  }
@@ -406,13 +406,13 @@ export class Commerce {
406
406
  // -----------------------------------------------------------------------
407
407
 
408
408
  async addUsageRecord(record: UsageRecord, token?: string): Promise<Transaction> {
409
- return this.request<Transaction>('/api/v1/billing/usage', {
409
+ return this.request<Transaction>('/v1/billing/usage', {
410
410
  method: 'POST', body: record, token,
411
411
  })
412
412
  }
413
413
 
414
414
  async getUsageRecords(user: string, currency = 'usd', token?: string): Promise<Transaction[]> {
415
- return this.request<Transaction[]>('/api/v1/billing/usage', {
415
+ return this.request<Transaction[]>('/v1/billing/usage', {
416
416
  params: { user, currency }, token,
417
417
  })
418
418
  }
@@ -425,13 +425,13 @@ export class Commerce {
425
425
  params: { user: string; currency?: string; amount: number; notes?: string; tags?: string[]; expiresIn?: string },
426
426
  token?: string,
427
427
  ): Promise<Transaction> {
428
- return this.request<Transaction>('/api/v1/billing/deposit', {
428
+ return this.request<Transaction>('/v1/billing/deposit', {
429
429
  method: 'POST', body: params, token,
430
430
  })
431
431
  }
432
432
 
433
433
  async grantStarterCredit(user: string, token?: string): Promise<Transaction> {
434
- return this.request<Transaction>('/api/v1/billing/credit', {
434
+ return this.request<Transaction>('/v1/billing/credit', {
435
435
  method: 'POST', body: { user }, token,
436
436
  })
437
437
  }
@@ -441,12 +441,12 @@ export class Commerce {
441
441
  // -----------------------------------------------------------------------
442
442
 
443
443
  async getPlans(token?: string): Promise<Plan[]> {
444
- return this.request<Plan[]>('/api/v1/billing/plans', { token })
444
+ return this.request<Plan[]>('/v1/billing/plans', { token })
445
445
  }
446
446
 
447
447
  async getPlan(planId: string, token?: string): Promise<Plan | null> {
448
448
  try {
449
- return await this.request<Plan>(`/api/v1/billing/plans/${planId}`, { token })
449
+ return await this.request<Plan>(`/v1/billing/plans/${planId}`, { token })
450
450
  } catch { return null }
451
451
  }
452
452
 
@@ -458,37 +458,37 @@ export class Commerce {
458
458
  params: { planId: string; userId?: string; customerId?: string; paymentMethodId?: string; couponCode?: string; trialDays?: number },
459
459
  token?: string,
460
460
  ): Promise<Subscription> {
461
- return this.request<Subscription>('/api/v1/billing/subscriptions', {
461
+ return this.request<Subscription>('/v1/billing/subscriptions', {
462
462
  method: 'POST', body: params, token,
463
463
  })
464
464
  }
465
465
 
466
466
  async getSubscription(subscriptionId: string, token?: string): Promise<Subscription | null> {
467
467
  try {
468
- return await this.request<Subscription>(`/api/v1/billing/subscriptions/${subscriptionId}`, { token })
468
+ return await this.request<Subscription>(`/v1/billing/subscriptions/${subscriptionId}`, { token })
469
469
  } catch { return null }
470
470
  }
471
471
 
472
472
  async listSubscriptions(params?: { customerId?: string }, token?: string): Promise<Subscription[]> {
473
- return this.request<Subscription[]>('/api/v1/billing/subscriptions', {
473
+ return this.request<Subscription[]>('/v1/billing/subscriptions', {
474
474
  params: params as Record<string, string> | undefined, token,
475
475
  })
476
476
  }
477
477
 
478
478
  async updateSubscription(subscriptionId: string, update: Partial<Subscription>, token?: string): Promise<Subscription> {
479
- return this.request<Subscription>(`/api/v1/billing/subscriptions/${subscriptionId}`, {
479
+ return this.request<Subscription>(`/v1/billing/subscriptions/${subscriptionId}`, {
480
480
  method: 'PATCH', body: update, token,
481
481
  })
482
482
  }
483
483
 
484
484
  async cancelSubscription(subscriptionId: string, immediately = false, token?: string): Promise<Subscription> {
485
- return this.request<Subscription>(`/api/v1/billing/subscriptions/${subscriptionId}/cancel`, {
485
+ return this.request<Subscription>(`/v1/billing/subscriptions/${subscriptionId}/cancel`, {
486
486
  method: 'POST', body: { immediately }, token,
487
487
  })
488
488
  }
489
489
 
490
490
  async reactivateSubscription(subscriptionId: string, token?: string): Promise<Subscription> {
491
- return this.request<Subscription>(`/api/v1/billing/subscriptions/${subscriptionId}/reactivate`, {
491
+ return this.request<Subscription>(`/v1/billing/subscriptions/${subscriptionId}/reactivate`, {
492
492
  method: 'POST', token,
493
493
  })
494
494
  }
@@ -506,7 +506,7 @@ export class Commerce {
506
506
  params: CheckoutSessionRequest,
507
507
  token?: string,
508
508
  ): Promise<CheckoutSessionResponse> {
509
- return this.request<CheckoutSessionResponse>('/api/v1/checkout/sessions', {
509
+ return this.request<CheckoutSessionResponse>('/v1/checkout/sessions', {
510
510
  method: 'POST', body: params, token,
511
511
  })
512
512
  }
@@ -522,7 +522,7 @@ export class Commerce {
522
522
  * tokenizes via the configured payment provider (Stripe).
523
523
  */
524
524
  async tokenizeCard(card: CardTokenizeRequest, token?: string): Promise<CardTokenizeResult> {
525
- return this.request<CardTokenizeResult>('/api/v1/billing/card/tokenize', {
525
+ return this.request<CardTokenizeResult>('/v1/billing/card/tokenize', {
526
526
  method: 'POST',
527
527
  body: {
528
528
  number: card.number.replace(/\s/g, ''),
@@ -550,25 +550,25 @@ export class Commerce {
550
550
  },
551
551
  token?: string,
552
552
  ): Promise<PaymentMethod> {
553
- return this.request<PaymentMethod>('/api/v1/billing/payment-methods', {
553
+ return this.request<PaymentMethod>('/v1/billing/payment-methods', {
554
554
  method: 'POST', body: params, token,
555
555
  })
556
556
  }
557
557
 
558
558
  async listPaymentMethods(customerId: string, token?: string): Promise<PaymentMethod[]> {
559
- return this.request<PaymentMethod[]>('/api/v1/billing/payment-methods', {
559
+ return this.request<PaymentMethod[]>('/v1/billing/payment-methods', {
560
560
  params: { customerId }, token,
561
561
  })
562
562
  }
563
563
 
564
564
  async removePaymentMethod(paymentMethodId: string, token?: string): Promise<void> {
565
- await this.request<void>(`/api/v1/billing/payment-methods/${paymentMethodId}`, {
565
+ await this.request<void>(`/v1/billing/payment-methods/${paymentMethodId}`, {
566
566
  method: 'DELETE', token,
567
567
  })
568
568
  }
569
569
 
570
570
  async setDefaultPaymentMethod(customerId: string, paymentMethodId: string, token?: string): Promise<PaymentMethod> {
571
- return this.request<PaymentMethod>(`/api/v1/billing/customers/${customerId}/default-payment-method`, {
571
+ return this.request<PaymentMethod>(`/v1/billing/customers/${customerId}/default-payment-method`, {
572
572
  method: 'POST', body: { paymentMethodId }, token,
573
573
  })
574
574
  }
@@ -583,7 +583,7 @@ export class Commerce {
583
583
  */
584
584
  async validateCoupon(code: string, subtotalCents?: number, token?: string): Promise<CouponValidateResult> {
585
585
  try {
586
- const result = await this.request<Coupon>('/api/v1/coupon/validate', {
586
+ const result = await this.request<Coupon>('/v1/coupon/validate', {
587
587
  method: 'POST',
588
588
  body: { code: code.toUpperCase().trim(), subtotalCents },
589
589
  token,
@@ -599,7 +599,7 @@ export class Commerce {
599
599
  * Redeem a coupon for a user. Creates credit grant records.
600
600
  */
601
601
  async redeemCoupon(code: string, userId: string, token?: string): Promise<CreditGrant[]> {
602
- return this.request<CreditGrant[]>('/api/v1/coupon/redeem', {
602
+ return this.request<CreditGrant[]>('/v1/coupon/redeem', {
603
603
  method: 'POST',
604
604
  body: { code: code.toUpperCase().trim(), userId },
605
605
  token,
@@ -615,17 +615,17 @@ export class Commerce {
615
615
  * Returns the referral code/link the user can share.
616
616
  */
617
617
  async getOrCreateReferrer(userId: string, token?: string): Promise<Referrer> {
618
- return this.request<Referrer>('/api/v1/referrer', {
618
+ return this.request<Referrer>('/v1/referrer', {
619
619
  method: 'POST', body: { userId }, token,
620
620
  })
621
621
  }
622
622
 
623
623
  async getReferrals(userId: string, token?: string): Promise<Referral[]> {
624
- return this.request<Referral[]>(`/api/v1/user/${userId}/referrals`, { token })
624
+ return this.request<Referral[]>(`/v1/user/${userId}/referrals`, { token })
625
625
  }
626
626
 
627
627
  async getReferrers(userId: string, token?: string): Promise<Referrer[]> {
628
- return this.request<Referrer[]>(`/api/v1/user/${userId}/referrers`, { token })
628
+ return this.request<Referrer[]>(`/v1/user/${userId}/referrers`, { token })
629
629
  }
630
630
 
631
631
  /**
@@ -633,7 +633,7 @@ export class Commerce {
633
633
  */
634
634
  async getAffiliate(userId: string, token?: string): Promise<Affiliate | null> {
635
635
  try {
636
- return await this.request<Affiliate>(`/api/v1/user/${userId}/affiliate`, { token })
636
+ return await this.request<Affiliate>(`/v1/user/${userId}/affiliate`, { token })
637
637
  } catch { return null }
638
638
  }
639
639
 
@@ -642,21 +642,21 @@ export class Commerce {
642
642
  * After creation, user can connect their bank via the returnedconnectUrl.
643
643
  */
644
644
  async createAffiliate(userId: string, token?: string): Promise<Affiliate> {
645
- return this.request<Affiliate>('/api/v1/affiliate', {
645
+ return this.request<Affiliate>('/v1/affiliate', {
646
646
  method: 'POST', body: { userId }, token,
647
647
  })
648
648
  }
649
649
 
650
650
  async getAffiliateReferrals(affiliateId: string, token?: string): Promise<Referral[]> {
651
- return this.request<Referral[]>(`/api/v1/affiliate/${affiliateId}/referrals`, { token })
651
+ return this.request<Referral[]>(`/v1/affiliate/${affiliateId}/referrals`, { token })
652
652
  }
653
653
 
654
654
  async getAffiliateOrders(affiliateId: string, token?: string): Promise<unknown[]> {
655
- return this.request<unknown[]>(`/api/v1/affiliate/${affiliateId}/orders`, { token })
655
+ return this.request<unknown[]>(`/v1/affiliate/${affiliateId}/orders`, { token })
656
656
  }
657
657
 
658
658
  async getAffiliateTransactions(affiliateId: string, token?: string): Promise<Transaction[]> {
659
- return this.request<Transaction[]>(`/api/v1/affiliate/${affiliateId}/transactions`, { token })
659
+ return this.request<Transaction[]>(`/v1/affiliate/${affiliateId}/transactions`, { token })
660
660
  }
661
661
 
662
662
  // -----------------------------------------------------------------------
@@ -664,26 +664,26 @@ export class Commerce {
664
664
  // -----------------------------------------------------------------------
665
665
 
666
666
  async authorize(orderId: string, token?: string): Promise<Payment> {
667
- return this.request<Payment>(`/api/v1/authorize/${orderId}`, { method: 'POST', token })
667
+ return this.request<Payment>(`/v1/authorize/${orderId}`, { method: 'POST', token })
668
668
  }
669
669
 
670
670
  async capture(orderId: string, token?: string): Promise<Payment> {
671
- return this.request<Payment>(`/api/v1/capture/${orderId}`, { method: 'POST', token })
671
+ return this.request<Payment>(`/v1/capture/${orderId}`, { method: 'POST', token })
672
672
  }
673
673
 
674
674
  async charge(orderId: string, token?: string): Promise<Payment> {
675
- return this.request<Payment>(`/api/v1/charge/${orderId}`, { method: 'POST', token })
675
+ return this.request<Payment>(`/v1/charge/${orderId}`, { method: 'POST', token })
676
676
  }
677
677
 
678
678
  async refund(paymentId: string, token?: string): Promise<Payment> {
679
- return this.request<Payment>(`/api/v1/refund/${paymentId}`, { method: 'POST', token })
679
+ return this.request<Payment>(`/v1/refund/${paymentId}`, { method: 'POST', token })
680
680
  }
681
681
 
682
682
  async billingRefund(
683
683
  params: { user: string; amount: number; originalTransactionId: string; currency?: string; notes?: string },
684
684
  token?: string,
685
685
  ): Promise<Transaction> {
686
- return this.request<Transaction>('/api/v1/billing/refund', {
686
+ return this.request<Transaction>('/v1/billing/refund', {
687
687
  method: 'POST', body: params, token,
688
688
  })
689
689
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/commerce",
3
- "version": "7.6.0",
3
+ "version": "7.6.1",
4
4
  "description": "e-commerce framework.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",