@dodopayments/convex 0.2.8 → 0.2.9

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.cjs CHANGED
@@ -4964,23 +4964,33 @@ var PaymentSchema = objectType({
4964
4964
  payload_type: literalType("Payment"),
4965
4965
  billing: objectType({
4966
4966
  city: stringType().nullable(),
4967
- country: stringType().nullable(),
4967
+ country: stringType(),
4968
4968
  state: stringType().nullable(),
4969
4969
  street: stringType().nullable(),
4970
4970
  zipcode: stringType().nullable()
4971
4971
  }),
4972
4972
  brand_id: stringType(),
4973
4973
  business_id: stringType(),
4974
+ card_holder_name: stringType().nullable(),
4974
4975
  card_issuing_country: stringType().nullable(),
4975
4976
  card_last_four: stringType().nullable(),
4976
4977
  card_network: stringType().nullable(),
4977
4978
  card_type: stringType().nullable(),
4979
+ checkout_session_id: stringType().nullable(),
4978
4980
  created_at: stringType().transform((d) => new Date(d)),
4979
4981
  currency: stringType(),
4982
+ custom_field_responses: arrayType(
4983
+ objectType({
4984
+ key: stringType(),
4985
+ value: stringType()
4986
+ })
4987
+ ).nullable(),
4980
4988
  customer: objectType({
4981
4989
  customer_id: stringType(),
4982
4990
  email: stringType(),
4983
- name: stringType().nullable()
4991
+ metadata: recordType(anyType()),
4992
+ name: stringType(),
4993
+ phone_number: stringType().nullable()
4984
4994
  }),
4985
4995
  digital_products_delivered: booleanType(),
4986
4996
  discount_id: stringType().nullable(),
@@ -4991,27 +5001,25 @@ var PaymentSchema = objectType({
4991
5001
  created_at: stringType().transform((d) => new Date(d)),
4992
5002
  currency: stringType(),
4993
5003
  dispute_id: stringType(),
4994
- dispute_stage: enumType([
4995
- "pre_dispute",
4996
- "dispute_opened",
4997
- "dispute_won",
4998
- "dispute_lost"
4999
- ]),
5004
+ dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
5000
5005
  dispute_status: enumType([
5001
5006
  "dispute_opened",
5002
- "dispute_won",
5003
- "dispute_lost",
5007
+ "dispute_expired",
5004
5008
  "dispute_accepted",
5005
5009
  "dispute_cancelled",
5006
- "dispute_challenged"
5010
+ "dispute_challenged",
5011
+ "dispute_won",
5012
+ "dispute_lost"
5007
5013
  ]),
5008
5014
  payment_id: stringType(),
5009
5015
  remarks: stringType().nullable()
5010
5016
  })
5011
- ).nullable(),
5017
+ ).default([]),
5012
5018
  error_code: stringType().nullable(),
5013
5019
  error_message: stringType().nullable(),
5014
- metadata: recordType(anyType()).nullable(),
5020
+ invoice_id: stringType().nullable(),
5021
+ invoice_url: stringType().nullable(),
5022
+ metadata: recordType(anyType()),
5015
5023
  payment_id: stringType(),
5016
5024
  payment_link: stringType().nullable(),
5017
5025
  payment_method: stringType().nullable(),
@@ -5024,21 +5032,34 @@ var PaymentSchema = objectType({
5024
5032
  ).nullable(),
5025
5033
  refunds: arrayType(
5026
5034
  objectType({
5027
- amount: numberType(),
5035
+ amount: numberType().nullable(),
5028
5036
  business_id: stringType(),
5029
5037
  created_at: stringType().transform((d) => new Date(d)),
5030
- currency: stringType(),
5038
+ currency: stringType().nullable(),
5031
5039
  is_partial: booleanType(),
5032
5040
  payment_id: stringType(),
5033
5041
  reason: stringType().nullable(),
5034
5042
  refund_id: stringType(),
5035
- status: enumType(["succeeded", "failed", "pending"])
5043
+ status: enumType(["succeeded", "failed", "pending", "review"])
5036
5044
  })
5037
- ).nullable(),
5045
+ ),
5046
+ refund_status: enumType(["partial", "full"]).nullable(),
5038
5047
  settlement_amount: numberType(),
5039
5048
  settlement_currency: stringType(),
5040
5049
  settlement_tax: numberType().nullable(),
