Class: Paypal::Payment::Request::Item

Inherits:
Base
  • Object
show all
Defined in:
lib/paypal/payment/request/item.rb

Instance Method Summary collapse

Methods included from Util

#==, formatted_amount, #numeric_attribute?, to_numeric

Constructor Details

#initialize(attributes = {}) ⇒ Item

Returns a new instance of Item.



6
7
8
9
# File 'lib/paypal/payment/request/item.rb', line 6

def initialize(attributes = {})
  super
  @quantity ||= 1
end

Instance Method Details

#to_params(parent_index, index = 0) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/paypal/payment/request/item.rb', line 11

def to_params(parent_index, index = 0)
  {
    :"L_PAYMENTREQUEST_#{parent_index}_NAME#{index}" => self.name,
    :"L_PAYMENTREQUEST_#{parent_index}_DESC#{index}" => self.description,
    :"L_PAYMENTREQUEST_#{parent_index}_AMT#{index}" => Util.formatted_amount(self.amount),
    :"L_PAYMENTREQUEST_#{parent_index}_NUMBER#{index}" => self.number,
    :"L_PAYMENTREQUEST_#{parent_index}_QTY#{index}" => self.quantity,
    :"L_PAYMENTREQUEST_#{parent_index}_ITEMCATEGORY#{index}" => self.category,
    :"L_PAYMENTREQUEST_#{parent_index}_ITEMURL#{index}" => self.url
  }.delete_if do |k, v|
    v.blank?
  end
end