dodopayments 2.20.0 → 2.21.0

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +1 -1
  4. data/lib/dodopayments/models/checkout_session_preview_response.rb +41 -4
  5. data/lib/dodopayments/models/credit_entitlements/balance_create_ledger_entry_params.rb +4 -2
  6. data/lib/dodopayments/models/discount.rb +95 -3
  7. data/lib/dodopayments/models/discount_create_params.rb +110 -3
  8. data/lib/dodopayments/models/discount_list_params.rb +7 -2
  9. data/lib/dodopayments/models/discount_type.rb +1 -0
  10. data/lib/dodopayments/models/discount_update_params.rb +108 -3
  11. data/lib/dodopayments/models/payment.rb +162 -1
  12. data/lib/dodopayments/models/payment_list_params.rb +163 -1
  13. data/lib/dodopayments/models/payment_method_types.rb +0 -1
  14. data/lib/dodopayments/models/price.rb +19 -1
  15. data/lib/dodopayments/models/subscription.rb +11 -1
  16. data/lib/dodopayments/models/subscription_create_response.rb +10 -1
  17. data/lib/dodopayments/models/subscription_list_params.rb +12 -1
  18. data/lib/dodopayments/models/subscription_list_response.rb +11 -1
  19. data/lib/dodopayments/models/subscription_update_payment_method_webhook_event.rb +40 -0
  20. data/lib/dodopayments/models/unsafe_unwrap_webhook_event.rb +4 -1
  21. data/lib/dodopayments/models/unwrap_webhook_event.rb +4 -1
  22. data/lib/dodopayments/models/webhook_event_type.rb +1 -0
  23. data/lib/dodopayments/models.rb +3 -0
  24. data/lib/dodopayments/resources/credit_entitlements/balances.rb +1 -1
  25. data/lib/dodopayments/resources/discounts.rb +24 -5
  26. data/lib/dodopayments/resources/payments.rb +3 -1
  27. data/lib/dodopayments/resources/subscriptions.rb +6 -1
  28. data/lib/dodopayments/resources/webhooks.rb +2 -2
  29. data/lib/dodopayments/version.rb +1 -1
  30. data/lib/dodopayments.rb +1 -0
  31. data/rbi/dodopayments/models/checkout_session_preview_response.rbi +47 -5
  32. data/rbi/dodopayments/models/credit_entitlements/balance_create_ledger_entry_params.rbi +6 -2
  33. data/rbi/dodopayments/models/discount.rbi +151 -2
  34. data/rbi/dodopayments/models/discount_create_params.rbi +197 -2
  35. data/rbi/dodopayments/models/discount_list_params.rbi +6 -2
  36. data/rbi/dodopayments/models/discount_type.rbi +1 -0
  37. data/rbi/dodopayments/models/discount_update_params.rbi +193 -2
  38. data/rbi/dodopayments/models/payment.rbi +365 -0
  39. data/rbi/dodopayments/models/payment_list_params.rbi +327 -0
  40. data/rbi/dodopayments/models/payment_method_types.rbi +0 -1
  41. data/rbi/dodopayments/models/price.rbi +20 -0
  42. data/rbi/dodopayments/models/subscription.rbi +15 -3
  43. data/rbi/dodopayments/models/subscription_create_response.rbi +13 -3
  44. data/rbi/dodopayments/models/subscription_list_params.rbi +11 -0
  45. data/rbi/dodopayments/models/subscription_list_response.rbi +15 -3
  46. data/rbi/dodopayments/models/subscription_update_payment_method_webhook_event.rbi +67 -0
  47. data/rbi/dodopayments/models/unsafe_unwrap_webhook_event.rbi +1 -0
  48. data/rbi/dodopayments/models/unwrap_webhook_event.rbi +1 -0
  49. data/rbi/dodopayments/models/webhook_event_type.rbi +5 -0
  50. data/rbi/dodopayments/models.rbi +3 -0
  51. data/rbi/dodopayments/resources/credit_entitlements/balances.rbi +3 -1
  52. data/rbi/dodopayments/resources/discounts.rbi +57 -3
  53. data/rbi/dodopayments/resources/payments.rbi +3 -0
  54. data/rbi/dodopayments/resources/subscriptions.rbi +3 -0
  55. data/rbi/dodopayments/resources/webhooks.rbi +2 -0
  56. data/sig/dodopayments/models/checkout_session_preview_response.rbs +18 -3
  57. data/sig/dodopayments/models/discount.rbs +69 -0
  58. data/sig/dodopayments/models/discount_create_params.rbs +69 -0
  59. data/sig/dodopayments/models/discount_type.rbs +2 -1
  60. data/sig/dodopayments/models/discount_update_params.rbs +69 -0
  61. data/sig/dodopayments/models/payment.rbs +145 -0
  62. data/sig/dodopayments/models/payment_list_params.rbs +308 -0
  63. data/sig/dodopayments/models/payment_method_types.rbs +0 -2
  64. data/sig/dodopayments/models/price.rbs +10 -0
  65. data/sig/dodopayments/models/subscription.rbs +8 -3
  66. data/sig/dodopayments/models/subscription_create_response.rbs +8 -3
  67. data/sig/dodopayments/models/subscription_list_params.rbs +7 -0
  68. data/sig/dodopayments/models/subscription_list_response.rbs +8 -3
  69. data/sig/dodopayments/models/subscription_update_payment_method_webhook_event.rbs +35 -0
  70. data/sig/dodopayments/models/unsafe_unwrap_webhook_event.rbs +1 -0
  71. data/sig/dodopayments/models/unwrap_webhook_event.rbs +1 -0
  72. data/sig/dodopayments/models/webhook_event_type.rbs +2 -0
  73. data/sig/dodopayments/models.rbs +2 -0
  74. data/sig/dodopayments/resources/discounts.rbs +8 -0
  75. data/sig/dodopayments/resources/payments.rbs +1 -0
  76. data/sig/dodopayments/resources/subscriptions.rbs +1 -0
  77. data/sig/dodopayments/resources/webhooks.rbs +2 -0
  78. metadata +5 -2
