Sha256: d64f0b5e9e681663b09e0ab17d54dd04bfabf208533dcc038bfd153e3f76ad22

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

module IdealMollie
  #
  # Object representing a "Order" object with attributes provided by Mollie
  #
  # @example
  #   Order.new({
  #     :transaction_id => "c9f93e5c2bd6c1e7c5bee5c5580c6f83"
  #     :amount => "1000",
  #     :currency => "EUR"
  #     :url => "https://www.abnamro.nl/nl/ideal/identification.do?randomizedstring=8433910909&trxid=30000217841224"
  #     :message => "Your iDEAL-payment has successfully been setup. Your customer should visit the given URL to make the payment"
  #   })
  #
  # @note The amount is always specified in *cents*. So 10,00 EUR would be 1000.
  class Order
    # @return [String] A unique id generated by Mollie.
    attr_accessor :transaction_id
    # @return [int] The amount of money for the transaction.
    attr_accessor :amount
    # @return [String] The currency for the transaction.
    attr_accessor :currency
    # @return [String] The url to the bank, to complete payment.
    attr_accessor :url
    # @return [String] A message with additional information about the Order.
    attr_accessor :message

    #
    # Initializer to transform a +Hash+ into an Order object
    #
    # @param [Hash] values
    def initialize(values=nil)
      return if values.nil?

      @transaction_id = values["transaction_id"].to_s if values.has_key?("transaction_id")
      @amount = values["amount"].to_i if values.has_key?("amount")
      @currency = values["currency"].to_s if values.has_key?("currency")
      @url = values["URL"].to_s if values.has_key?("URL")
      @message = values["message"].to_s if values.has_key?("message")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ideal-mollie-0.0.3 lib/ideal-mollie/order.rb