Class: Pago::V2026_04::Models::OrderCreate

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

Overview

Schema to create a draft order for an off-session charge.

Constant Summary collapse

JSON_KEYS =

Returns:

  • (Hash[Symbol, String])
{
  custom_field_data: "custom_field_data",
  metadata: "metadata",
  organization_id: "organization_id",
  customer_id: "customer_id",
  product_id: "product_id",
  currency: "currency",
  amount: "amount",
  description: "description"
}.freeze
REQUIRED_KEYS =

Returns:

  • (Array[String])
["customer_id", "product_id"].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(custom_field_data: ::Pago::UNSET, metadata: ::Pago::UNSET, organization_id: ::Pago::UNSET, customer_id:, product_id:, currency: ::Pago::UNSET, amount: ::Pago::UNSET, description: ::Pago::UNSET) ⇒ OrderCreate

Returns a new instance of OrderCreate.

Parameters:

  • custom_field_data: (Hash[String, untyped], nil) (defaults to: ::Pago::UNSET)
  • metadata: (Hash[String, untyped], nil) (defaults to: ::Pago::UNSET)
  • organization_id: (String, nil) (defaults to: ::Pago::UNSET)
  • customer_id: (String)
  • product_id: (String)
  • currency: (String, nil) (defaults to: ::Pago::UNSET)
  • amount: (Integer, nil) (defaults to: ::Pago::UNSET)
  • description: (String, nil) (defaults to: ::Pago::UNSET)


32234
32235
32236
32237
32238
32239
32240
32241
32242
32243
32244
32245
32246
32247
32248
32249
32250
32251
32252
32253
# File 'lib/pago/v2026_04/models.rb', line 32234

def initialize(
  custom_field_data: ::Pago::UNSET,
  metadata: ::Pago::UNSET,
  organization_id: ::Pago::UNSET,
  customer_id:,
  product_id:,
  currency: ::Pago::UNSET,
  amount: ::Pago::UNSET,
  description: ::Pago::UNSET
)
  super()
  assign(:custom_field_data, custom_field_data)
  assign(:metadata, )
  assign(:organization_id, organization_id)
  assign(:customer_id, customer_id)
  assign(:product_id, product_id)
  assign(:currency, currency)
  assign(:amount, amount)
  assign(:description, description)
end

Instance Attribute Details

#amountInteger? (readonly)

A custom amount to charge, in the smallest currency unit. Overrides the product's price; defaults to the product's configured price (0 for free products). A positive amount must be at least the currency's minimum.

Returns:

  • (Integer, nil)


32228
32229
32230
# File 'lib/pago/v2026_04/models.rb', line 32228

def amount
  @amount
end

#currencyString? (readonly)

The currency to charge in (ISO 4217, lowercase, e.g. usd). Defaults to the organization's default currency; specify it to force a different one, or when the product isn't priced in the organization's default currency.

Returns:

  • (String, nil)


32224
32225
32226
# File 'lib/pago/v2026_04/models.rb', line 32224

def currency
  @currency
end

#custom_field_dataHash{String => String, Integer, Boolean, nil} (readonly)

Key-value object storing custom field values.

Returns:

  • (Hash{String => String, Integer, Boolean, nil})


32194
32195
32196
# File 'lib/pago/v2026_04/models.rb', line 32194

def custom_field_data
  @custom_field_data
end

#customer_idString (readonly)

The ID of the customer the order is for. Must belong to the order's organization.

Returns:

  • (String)


32216
32217
32218
# File 'lib/pago/v2026_04/models.rb', line 32216

def customer_id
  @customer_id
end

#descriptionString? (readonly)

A custom description for the order's line item, shown on the invoice and receipt (e.g. 5,000 tokens). Defaults to the product name.

Returns:

  • (String, nil)


32232
32233
32234
# File 'lib/pago/v2026_04/models.rb', line 32232

def description
  @description
end

#metadataHash{String => String, Integer, Float, Boolean} (readonly)

Key-value object allowing you to store additional information.

The key must be a string with a maximum length of 40 characters. The value must be either:

  • A string with a maximum length of 500 characters
  • An integer
  • A floating-point number
  • A boolean

You can store up to 50 key-value pairs.

Returns:

  • (Hash{String => String, Integer, Float, Boolean})


32208
32209
32210
# File 'lib/pago/v2026_04/models.rb', line 32208

def 
  @metadata
end

#organization_idString? (readonly)

The ID of the organization the order belongs to. Required unless you use an organization token. The customer and product must belong to this organization.

Returns:

  • (String, nil)


32212
32213
32214
# File 'lib/pago/v2026_04/models.rb', line 32212

def organization_id
  @organization_id
end

#product_idString (readonly)

The ID of the one-time product to charge for. Must belong to the order's organization. Only fixed-price and free products are supported.

Returns:

  • (String)


32220
32221
32222
# File 'lib/pago/v2026_04/models.rb', line 32220

def product_id
  @product_id
end

Class Method Details

.from_json(data) ⇒ OrderCreate?

Parameters:

  • data (Hash, String, nil)

Returns:



32257
32258
32259
32260
32261
32262
32263
32264
32265
32266
32267
32268
32269
32270
32271
32272
32273
32274
32275
# File 'lib/pago/v2026_04/models.rb', line 32257

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(
      custom_field_data: (data.key?("custom_field_data") ? data["custom_field_data"] : ::Pago::UNSET),
      metadata: (data.key?("metadata") ? data["metadata"] : ::Pago::UNSET),
      organization_id: (data.key?("organization_id") ? data["organization_id"] : ::Pago::UNSET),
      customer_id: (data.key?("customer_id") ? data["customer_id"] : ::Pago::UNSET),
      product_id: (data.key?("product_id") ? data["product_id"] : ::Pago::UNSET),
      currency: (data.key?("currency") ? data["currency"] : ::Pago::UNSET),
      amount: (data.key?("amount") ? data["amount"] : ::Pago::UNSET),
      description: (data.key?("description") ? data["description"] : ::Pago::UNSET)
    ),
    data
  )
end