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