Class: Pago::V2026_04::Models::WebhookOrderCreatedPayload

Inherits:
Model
  • Object
show all
Defined in:
lib/pago/v2026_04/models.rb,
sig/pago/v2026_04/generated.rbs

Overview

Sent when a new order is created.

A new order is created when:

  • A customer purchases a one-time product. In this case, billing_reason is set to purchase.
  • A customer starts a subscription. In this case, billing_reason is set to subscription_create.
  • A subscription is renewed. In this case, billing_reason is set to subscription_cycle.
  • A subscription is upgraded or downgraded with an immediate proration invoice. In this case, billing_reason is set to subscription_update.

[!WARNING] The order might not be paid yet, so the status field might be pending.

Discord & Slack support: Full

Constant Summary collapse

JSON_KEYS =

Returns:

  • (Hash[Symbol, String])
{
  type: "type",
  timestamp: "timestamp",
  data: "data"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
["type", "timestamp", "data"].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#==, #[], #field_set?, #hash, #inspect, json_keys, required_json_keys, #to_json, #to_json_hash, wrap_raw

Constructor Details

#initialize(type:, timestamp:, data:) ⇒ WebhookOrderCreatedPayload

Returns a new instance of WebhookOrderCreatedPayload.

Parameters:



45448
45449
45450
45451
45452
45453
45454
45455
45456
45457
# File 'lib/pago/v2026_04/models.rb', line 45448

def initialize(
  type:,
  timestamp:,
  data:
)
  super()
  assign(:type, type)
  assign(:timestamp, timestamp)
  assign(:data, data)
end

Instance Attribute Details

#dataModels::Order (readonly)

Returns:



45446
45447
45448
# File 'lib/pago/v2026_04/models.rb', line 45446

def data
  @data
end

#timestampString (readonly)

Returns:

  • (String)


45443
45444
45445
# File 'lib/pago/v2026_04/models.rb', line 45443

def timestamp
  @timestamp
end

#typeString (readonly)

Returns:

  • (String)


45440
45441
45442
# File 'lib/pago/v2026_04/models.rb', line 45440

def type
  @type
end

Class Method Details

.from_json(data) ⇒ WebhookOrderCreatedPayload?

Parameters:

  • data (Hash, String, nil)

Returns:



45461
45462
45463
45464
45465
45466
45467
45468
45469
45470
45471
45472
45473
45474
# File 'lib/pago/v2026_04/models.rb', line 45461

def self.from_json(data)
  data = ::JSON.parse(data) if data.is_a?(String)
  data = ::Pago::Serde.object(data)
  return nil if data.nil?

  wrap_raw(
    new(
      type: (data.key?("type") ? data["type"] : ::Pago::UNSET),
      timestamp: (data.key?("timestamp") ? data["timestamp"] : ::Pago::UNSET),
      data: (data.key?("data") ? Models::Order.from_json(data["data"]) : ::Pago::UNSET)
    ),
    data
  )
end