Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 470
chore(backend): Add webhook event types for Commerce related events#6338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
503fcca50a1a29f3d9b2af0b00a4c5b082bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@clerk/backend': minor | ||
| --- | ||
| Add types for Commerce webhooks |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -63,6 +63,10 @@ export const ObjectType = { | ||
| TestingToken: 'testing_token', | ||
| Role: 'role', | ||
| Permission: 'permission', | ||
| CommercePayer: 'commerce_payer', | ||
| CommercePaymentAttempt: 'commerce_payment_attempt', | ||
| CommerceSubscription: 'commerce_subscription', | ||
| CommerceSubscriptionItem: 'commerce_subscription_item', | ||
| } as const; | ||
| export type ObjectType = (typeof ObjectType)[keyof typeof ObjectType]; | ||
| @@ -757,6 +761,136 @@ export interface IdPOAuthAccessTokenJSON extends ClerkResourceJSON { | ||
| updated_at: number; | ||
| } | ||
| export interface CommercePayerJSON extends ClerkResourceJSON { | ||
| object: typeof ObjectType.CommercePayer; | ||
| instance_id: string; | ||
| user_id?: string; | ||
| first_name?: string; | ||
| last_name?: string; | ||
| email: string; | ||
| organization_id?: string; | ||
| organization_name?: string; | ||
| image_url: string; | ||
| created_at: number; | ||
| updated_at: number; | ||
| } | ||
| export interface CommercePayeeJSON { | ||
| id: string; | ||
| gateway_type: string; | ||
| gateway_external_id: string; | ||
| gateway_status: 'active' | 'pending' | 'restricted' | 'disconnected'; | ||
| } | ||
| export interface CommerceAmountJSON { | ||
| amount: number; | ||
| amount_formatted: string; | ||
| currency: string; | ||
| currency_symbol: string; | ||
| } | ||
| export interface CommerceTotalsJSON { | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For FAPI we also have | ||
| subtotal: CommerceAmountJSON; | ||
| tax_total: CommerceAmountJSON; | ||
| grand_total: CommerceAmountJSON; | ||
| } | ||
| export interface CommercePaymentSourceJSON { | ||
| id: string; | ||
| gateway: string; | ||
| gateway_external_id: string; | ||
| gateway_external_account_id?: string; | ||
| payment_method: string; | ||
| status: 'active' | 'disconnected'; | ||
| card_type?: string; | ||
| last4?: string; | ||
panteliselef marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| export interface CommercePaymentFailedReasonJSON { | ||
| code: string; | ||
| decline_code: string; | ||
| } | ||
| export interface CommerceSubscriptionCreditJSON { | ||
| amount: CommerceAmountJSON; | ||
| cycle_days_remaining: number; | ||
| cycle_days_total: number; | ||
| cycle_remaining_percent: number; | ||
| } | ||
| export interface CommercePlanJSON { | ||
| id: string; | ||
| instance_id: string; | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we keeping | ||
| product_id: string; | ||
| name: string; | ||
| slug: string; | ||
| description?: string; | ||
| is_default: boolean; | ||
| is_recurring: boolean; | ||
| amount: number; | ||
| period: 'month' | 'annual'; | ||
| interval: number; | ||
| has_base_fee: boolean; | ||
| currency: string; | ||
| annual_monthly_amount: number; | ||
| publicly_visible: boolean; | ||
| } | ||
| export interface CommerceSubscriptionItemJSON extends ClerkResourceJSON { | ||
| object: typeof ObjectType.CommerceSubscriptionItem; | ||
| status: 'abandoned' | 'active' | 'canceled' | 'ended' | 'expired' | 'incomplete' | 'past_due' | 'upcoming'; | ||
| credit: CommerceSubscriptionCreditJSON; | ||
| proration_date: string; | ||
mauricioabreu marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| plan_period: 'month' | 'annual'; | ||
| period_start: number; | ||
| period_end?: number; | ||
| canceled_at?: number; | ||
| past_due_at?: number; | ||
| lifetime_paid: number; | ||
| next_payment_amount: number; | ||
| next_payment_date: number; | ||
| amount: CommerceAmountJSON; | ||
| plan: CommercePlanJSON; | ||
| plan_id: string; | ||
| } | ||
| export interface CommercePaymentAttemptJSON extends ClerkResourceJSON { | ||
| object: typeof ObjectType.CommercePaymentAttempt; | ||
| instance_id: string; | ||
| payment_id: string; | ||
| statement_id: string; | ||
| gateway_external_id: string; | ||
| status: 'pending' | 'paid' | 'failed'; | ||
| created_at: number; | ||
| updated_at: number; | ||
| paid_at?: number; | ||
| failed_at?: number; | ||
| failed_reason?: CommercePaymentFailedReasonJSON; | ||
| billing_date: number; | ||
| charge_type: 'checkout' | 'recurring'; | ||
| payee: CommercePayeeJSON; | ||
| payer: CommercePayerJSON; | ||
| totals: CommerceTotalsJSON; | ||
| payment_source: CommercePaymentSourceJSON; | ||
| subscription_items: CommerceSubscriptionItemJSON[]; | ||
| } | ||
| export interface CommerceSubscriptionJSON extends ClerkResourceJSON { | ||
| object: typeof ObjectType.CommerceSubscription; | ||
| status: 'abandoned' | 'active' | 'canceled' | 'ended' | 'expired' | 'incomplete' | 'past_due' | 'upcoming'; | ||
| active_at?: number; | ||
| canceled_at?: number; | ||
| created_at: number; | ||
| ended_at?: number; | ||
| past_due_at?: number; | ||
| updated_at: number; | ||
| latest_payment_id: string; | ||
| payer_id: string; | ||
| payer: CommercePayerJSON; | ||
| payment_source_id: string; | ||
| items: CommerceSubscriptionItemJSON[]; | ||
| } | ||
| export interface WebhooksSvixJSON { | ||
| svix_url: string; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we keeping
instance_id?