@@ -69,6 +69,8 @@ export const ObjectType = {
6969 CommercePaymentAttempt : 'commerce_payment_attempt' ,
7070 CommerceSubscription : 'commerce_subscription' ,
7171 CommerceSubscriptionItem : 'commerce_subscription_item' ,
72+ CommercePlan : 'commerce_plan' ,
73+ Feature : 'feature' ,
7274} as const ;
7375
7476export type ObjectType = ( typeof ObjectType ) [ keyof typeof ObjectType ] ;
@@ -791,71 +793,65 @@ export interface CommercePayerJSON extends ClerkResourceJSON {
791793 updated_at : number ;
792794}
793795
794- export interface CommercePayeeJSON {
796+ interface CommercePayeeJSON {
795797 id : string ;
796798 gateway_type : string ;
797799 gateway_external_id : string ;
798800 gateway_status : 'active' | 'pending' | 'restricted' | 'disconnected' ;
799801}
800802
801- export interface CommerceAmountJSON {
803+ interface CommerceFeeJSON {
802804 amount : number ;
803805 amount_formatted : string ;
804806 currency : string ;
805807 currency_symbol : string ;
806808}
807809
808- export interface CommerceTotalsJSON {
809- subtotal : CommerceAmountJSON ;
810- tax_total : CommerceAmountJSON ;
811- grand_total : CommerceAmountJSON ;
810+ interface CommerceTotalsJSON {
811+ subtotal : CommerceFeeJSON ;
812+ tax_total : CommerceFeeJSON ;
813+ grand_total : CommerceFeeJSON ;
812814}
813815
814- export interface CommercePaymentSourceJSON {
815- id : string ;
816- gateway : string ;
817- gateway_external_id : string ;
818- gateway_external_account_id ?: string ;
819- payment_method : string ;
820- status : 'active' | 'disconnected' ;
821- card_type ?: string ;
822- last4 ?: string ;
823- }
824-
825- export interface CommercePaymentFailedReasonJSON {
826- code : string ;
827- decline_code : string ;
828- }
829-
830- export interface CommerceSubscriptionCreditJSON {
831- amount : CommerceAmountJSON ;
832- cycle_days_remaining : number ;
833- cycle_days_total : number ;
834- cycle_remaining_percent : number ;
816+ export interface FeatureJSON extends ClerkResourceJSON {
817+ object : typeof ObjectType . Feature ;
818+ name : string ;
819+ description : string ;
820+ slug : string ;
821+ avatar_url : string ;
835822}
836823
837- export interface CommercePlanJSON {
824+ /**
825+ * @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change.
826+ * It is advised to pin the SDK version to avoid breaking changes.
827+ */
828+ export interface CommercePlanJSON extends ClerkResourceJSON {
829+ object : typeof ObjectType . CommercePlan ;
838830 id : string ;
839- instance_id : string ;
840831 product_id : string ;
841832 name : string ;
842833 slug : string ;
843834 description ?: string ;
844835 is_default : boolean ;
845836 is_recurring : boolean ;
846- amount : number ;
847- period : 'month' | 'annual' ;
848- interval : number ;
849837 has_base_fee : boolean ;
850- currency : string ;
851- annual_monthly_amount : number ;
852838 publicly_visible : boolean ;
839+ fee : CommerceFeeJSON ;
840+ annual_fee : CommerceFeeJSON ;
841+ annual_monthly_fee : CommerceFeeJSON ;
842+ for_payer_type : 'org' | 'user' ;
843+ features : FeatureJSON [ ] ;
853844}
854845
855846export interface CommerceSubscriptionItemJSON extends ClerkResourceJSON {
856847 object : typeof ObjectType . CommerceSubscriptionItem ;
857848 status : 'abandoned' | 'active' | 'canceled' | 'ended' | 'expired' | 'incomplete' | 'past_due' | 'upcoming' ;
858- credit : CommerceSubscriptionCreditJSON ;
849+ credit : {
850+ amount : CommerceFeeJSON ;
851+ cycle_days_remaining : number ;
852+ cycle_days_total : number ;
853+ cycle_remaining_percent : number ;
854+ } ;
859855 proration_date : string ;
860856 plan_period : 'month' | 'annual' ;
861857 period_start : number ;
@@ -865,8 +861,24 @@ export interface CommerceSubscriptionItemJSON extends ClerkResourceJSON {
865861 lifetime_paid : number ;
866862 next_payment_amount : number ;
867863 next_payment_date : number ;
868- amount : CommerceAmountJSON ;
869- plan : CommercePlanJSON ;
864+ amount : CommerceFeeJSON ;
865+ plan : {
866+ id : string ;
867+ instance_id : string ;
868+ product_id : string ;
869+ name : string ;
870+ slug : string ;
871+ description ?: string ;
872+ is_default : boolean ;
873+ is_recurring : boolean ;
874+ amount : number ;
875+ period : 'month' | 'annual' ;
876+ interval : number ;
877+ has_base_fee : boolean ;
878+ currency : string ;
879+ annual_monthly_amount : number ;
880+ publicly_visible : boolean ;
881+ } ;
870882 plan_id : string ;
871883}
872884
@@ -881,13 +893,25 @@ export interface CommercePaymentAttemptJSON extends ClerkResourceJSON {
881893 updated_at : number ;
882894 paid_at ?: number ;
883895 failed_at ?: number ;
884- failed_reason ?: CommercePaymentFailedReasonJSON ;
896+ failed_reason ?: {
897+ code : string ;
898+ decline_code : string ;
899+ } ;
885900 billing_date : number ;
886901 charge_type : 'checkout' | 'recurring' ;
887902 payee : CommercePayeeJSON ;
888903 payer : CommercePayerJSON ;
889904 totals : CommerceTotalsJSON ;
890- payment_source : CommercePaymentSourceJSON ;
905+ payment_source : {
906+ id : string ;
907+ gateway : string ;
908+ gateway_external_id : string ;
909+ gateway_external_account_id ?: string ;
910+ payment_method : string ;
911+ status : 'active' | 'disconnected' ;
912+ card_type ?: string ;
913+ last4 ?: string ;
914+ } ;
891915 subscription_items : CommerceSubscriptionItemJSON [ ] ;
892916}
893917
0 commit comments