class Minfraud::Components::Order

Order corresponds to the order object of a minFraud request.

@see dev.maxmind.com/minfraud/#Order_(/order)

Attributes

affiliate_id[RW]

The ID of the affiliate where the order is coming from. No specific format is required.

@return [String, nil]

amount[RW]

The total order amount for the transaction before taxes and discounts. The value must be at least 0 and at most 1e14 - 1.

@return [Float, nil]

currency[RW]

The ISO 4217 currency code for the currency used in the transaction.

@see en.wikipedia.org/wiki/ISO_4217

@return [String, nil]

discount_code[RW]

The discount code applied to the transaction. If multiple discount codes are used, please separate them with a comma.

@return [String, nil]

has_gift_message[RW]

Whether the purchaser included a gift message.

@return [Boolean, nil]

is_gift[RW]

Whether order was marked as a gift by the purchaser.

@return [Boolean, nil]

referrer_uri[RW]

The URI of the referring site for this order. Needs to be absolute and have a URI scheme such as https://.

@return [String, nil]

subaffiliate_id[RW]

The ID of the sub-affiliate where the order is coming from. No specific format is required.

@return [String, nil]

Public Class Methods

new(params = {}) click to toggle source

@param params [Hash] Hash of parameters. Each key/value should

correspond to one of the available attributes.
# File lib/minfraud/components/order.rb, line 60
def initialize(params = {})
  @amount           = params[:amount]
  @has_gift_message = params[:has_gift_message]
  @affiliate_id     = params[:affiliate_id]
  @subaffiliate_id  = params[:subaffiliate_id]
  @currency         = params[:currency]
  @discount_code    = params[:discount_code]
  @referrer_uri     = params[:referrer_uri]
  @is_gift          = params[:is_gift]

  validate
end

Private Instance Methods

validate() click to toggle source
# File lib/minfraud/components/order.rb, line 75
def validate
  return if !Minfraud.enable_validation

  validate_nonnegative_number('amount', @amount)
  validate_boolean('has_gift_message', @has_gift_message)
  validate_string('affiliate_id', 255, @affiliate_id)
  validate_string('subaffiliate_id', 255, @subaffiliate_id)
  validate_regex('currency', /\A[A-Z]{3}\z/, @currency)
  validate_string('discount_code', 255, @discount_code)
  validate_uri('referrer_uri', @referrer_uri)
  validate_boolean('is_gift', @is_gift)
end