@@ -48,6 +48,11 @@ module Dodopayments
48
48
  sig { returns(T::Array[Dodopayments::Dispute]) }
49
49
  attr_accessor :disputes
50
50
 
51
+ # Whether this payment was created solely to update a subscription's payment
52
+ # method (a zero-/setup-amount charge). `false` for normal charges.
53
+ sig { returns(T::Boolean) }
54
+ attr_accessor :is_update_payment_method
55
+
51
56
  # Additional custom data associated with the payment
52
57
  sig { returns(T::Hash[Symbol, Dodopayments::MetadataItem::Variants]) }
53
58
  attr_accessor :metadata
@@ -134,6 +139,22 @@ module Dodopayments
134
139
  sig { returns(T.nilable(String)) }
135
140
  attr_accessor :error_message
136
141
 
142
+ # Purpose-built failure messaging for the merchant and the customer, derived from
143
+ # `error_code`. Present whenever `error_code` is set, regardless of payment
144
+ # status; unrecognised codes still resolve via a generic fallback rather than
145
+ # being omitted. The customer copy is always generic for fraud-sensitive declines
146
+ # (lost/stolen/pickup/fraudulent) so the true reason is never leaked.
147
+ sig { returns(T.nilable(Dodopayments::Payment::FailureDetails)) }
148
+ attr_reader :failure_details
149
+
150
+ sig do
151
+ params(
152
+ failure_details:
153
+ T.nilable(Dodopayments::Payment::FailureDetails::OrHash)
154
+ ).void
155
+ end
156
+ attr_writer :failure_details
157
+
137
158
  # Invoice ID for this payment. Uses India-specific invoice ID if available.
138
159
  sig { returns(T.nilable(String)) }
139
160
  attr_accessor :invoice_id
@@ -150,6 +171,10 @@ module Dodopayments
150
171
  sig { returns(T.nilable(String)) }
151
172
  attr_accessor :payment_method
152
173
 
174
+ # Identifier of the saved payment method used for this payment, if any.
175
+ sig { returns(T.nilable(String)) }
176
+ attr_accessor :payment_method_id
177
+
153
178
  # Specific type of payment method (e.g. "visa", "mastercard")
154
179
  sig { returns(T.nilable(String)) }
155
180
  attr_accessor :payment_method_type
@@ -198,6 +223,7 @@ module Dodopayments
198
223
  customer: Dodopayments::CustomerLimitedDetails::OrHash,
199
224
  digital_products_delivered: T::Boolean,
200
225
  disputes: T::Array[Dodopayments::Dispute::OrHash],
226
+ is_update_payment_method: T::Boolean,
201
227
  metadata: T::Hash[Symbol, Dodopayments::MetadataItem::Variants],
202
228
  payment_id: String,
203
229
  payment_provider: Dodopayments::Payment::PaymentProvider::OrSymbol,