5041
- status: enumType(["succeeded", "failed", "pending", "processing", "cancelled"]),
5050
+ status: enumType([
5051
+ "succeeded",
5052
+ "failed",
5053
+ "cancelled",
5054
+ "processing",
5055
+ "requires_customer_action",
5056
+ "requires_merchant_action",
5057
+ "requires_payment_method",
5058
+ "requires_confirmation",
5059
+ "requires_capture",
5060
+ "partially_captured",
5061
+ "partially_captured_and_capturable"
5062
+ ]).nullable(),
5042
5063
  subscription_id: stringType().nullable(),
5043
5064
  tax: numberType().nullable(),
5044
5065
  total_amount: numberType(),
@@ -5051,10 +5072,10 @@ var SubscriptionSchema = objectType({
5051
5072
  addon_id: stringType(),
5052
5073
  quantity: numberType()
5053
5074
  })
5054
- ).nullable(),
5075
+ ),
5055
5076
  billing: objectType({
5056
5077
  city: stringType().nullable(),
5057
- country: stringType().nullable(),
5078
+ country: stringType(),
5058
5079
  state: stringType().nullable(),
5059
5080
  street: stringType().nullable(),
5060
5081
  zipcode: stringType().nullable()
@@ -5066,15 +5087,72 @@ var SubscriptionSchema = objectType({
5066
5087
  customer: objectType({
5067
5088
  customer_id: stringType(),
5068
5089
  email: stringType(),
5069
- name: stringType().nullable()
5090
+ metadata: recordType(anyType()),
5091
+ name: stringType(),
5092
+ phone_number: stringType().nullable()
5070
5093
  }),
5094
+ custom_field_responses: arrayType(
5095
+ objectType({
5096
+ key: stringType(),
5097
+ value: stringType()
5098
+ })
5099
+ ).nullable(),
5100
+ discount_cycles_remaining: numberType().nullable(),
5071
5101
  discount_id: stringType().nullable(),
5072
- metadata: recordType(anyType()).nullable(),
5073
- next_billing_date: stringType().transform((d) => new Date(d)).nullable(),
5102
+ expires_at: stringType().transform((d) => new Date(d)).nullable(),
5103
+ credit_entitlement_cart: arrayType(
5104
+ objectType({
5105
+ credit_entitlement_id: stringType(),
5106
+ credit_entitlement_name: stringType(),
5107
+ credits_amount: stringType(),
5108
+ overage_balance: stringType(),
5109
+ overage_behavior: enumType([
5110
+ "forgive_at_reset",
5111
+ "invoice_at_billing",
5112
+ "carry_deficit",
5113
+ "carry_deficit_auto_repay"
5114
+ ]),
5115
+ overage_enabled: booleanType(),
5116
+ product_id: stringType(),
5117
+ remaining_balance: stringType(),
5118
+ rollover_enabled: booleanType(),
5119
+ unit: stringType(),
5120
+ expires_after_days: numberType().nullable(),
5121
+ low_balance_threshold_percent: numberType().nullable(),
5122
+ max_rollover_count: numberType().nullable(),
5123
+ overage_limit: stringType().nullable(),
5124
+ rollover_percentage: numberType().nullable(),
5125
+ rollover_timeframe_count: numberType().nullable(),
5126
+ rollover_timeframe_interval: enumType(["Day", "Week", "Month", "Year"]).nullable()
5127
+ })
5128
+ ),
5129
+ meter_credit_entitlement_cart: arrayType(
5130
+ objectType({
5131
+ credit_entitlement_id: stringType(),
5132
+ meter_id: stringType(),
5133
+ meter_name: stringType(),
5134
+ meter_units_per_credit: stringType(),
5135
+ product_id: stringType()
5136
+ })
5137
+ ),
5138
+ meters: arrayType(
5139
+ objectType({
5140
+ currency: stringType(),
5141
+ description: stringType().nullable(),
5142
+ free_threshold: numberType(),
5143
+ measurement_unit: stringType(),
5144
+ meter_id: stringType(),
5145
+ name: stringType(),
5146
+ price_per_unit: stringType().nullable()
5147
+ })
5148
+ ),
5149
+ metadata: recordType(anyType()),
5150
+ next_billing_date: stringType().transform((d) => new Date(d)),
5074
5151
  on_demand: booleanType(),
5075
5152
  payment_frequency_count: numberType(),
5076
5153
  payment_frequency_interval: enumType(["Day", "Week", "Month", "Year"]),
5077
- previous_billing_date: stringType().transform((d) => new Date(d)).nullable(),
5154
+ payment_method_id: stringType().nullable(),
5155
+ previous_billing_date: stringType().transform((d) => new Date(d)),
5078
5156
  product_id: stringType(),
5079
5157
  quantity: numberType(),
5080
5158
  recurring_pre_tax_amount: numberType(),
@@ -5082,7 +5160,6 @@ var SubscriptionSchema = objectType({
5082
5160
  "pending",
5083
5161
  "active",
5084
5162
  "on_hold",
5085
- "paused",
5086
5163
  "cancelled",
5087
5164
  "expired",
5088
5165
  "failed"
@@ -5090,20 +5167,29 @@ var SubscriptionSchema = objectType({
5090
5167
  subscription_id: stringType(),
5091
5168
  subscription_period_count: numberType(),
5092
5169
  subscription_period_interval: enumType(["Day", "Week", "Month", "Year"]),
5170
+ tax_id: stringType().nullable(),
5093
5171
  tax_inclusive: booleanType(),
5094
5172
  trial_period_days: numberType()
5095
5173
  });
5096
5174
  var RefundSchema = objectType({
5097
5175
  payload_type: literalType("Refund"),
5098
- amount: numberType(),
5176
+ amount: numberType().nullable(),
5099
5177
  business_id: stringType(),
5100
5178
  created_at: stringType().transform((d) => new Date(d)),
5101
- currency: stringType(),
5179
+ customer: objectType({
5180
+ customer_id: stringType(),
5181
+ email: stringType(),
5182
+ metadata: recordType(anyType()),
5183
+ name: stringType(),
5184
+ phone_number: stringType().nullable()
5185
+ }),
5186
+ currency: stringType().nullable(),
5102
5187
  is_partial: booleanType(),
5188
+ metadata: recordType(anyType()),
5103
5189
  payment_id: stringType(),
5104
5190
  reason: stringType().nullable(),
5105
5191
  refund_id: stringType(),
5106
- status: enumType(["succeeded", "failed", "pending"])
5192
+ status: enumType(["succeeded", "failed", "pending", "review"])
5107
5193
  });
5108
5194
  var DisputeSchema = objectType({
5109
5195
  payload_type: literalType("Dispute"),
@@ -5111,27 +5197,31 @@ var DisputeSchema = objectType({
5111
5197
  business_id: stringType(),
5112
5198
  created_at: stringType().transform((d) => new Date(d)),
5113
5199
  currency: stringType(),
5200
+ customer: objectType({
5201
+ customer_id: stringType(),
5202
+ email: stringType(),
5203
+ metadata: recordType(anyType()),
5204
+ name: stringType(),
5205
+ phone_number: stringType().nullable()
5206
+ }),
5114
5207
  dispute_id: stringType(),
5115
- dispute_stage: enumType([
5116
- "pre_dispute",
5117
- "dispute_opened",
5118
- "dispute_won",
5119
- "dispute_lost"
5120
- ]),
5208
+ dispute_stage: enumType(["pre_dispute", "dispute", "pre_arbitration"]),
5121
5209
  dispute_status: enumType([
5122
5210
  "dispute_opened",
5123
- "dispute_won",
5124
- "dispute_lost",
5211
+ "dispute_expired",
5125
5212
  "dispute_accepted",
5126
5213
  "dispute_cancelled",
5127
- "dispute_challenged"
5214
+ "dispute_challenged",
5215
+ "dispute_won",
5216
+ "dispute_lost"
5128
5217
  ]),
5129
5218
  payment_id: stringType(),
5219
+ reason: stringType().nullable(),
5130
5220
  remarks: stringType().nullable()
5131
5221
  });
5132
5222
  var LicenseKeySchema = objectType({
5133
5223
  payload_type: literalType("LicenseKey"),
5134
- activations_limit: numberType(),
5224
+ activations_limit: numberType().nullable(),
5135
5225
  business_id: stringType(),
5136
5226
  created_at: stringType().transform((d) => new Date(d)),
5137
5227
  customer_id: stringType(),
@@ -5141,7 +5231,7 @@ var LicenseKeySchema = objectType({
5141
5231
  key: stringType(),
5142
5232
  payment_id: stringType(),
5143
5233
  product_id: stringType(),
5144
- status: enumType(["active", "inactive", "expired"]),
5234
+ status: enumType(["active", "expired", "disabled"]),
5145
5235
  subscription_id: stringType().nullable()
5146
5236
  });
5147
5237
  var PaymentSucceededPayloadSchema = objectType({
@@ -5240,12 +5330,6 @@ var SubscriptionRenewedPayloadSchema = objectType({
5240
5330
  timestamp: stringType().transform((d) => new Date(d)),
5241
5331
  data: SubscriptionSchema
5242
5332
  });
5243
- var SubscriptionPausedPayloadSchema = objectType({
5244
- business_id: stringType(),
5245
- type: literalType("subscription.paused"),
5246
- timestamp: stringType().transform((d) => new Date(d)),
5247
- data: SubscriptionSchema
5248
- });
5249
5333
  var SubscriptionPlanChangedPayloadSchema = objectType({
5250
5334
  business_id: stringType(),
5251
5335
  type: literalType("subscription.plan_changed"),
@@ -5282,6 +5366,94 @@ var LicenseKeyCreatedPayloadSchema = objectType({
5282
5366
  timestamp: stringType().transform((d) => new Date(d)),
5283
5367
  data: LicenseKeySchema
5284
5368
  });
5369
+ var CreditLedgerEntrySchema = objectType({
5370
+ payload_type: literalType("CreditLedgerEntry"),
5371
+ id: stringType(),
5372
+ amount: stringType(),
5373
+ balance_after: stringType(),
5374
+ balance_before: stringType(),
5375
+ business_id: stringType(),
5376
+ created_at: stringType().transform((d) => new Date(d)),
5377
+ credit_entitlement_id: stringType(),
5378
+ customer_id: stringType(),
5379
+ is_credit: booleanType(),
5380
+ overage_after: stringType(),
5381
+ overage_before: stringType(),
5382
+ transaction_type: enumType([
5383
+ "credit_added",
5384
+ "credit_deducted",
5385
+ "credit_expired",
5386
+ "credit_rolled_over",
5387
+ "rollover_forfeited",
5388
+ "overage_charged",
5389
+ "auto_top_up",
5390
+ "manual_adjustment",
5391
+ "refund"
5392
+ ]),
5393
+ description: stringType().nullable(),
5394
+ grant_id: stringType().nullable(),
5395
+ reference_id: stringType().nullable(),
5396
+ reference_type: stringType().nullable()
5397
+ });
5398
+ var CreditBalanceLowSchema = objectType({
5399
+ payload_type: literalType("CreditBalanceLow"),
5400
+ customer_id: stringType(),
5401
+ subscription_id: stringType(),
5402
+ credit_entitlement_id: stringType(),
5403
+ credit_entitlement_name: stringType(),
5404
+ available_balance: stringType(),
5405
+ subscription_credits_amount: stringType(),
5406
+ threshold_percent: numberType(),
5407
+ threshold_amount: stringType()
5408
+ });
5409
+ var CreditAddedPayloadSchema = objectType({
5410
+ business_id: stringType(),
5411
+ type: literalType("credit.added"),
5412
+ timestamp: stringType().transform((d) => new Date(d)),
5413
+ data: CreditLedgerEntrySchema
5414
+ });
5415
+ var CreditDeductedPayloadSchema = objectType({
5416
+ business_id: stringType(),
5417
+ type: literalType("credit.deducted"),
5418
+ timestamp: stringType().transform((d) => new Date(d)),
5419
+ data: CreditLedgerEntrySchema
5420
+ });
5421
+ var CreditExpiredPayloadSchema = objectType({
5422
+ business_id: stringType(),
5423
+ type: literalType("credit.expired"),
5424
+ timestamp: stringType().transform((d) => new Date(d)),
5425
+ data: CreditLedgerEntrySchema
5426
+ });
5427
+ var CreditRolledOverPayloadSchema = objectType({
5428
+ business_id: stringType(),
5429
+ type: literalType("credit.rolled_over"),
5430
+ timestamp: stringType().transform((d) => new Date(d)),
5431
+ data: CreditLedgerEntrySchema
5432
+ });
5433
+ var CreditRolloverForfeitedPayloadSchema = objectType({
5434
+ business_id: stringType(),
5435
+ type: literalType("credit.rollover_forfeited"),
5436
+ timestamp: stringType().transform((d) => new Date(d)),
5437
+ data: CreditLedgerEntrySchema
5438
+ });
5439
+ var CreditOverageChargedPayloadSchema = objectType({
5440
+ business_id: stringType(),
5441
+ type: literalType("credit.overage_charged"),
5442
+ timestamp: stringType().transform((d) => new Date(d)),
5443
+ data: CreditLedgerEntrySchema
5444
+ });
5445
+ var CreditManualAdjustmentPayloadSchema = objectType({
5446
+ business_id: stringType(),
5447
+ type: literalType("credit.manual_adjustment"),
5448
+ timestamp: stringType().transform((d) => new Date(d)),
5449
+ data: CreditLedgerEntrySchema
5450
+ });
5451
+ var CreditBalanceLowPayloadSchema = objectType({
5452
+ business_id: stringType(),
5453
+ type: literalType("credit.balance_low"),
5454
+ timestamp: stringType().transform((d) => new Date(d)),
5455
+ data: CreditBalanceLowSchema
5456
+ });
5285
5457
  var WebhookPayloadSchema = discriminatedUnionType("type", [
5286
5458
  PaymentSucceededPayloadSchema,
5287
5459
  PaymentFailedPayloadSchema,
@@ -5299,13 +5471,20 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
5299
5471
  SubscriptionActivePayloadSchema,
5300
5472
  SubscriptionOnHoldPayloadSchema,
5301
5473
  SubscriptionRenewedPayloadSchema,
5302
- SubscriptionPausedPayloadSchema,
5303
5474
  SubscriptionPlanChangedPayloadSchema,
5304
5475
  SubscriptionCancelledPayloadSchema,
5305
5476
  SubscriptionFailedPayloadSchema,
5306
5477
  SubscriptionExpiredPayloadSchema,
5307
5478
  SubscriptionUpdatedPayloadSchema,
5308
- LicenseKeyCreatedPayloadSchema
5479
+ LicenseKeyCreatedPayloadSchema,
5480
+ CreditAddedPayloadSchema,
5481
+ CreditDeductedPayloadSchema,
5482
+ CreditExpiredPayloadSchema,
5483
+ CreditRolledOverPayloadSchema,
5484
+ CreditRolloverForfeitedPayloadSchema,
5485
+ CreditOverageChargedPayloadSchema,
5486
+ CreditManualAdjustmentPayloadSchema,
5487
+ CreditBalanceLowPayloadSchema
5309
5488
  ]);
5310
5489
 
5311
5490
  // src/webhook/vendor/timing_safe_equal.ts
@@ -6185,9 +6364,6 @@ async function handleWebhookPayload(payload, config, context) {
6185
6364
  if (payload.type === "subscription.renewed") {
6186
6365
  await callHandler(config.onSubscriptionRenewed, payload);
6187
6366
  }
6188
- if (payload.type === "subscription.paused") {
6189
- await callHandler(config.onSubscriptionPaused, payload);
6190
- }
6191
6367
  if (payload.type === "subscription.plan_changed") {
6192
6368
  await callHandler(config.onSubscriptionPlanChanged, payload);
6193
6369
  }
@@ -6206,6 +6382,30 @@ async function handleWebhookPayload(payload, config, context) {
6206
6382
  if (payload.type === "license_key.created") {
6207
6383
  await callHandler(config.onLicenseKeyCreated, payload);
6208
6384
  }
6385
+ if (payload.type === "credit.added") {
6386
+ await callHandler(config.onCreditAdded, payload);
6387
+ }
6388
+ if (payload.type === "credit.deducted") {
6389
+ await callHandler(config.onCreditDeducted, payload);
6390
+ }
6391
+ if (payload.type === "credit.expired") {
6392
+ await callHandler(config.onCreditExpired, payload);
6393
+ }
6394
+ if (payload.type === "credit.rolled_over") {
6395
+ await callHandler(config.onCreditRolledOver, payload);
6396
+ }
6397
+ if (payload.type === "credit.rollover_forfeited") {
6398
+ await callHandler(config.onCreditRolloverForfeited, payload);
6399
+ }
6400
+ if (payload.type === "credit.overage_charged") {
6401
+ await callHandler(config.onCreditOverageCharged, payload);
6402
+ }
6403
+ if (payload.type === "credit.manual_adjustment") {
6404
+ await callHandler(config.onCreditManualAdjustment, payload);
6405
+ }
6406
+ if (payload.type === "credit.balance_low") {
6407
+ await callHandler(config.onCreditBalanceLow, payload);
6408
+ }
6209
6409
  }
6210
6410
  var verifyWebhookPayload = async ({
6211
6411
  webhookKey,