Class: Dodopayments::Models::Payment::Discount

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/dodopayments/models/payment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, fields, hash, #hash, inherited, inspect, #inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, #inspect, inspect, meta_info, new_coerce_state, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize(billing:, brand_id:, business_id:, created_at:, currency:, customer:, digital_products_delivered:, disputes:, metadata:, payment_id:, refunds:, settlement_amount:, settlement_currency:, total_amount:, card_holder_name: nil, card_issuing_country: nil, card_last_four: nil, card_network: nil, card_type: nil, checkout_session_id: nil, custom_field_responses: nil, discount_id: nil, discounts: nil, error_code: nil, error_message: nil, invoice_id: nil, invoice_url: nil, payment_link: nil, payment_method: nil, payment_method_type: nil, product_cart: nil, refund_status: nil, settlement_tax: nil, status: nil, subscription_id: nil, tax: nil, updated_at: nil) ⇒ Object

Some parameter documentations has been truncated, see Dodopayments::Models::Payment for more details.

Parameters:

  • billing (Dodopayments::Models::BillingAddress)

    Billing address details for payments

  • brand_id (String)

    brand id this payment belongs to

  • business_id (String)

    Identifier of the business associated with the payment

  • created_at (Time)

    Timestamp when the payment was created

  • currency (Symbol, Dodopayments::Models::Currency)

    Currency used for the payment

  • customer (Dodopayments::Models::CustomerLimitedDetails)

    Details about the customer who made the payment

  • digital_products_delivered (Boolean)

    brand id this payment belongs to

  • disputes (Array<Dodopayments::Models::Dispute>)

    List of disputes associated with this payment

  • metadata (Hash{Symbol=>String})

    Additional custom data associated with the payment

  • payment_id (String)

    Unique identifier for the payment

  • refunds (Array<Dodopayments::Models::RefundListItem>)

    List of refunds issued for this payment

  • settlement_amount (Integer)

    The amount that will be credited to your Dodo balance after currency conversion

  • settlement_currency (Symbol, Dodopayments::Models::Currency)

    The currency in which the settlement_amount will be credited to your Dodo balanc

  • total_amount (Integer)

    Total amount charged to the customer including tax, in smallest currency unit (e

  • card_holder_name (String, nil) (defaults to: nil)

    Cardholder name

  • card_issuing_country (Symbol, Dodopayments::Models::CountryCode, nil) (defaults to: nil)

    ISO2 country code of the card

  • card_last_four (String, nil) (defaults to: nil)

    The last four digits of the card

  • card_network (String, nil) (defaults to: nil)

    Card network like VISA, MASTERCARD etc.

  • card_type (String, nil) (defaults to: nil)

    The type of card DEBIT or CREDIT

  • checkout_session_id (String, nil) (defaults to: nil)

    If payment is made using a checkout session,

  • custom_field_responses (Array<Dodopayments::Models::CustomFieldResponse>, nil) (defaults to: nil)

    Customer’s responses to custom fields collected during checkout

  • discount_id (String, nil) (defaults to: nil)

    DEPRECATED: Use discounts instead. Returns the first discount’s ID if present.

  • discounts (Array<Dodopayments::Models::Payment::Discount>, nil) (defaults to: nil)

    All stacked discounts applied, ordered by position

  • error_code (String, nil) (defaults to: nil)

    An error code if the payment failed

  • error_message (String, nil) (defaults to: nil)

    An error message if the payment failed

  • invoice_id (String, nil) (defaults to: nil)

    Invoice ID for this payment. Uses India-specific invoice ID if available.

  • invoice_url (String, nil) (defaults to: nil)

    URL to download the invoice PDF for this payment.

  • payment_link (String, nil) (defaults to: nil)

    Checkout URL

  • payment_method (String, nil) (defaults to: nil)

    Payment method used by customer (e.g. “card”, “bank_transfer”)

  • payment_method_type (String, nil) (defaults to: nil)

    Specific type of payment method (e.g. “visa”, “mastercard”)

  • product_cart (Array<Dodopayments::Models::Payment::ProductCart>, nil) (defaults to: nil)

    List of products purchased in a one-time payment

  • refund_status (Symbol, Dodopayments::Models::PaymentRefundStatus, nil) (defaults to: nil)

    Summary of the refund status for this payment. None if no succeeded refunds exis

  • settlement_tax (Integer, nil) (defaults to: nil)

    This represents the portion of settlement_amount that corresponds to taxes colle

  • status (Symbol, Dodopayments::Models::IntentStatus, nil) (defaults to: nil)

    Current status of the payment intent

  • subscription_id (String, nil) (defaults to: nil)

    Identifier of the subscription if payment is part of a subscription

  • tax (Integer, nil) (defaults to: nil)

    Amount of tax collected in smallest currency unit (e.g. cents)

  • updated_at (Time, nil) (defaults to: nil)

    Timestamp when the payment was last updated



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'lib/dodopayments/models/payment.rb', line 324

class Discount < Dodopayments::Internal::Type::BaseModel
  # @!attribute amount
  #   The discount amount (basis points for percentage, USD cents for flat)
  #
  #   @return [Integer]
  required :amount, Integer

  # @!attribute business_id
  #   The business this discount belongs to
  #
  #   @return [String]
  required :business_id, String

  # @!attribute code
  #   The discount code
  #
  #   @return [String]
  required :code, String

  # @!attribute created_at
  #   Timestamp when the discount was created
  #
  #   @return [Time]
  required :created_at, Time

  # @!attribute discount_id
  #   The unique discount ID
  #
  #   @return [String]
  required :discount_id, String

  # @!attribute metadata
  #   Additional metadata
  #
  #   @return [Hash{Symbol=>String}]
  required :metadata, Dodopayments::Internal::Type::HashOf[String]

  # @!attribute position
  #   Position of this discount in the stack (0-based)
  #
  #   @return [Integer]
  required :position, Integer

  # @!attribute preserve_on_plan_change
  #   Whether this discount should be preserved when a subscription changes plans
  #
  #   @return [Boolean]
  required :preserve_on_plan_change, Dodopayments::Internal::Type::Boolean

  # @!attribute restricted_to
  #   List of product IDs to which this discount is restricted
  #
  #   @return [Array<String>]
  required :restricted_to, Dodopayments::Internal::Type::ArrayOf[String]

  # @!attribute times_used
  #   How many times this discount has been used
  #
  #   @return [Integer]
  required :times_used, Integer

  # @!attribute type
  #   The type of discount
  #
  #   @return [Symbol, Dodopayments::Models::DiscountType]
  required :type, enum: -> { Dodopayments::DiscountType }

  # @!attribute cycles_remaining
  #   Remaining billing cycles for this discount on this subscription (None for
  #   one-time payments)
  #
  #   @return [Integer, nil]
  optional :cycles_remaining, Integer, nil?: true

  # @!attribute expires_at
  #   Optional date/time after which discount is expired
  #
  #   @return [Time, nil]
  optional :expires_at, Time, nil?: true

  # @!attribute name
  #   Name for the Discount
  #
  #   @return [String, nil]
  optional :name, String, nil?: true

  # @!attribute subscription_cycles
  #   Number of subscription billing cycles this discount is valid for
  #
  #   @return [Integer, nil]
  optional :subscription_cycles, Integer, nil?: true

  # @!attribute usage_limit
  #   Usage limit for this discount, if any
  #
  #   @return [Integer, nil]
  optional :usage_limit, Integer, nil?: true

  # @!method initialize(amount:, business_id:, code:, created_at:, discount_id:, metadata:, position:, preserve_on_plan_change:, restricted_to:, times_used:, type:, cycles_remaining: nil, expires_at: nil, name: nil, subscription_cycles: nil, usage_limit: nil)
  #   Some parameter documentations has been truncated, see
  #   {Dodopayments::Models::Payment::Discount} for more details.
  #
  #   Response struct for a discount with its position in a stack and optional
  #   cycle-tracking information (for subscriptions).
  #
  #   @param amount [Integer] The discount amount (basis points for percentage, USD cents for flat)
  #
  #   @param business_id [String] The business this discount belongs to
  #
  #   @param code [String] The discount code
  #
  #   @param created_at [Time] Timestamp when the discount was created
  #
  #   @param discount_id [String] The unique discount ID
  #
  #   @param metadata [Hash{Symbol=>String}] Additional metadata
  #
  #   @param position [Integer] Position of this discount in the stack (0-based)
  #
  #   @param preserve_on_plan_change [Boolean] Whether this discount should be preserved when a subscription changes plans
  #
  #   @param restricted_to [Array<String>] List of product IDs to which this discount is restricted
  #
  #   @param times_used [Integer] How many times this discount has been used
  #
  #   @param type [Symbol, Dodopayments::Models::DiscountType] The type of discount
  #
  #   @param cycles_remaining [Integer, nil] Remaining billing cycles for this discount on this subscription (None for one-ti
  #
  #   @param expires_at [Time, nil] Optional date/time after which discount is expired
  #
  #   @param name [String, nil] Name for the Discount
  #
  #   @param subscription_cycles [Integer, nil] Number of subscription billing cycles this discount is valid for
  #
  #   @param usage_limit [Integer, nil] Usage limit for this discount, if any
end

Instance Attribute Details

#amountInteger

The discount amount (basis points for percentage, USD cents for flat)

Returns:

  • (Integer)


329
# File 'lib/dodopayments/models/payment.rb', line 329

required :amount, Integer

#business_idString

The business this discount belongs to

Returns:

  • (String)


335
# File 'lib/dodopayments/models/payment.rb', line 335

required :business_id, String

#codeString

The discount code

Returns:

  • (String)


341
# File 'lib/dodopayments/models/payment.rb', line 341

required :code, String

#created_atTime

Timestamp when the discount was created

Returns:

  • (Time)


347
# File 'lib/dodopayments/models/payment.rb', line 347

required :created_at, Time

#cycles_remainingInteger?

Remaining billing cycles for this discount on this subscription (None for one-time payments)

Returns:

  • (Integer, nil)


396
# File 'lib/dodopayments/models/payment.rb', line 396

optional :cycles_remaining, Integer, nil?: true

#discount_idString

The unique discount ID

Returns:

  • (String)


353
# File 'lib/dodopayments/models/payment.rb', line 353

required :discount_id, String

#expires_atTime?

Optional date/time after which discount is expired

Returns:

  • (Time, nil)


402
# File 'lib/dodopayments/models/payment.rb', line 402

optional :expires_at, Time, nil?: true

#metadataHash{Symbol=>String}

Additional metadata

Returns:

  • (Hash{Symbol=>String})


359
# File 'lib/dodopayments/models/payment.rb', line 359

required :metadata, Dodopayments::Internal::Type::HashOf[String]

#nameString?

Name for the Discount

Returns:

  • (String, nil)


408
# File 'lib/dodopayments/models/payment.rb', line 408

optional :name, String, nil?: true

#positionInteger

Position of this discount in the stack (0-based)

Returns:

  • (Integer)


365
# File 'lib/dodopayments/models/payment.rb', line 365

required :position, Integer

#preserve_on_plan_changeBoolean

Whether this discount should be preserved when a subscription changes plans

Returns:

  • (Boolean)


371
# File 'lib/dodopayments/models/payment.rb', line 371

required :preserve_on_plan_change, Dodopayments::Internal::Type::Boolean

#restricted_toArray<String>

List of product IDs to which this discount is restricted

Returns:

  • (Array<String>)


377
# File 'lib/dodopayments/models/payment.rb', line 377

required :restricted_to, Dodopayments::Internal::Type::ArrayOf[String]

#subscription_cyclesInteger?

Number of subscription billing cycles this discount is valid for

Returns:

  • (Integer, nil)


414
# File 'lib/dodopayments/models/payment.rb', line 414

optional :subscription_cycles, Integer, nil?: true

#times_usedInteger

How many times this discount has been used

Returns:

  • (Integer)


383
# File 'lib/dodopayments/models/payment.rb', line 383

required :times_used, Integer

#typeSymbol, Dodopayments::Models::DiscountType

The type of discount



389
# File 'lib/dodopayments/models/payment.rb', line 389

required :type, enum: -> { Dodopayments::DiscountType }

#usage_limitInteger?

Usage limit for this discount, if any

Returns:

  • (Integer, nil)


420
# File 'lib/dodopayments/models/payment.rb', line 420

optional :usage_limit, Integer, nil?: true