@@ -218,10 +244,13 @@ module Dodopayments
218
244
  discounts: T.nilable(T::Array[Dodopayments::DiscountDetail::OrHash]),
219
245
  error_code: T.nilable(String),
220
246
  error_message: T.nilable(String),
247
+ failure_details:
248
+ T.nilable(Dodopayments::Payment::FailureDetails::OrHash),
221
249
  invoice_id: T.nilable(String),
222
250
  invoice_url: T.nilable(String),
223
251
  payment_link: T.nilable(String),
224
252
  payment_method: T.nilable(String),
253
+ payment_method_id: T.nilable(String),
225
254
  payment_method_type: T.nilable(String),
226
255
  product_cart:
227
256
  T.nilable(T::Array[Dodopayments::Payment::ProductCart::OrHash]),
@@ -250,6 +279,9 @@ module Dodopayments
250
279
  digital_products_delivered:,
251
280
  # List of disputes associated with this payment
252
281
  disputes:,
282
+ # Whether this payment was created solely to update a subscription's payment
283
+ # method (a zero-/setup-amount charge). `false` for normal charges.
284
+ is_update_payment_method:,
253
285
  # Additional custom data associated with the payment
254
286
  metadata:,
255
287
  # Unique identifier for the payment
@@ -298,6 +330,12 @@ module Dodopayments
298
330
  error_code: nil,
299
331
  # An error message if the payment failed
300
332
  error_message: nil,
333
+ # Purpose-built failure messaging for the merchant and the customer, derived from
334
+ # `error_code`. Present whenever `error_code` is set, regardless of payment
335
+ # status; unrecognised codes still resolve via a generic fallback rather than
336
+ # being omitted. The customer copy is always generic for fraud-sensitive declines
337
+ # (lost/stolen/pickup/fraudulent) so the true reason is never leaked.
338
+ failure_details: nil,
301
339
  # Invoice ID for this payment. Uses India-specific invoice ID if available.
302
340
  invoice_id: nil,
303
341
  # URL to download the invoice PDF for this payment.
@@ -306,6 +344,8 @@ module Dodopayments
306
344
  payment_link: nil,
307
345
  # Payment method used by customer (e.g. "card", "bank_transfer")
308
346
  payment_method: nil,
347
+ # Identifier of the saved payment method used for this payment, if any.
348
+ payment_method_id: nil,
309
349
  # Specific type of payment method (e.g. "visa", "mastercard")
310
350
  payment_method_type: nil,
311
351
  # List of products purchased in a one-time payment
@@ -340,6 +380,7 @@ module Dodopayments
340
380
  customer: Dodopayments::CustomerLimitedDetails,
341
381
  digital_products_delivered: T::Boolean,
342
382
  disputes: T::Array[Dodopayments::Dispute],
383
+ is_update_payment_method: T::Boolean,
343
384
  metadata: T::Hash[Symbol, Dodopayments::MetadataItem::Variants],
344
385
  payment_id: String,
345
386
  payment_provider:
@@ -362,10 +403,12 @@ module Dodopayments
362
403
  discounts: T.nilable(T::Array[Dodopayments::DiscountDetail]),
363
404
  error_code: T.nilable(String),
364
405
  error_message: T.nilable(String),
406
+ failure_details: T.nilable(Dodopayments::Payment::FailureDetails),
365
407
  invoice_id: T.nilable(String),
366
408
  invoice_url: T.nilable(String),
367
409
  payment_link: T.nilable(String),
368
410
  payment_method: T.nilable(String),
411
+ payment_method_id: T.nilable(String),
369
412
  payment_method_type: T.nilable(String),
370
413
  product_cart:
371
414
  T.nilable(T::Array[Dodopayments::Payment::ProductCart]),
@@ -407,6 +450,328 @@ module Dodopayments
407
450
  end
408
451
  end
409
452
 
453
+ class FailureDetails < Dodopayments::Internal::Type::BaseModel
454
+ OrHash =
455
+ T.type_alias do
456
+ T.any(
457
+ Dodopayments::Payment::FailureDetails,
458
+ Dodopayments::Internal::AnyHash
459
+ )
460
+ end
461
+
462
+ # The unified error code (echoes `error_code`).
463
+ sig { returns(String) }
464
+ attr_accessor :code
465
+
466
+ # The primary CTA to show the customer.
467
+ sig do
468
+ returns(
469
+ Dodopayments::Payment::FailureDetails::CustomerCta::TaggedSymbol
470
+ )
471
+ end
472
+ attr_accessor :customer_cta
473
+
474
+ # Whether the customer can resolve this themselves (e.g. fix CVC).
475
+ sig { returns(T::Boolean) }
476
+ attr_accessor :customer_fixable
477
+
478
+ # The customer-facing string. Always generic (`C11`) for the fraud-4.
479
+ sig { returns(String) }
480
+ attr_accessor :customer_message
481
+
482
+ # The customer message template identifier (C1..C20).
483
+ sig do
484
+ returns(
485
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
486
+ )
487
+ end
488
+ attr_accessor :customer_template
489
+
490
+ # Soft or hard decline.
491
+ sig do
492
+ returns(
493
+ Dodopayments::Payment::FailureDetails::DeclineType::TaggedSymbol
494
+ )
495
+ end
496
+ attr_accessor :decline_type
497
+
498
+ # Merchant-facing headline + recommended action (Payment Details). For the fraud-4
499
+ # this includes the operator "do not reveal" warning.
500
+ sig { returns(String) }
501
+ attr_accessor :merchant_message
502
+
503
+ # Purpose-built failure messaging for the merchant and the customer, derived from
504
+ # `error_code`. Present whenever `error_code` is set, regardless of payment
505
+ # status; unrecognised codes still resolve via a generic fallback rather than
506
+ # being omitted. The customer copy is always generic for fraud-sensitive declines
507
+ # (lost/stolen/pickup/fraudulent) so the true reason is never leaked.
508
+ sig do
509
+ params(
510
+ code: String,
511
+ customer_cta:
512
+ Dodopayments::Payment::FailureDetails::CustomerCta::OrSymbol,
513
+ customer_fixable: T::Boolean,
514
+ customer_message: String,
515
+ customer_template:
516
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::OrSymbol,
517
+ decline_type:
518
+ Dodopayments::Payment::FailureDetails::DeclineType::OrSymbol,
519
+ merchant_message: String
520
+ ).returns(T.attached_class)
521
+ end
522
+ def self.new(
523
+ # The unified error code (echoes `error_code`).
524
+ code:,
525
+ # The primary CTA to show the customer.
526
+ customer_cta:,
527
+ # Whether the customer can resolve this themselves (e.g. fix CVC).
528
+ customer_fixable:,
529
+ # The customer-facing string. Always generic (`C11`) for the fraud-4.
530
+ customer_message:,
531
+ # The customer message template identifier (C1..C20).
532
+ customer_template:,
533
+ # Soft or hard decline.
534
+ decline_type:,
535
+ # Merchant-facing headline + recommended action (Payment Details). For the fraud-4
536
+ # this includes the operator "do not reveal" warning.
537
+ merchant_message:
538
+ )
539
+ end
540
+
541
+ sig do
542
+ override.returns(
543
+ {
544
+ code: String,
545
+ customer_cta:
546
+ Dodopayments::Payment::FailureDetails::CustomerCta::TaggedSymbol,
547
+ customer_fixable: T::Boolean,
548
+ customer_message: String,
549
+ customer_template:
550
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol,
551
+ decline_type:
552
+ Dodopayments::Payment::FailureDetails::DeclineType::TaggedSymbol,
553
+ merchant_message: String
554
+ }
555
+ )
556
+ end
557
+ def to_hash
558
+ end
559
+
560
+ # The primary CTA to show the customer.
561
+ module CustomerCta
562
+ extend Dodopayments::Internal::Type::Enum
563
+
564
+ TaggedSymbol =
565
+ T.type_alias do
566
+ T.all(Symbol, Dodopayments::Payment::FailureDetails::CustomerCta)
567
+ end
568
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
569
+
570
+ EDIT_AND_RETRY =
571
+ T.let(
572
+ :edit_and_retry,
573
+ Dodopayments::Payment::FailureDetails::CustomerCta::TaggedSymbol
574
+ )
575
+ USE_ANOTHER_METHOD =
576
+ T.let(
577
+ :use_another_method,
578
+ Dodopayments::Payment::FailureDetails::CustomerCta::TaggedSymbol
579
+ )
580
+ TRY_AGAIN =
581
+ T.let(
582
+ :try_again,
583
+ Dodopayments::Payment::FailureDetails::CustomerCta::TaggedSymbol
584
+ )
585
+ TRY_LATER =
586
+ T.let(
587
+ :try_later,
588
+ Dodopayments::Payment::FailureDetails::CustomerCta::TaggedSymbol
589
+ )
590
+ RETRY_AND_VERIFY =
591
+ T.let(
592
+ :retry_and_verify,
593
+ Dodopayments::Payment::FailureDetails::CustomerCta::TaggedSymbol
594
+ )
595
+ RESTART =
596
+ T.let(
597
+ :restart,
598
+ Dodopayments::Payment::FailureDetails::CustomerCta::TaggedSymbol
599
+ )
600
+ UPDATE_METHOD =
601
+ T.let(
602
+ :update_method,
603
+ Dodopayments::Payment::FailureDetails::CustomerCta::TaggedSymbol
604
+ )
605
+
606
+ sig do
607
+ override.returns(
608
+ T::Array[
609
+ Dodopayments::Payment::FailureDetails::CustomerCta::TaggedSymbol
610
+ ]
611
+ )
612
+ end
613
+ def self.values
614
+ end
615
+ end
616
+
617
+ # The customer message template identifier (C1..C20).
618
+ module CustomerTemplate
619
+ extend Dodopayments::Internal::Type::Enum
620
+
621
+ TaggedSymbol =
622
+ T.type_alias do
623
+ T.all(
624
+ Symbol,
625
+ Dodopayments::Payment::FailureDetails::CustomerTemplate
626
+ )
627
+ end
628
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
629
+
630
+ C1 =
631
+ T.let(
632
+ :C1,
633
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
634
+ )
635
+ C2 =
636
+ T.let(
637
+ :C2,
638
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
639
+ )
640
+ C3 =
641
+ T.let(
642
+ :C3,
643
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
644
+ )
645
+ C4 =
646
+ T.let(
647
+ :C4,
648
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
649
+ )
650
+ C5 =
651
+ T.let(
652
+ :C5,
653
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
654
+ )
655
+ C6 =
656
+ T.let(
657
+ :C6,
658
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
659
+ )
660
+ C7 =
661
+ T.let(
662
+ :C7,
663
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
664
+ )
665
+ C8 =
666
+ T.let(
667
+ :C8,
668
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
669
+ )
670
+ C9 =
671
+ T.let(
672
+ :C9,
673
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
674
+ )
675
+ C10 =
676
+ T.let(
677
+ :C10,
678
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
679
+ )
680
+ C11 =
681
+ T.let(
682
+ :C11,
683
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
684
+ )
685
+ C12 =
686
+ T.let(
687
+ :C12,
688
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
689
+ )
690
+ C13 =
691
+ T.let(
692
+ :C13,
693
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
694
+ )
695
+ C14 =
696
+ T.let(
697
+ :C14,
698
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
699
+ )
700
+ C15 =
701
+ T.let(
702
+ :C15,
703
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
704
+ )
705
+ C16 =
706
+ T.let(
707
+ :C16,
708
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
709
+ )
710
+ C17 =
711
+ T.let(
712
+ :C17,
713
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
714
+ )
715
+ C18 =
716
+ T.let(
717
+ :C18,
718
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
719
+ )
720
+ C19 =
721
+ T.let(
722
+ :C19,
723
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
724
+ )
725
+ C20 =
726
+ T.let(
727
+ :C20,
728
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
729
+ )
730
+
731
+ sig do
732
+ override.returns(
733
+ T::Array[
734
+ Dodopayments::Payment::FailureDetails::CustomerTemplate::TaggedSymbol
735
+ ]
736
+ )
737
+ end
738
+ def self.values
739
+ end
740
+ end
741
+
742
+ # Soft or hard decline.
743
+ module DeclineType
744
+ extend Dodopayments::Internal::Type::Enum
745
+
746
+ TaggedSymbol =
747
+ T.type_alias do
748
+ T.all(Symbol, Dodopayments::Payment::FailureDetails::DeclineType)
749
+ end
750
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
751
+
752
+ SOFT =
753
+ T.let(
754
+ :soft,
755
+ Dodopayments::Payment::FailureDetails::DeclineType::TaggedSymbol
756
+ )
757
+ HARD =
758
+ T.let(
759
+ :hard,
760
+ Dodopayments::Payment::FailureDetails::DeclineType::TaggedSymbol
761
+ )
762
+
763
+ sig do
764
+ override.returns(
765
+ T::Array[
766
+ Dodopayments::Payment::FailureDetails::DeclineType::TaggedSymbol
767
+ ]
768
+ )
769
+ end
770
+ def self.values
771
+ end
772
+ end
773
+ end
774
+
410
775
  class ProductCart < Dodopayments::Internal::Type::BaseModel
411
776
  OrHash =
412
777
  T.type_alias do