Class: Instamojo::Payment

Inherits:
Object
  • Object
show all
Includes:
CommonObject
Defined in:
lib/client/payment.rb

Overview

          "payment_id" => "MOJO3815000F72853519",
            "quantity" => 1,
              "status" => "Credit",
           "link_slug" => "demo-product",
          "link_title" => "Demo product",
          "buyer_name" => "",
         "buyer_phone" => "",
         "buyer_email" => "[email protected]",
            "currency" => "Free",
          "unit_price" => "0.00",
              "amount" => "0.00",
                "fees" => "0",
    "shipping_address" => nil,
       "shipping_city" => nil,
      "shipping_state" => nil,
        "shipping_zip" => nil,
    "shipping_country" => nil,
       "discount_code" => nil,
 "discount_amount_off" => nil,
            "variants" => [],
       "custom_fields" => {,
        "affiliate_id" => nil,
"affiliate_commission" => nil,
          "created_at" => "2013-08-15T13:16:24.629Z"

}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CommonObject

#assign_values, #construct_hash, included, #reload, #reload!, #to_h, #to_json

Constructor Details

#initialize(payment, client) ⇒ Payment

Returns a new instance of Payment.



41
42
43
44
# File 'lib/client/payment.rb', line 41

def initialize(payment, client)
  assign_values(payment)
  @client = client # Reference to client
end

Instance Attribute Details

#affiliate_commissionObject

Returns the value of attribute affiliate_commission.



35
36
37
# File 'lib/client/payment.rb', line 35

def affiliate_commission
  @affiliate_commission
end

#affiliate_idObject

Returns the value of attribute affiliate_id.



35
36
37
# File 'lib/client/payment.rb', line 35

def affiliate_id
  @affiliate_id
end

#amountObject

Returns the value of attribute amount.



34
35
36
# File 'lib/client/payment.rb', line 34

def amount
  @amount
end

#buyer_emailObject

Returns the value of attribute buyer_email.



33
34
35
# File 'lib/client/payment.rb', line 33

def buyer_email
  @buyer_email
end

#buyer_nameObject

Returns the value of attribute buyer_name.



33
34
35
# File 'lib/client/payment.rb', line 33

def buyer_name
  @buyer_name
end

#buyer_phoneObject

Returns the value of attribute buyer_phone.



33
34
35
# File 'lib/client/payment.rb', line 33

def buyer_phone
  @buyer_phone
end

#created_atObject

Returns the value of attribute created_at.



35
36
37
# File 'lib/client/payment.rb', line 35

def created_at
  @created_at
end

#currencyObject

Returns the value of attribute currency.



34
35
36
# File 'lib/client/payment.rb', line 34

def currency
  @currency
end

#custom_fieldsObject

Returns the value of attribute custom_fields.



35
36
37
# File 'lib/client/payment.rb', line 35

def custom_fields
  @custom_fields
end

#discount_amount_offObject

Returns the value of attribute discount_amount_off.



35
36
37
# File 'lib/client/payment.rb', line 35

def discount_amount_off
  @discount_amount_off
end

#discount_codeObject

Returns the value of attribute discount_code.



35
36
37
# File 'lib/client/payment.rb', line 35

def discount_code
  @discount_code
end

#feesObject

Returns the value of attribute fees.



34
35
36
# File 'lib/client/payment.rb', line 34

def fees
  @fees
end

Returns the value of attribute link_slug.



33
34
35
# File 'lib/client/payment.rb', line 33

def link_slug
  @link_slug
end

Returns the value of attribute link_title.



33
34
35
# File 'lib/client/payment.rb', line 33

def link_title
  @link_title
end

#originalObject (readonly)

Returns the value of attribute original.



37
38
39
# File 'lib/client/payment.rb', line 37

def original
  @original
end

#payment_idObject

Returns the value of attribute payment_id.



33
34
35
# File 'lib/client/payment.rb', line 33

def payment_id
  @payment_id
end

#quantityObject

Returns the value of attribute quantity.



33
34
35
# File 'lib/client/payment.rb', line 33

def quantity
  @quantity
end

#shipping_addressObject

Returns the value of attribute shipping_address.



34
35
36
# File 'lib/client/payment.rb', line 34

def shipping_address
  @shipping_address
end

#shipping_cityObject

Returns the value of attribute shipping_city.



34
35
36
# File 'lib/client/payment.rb', line 34

def shipping_city
  @shipping_city
end

#shipping_countryObject

Returns the value of attribute shipping_country.



35
36
37
# File 'lib/client/payment.rb', line 35

def shipping_country
  @shipping_country
end

#shipping_stateObject

Returns the value of attribute shipping_state.



34
35
36
# File 'lib/client/payment.rb', line 34

def shipping_state
  @shipping_state
end

#shipping_zipObject

Returns the value of attribute shipping_zip.



34
35
36
# File 'lib/client/payment.rb', line 34

def shipping_zip
  @shipping_zip
end

#statusObject

Returns the value of attribute status.



33
34
35
# File 'lib/client/payment.rb', line 33

def status
  @status
end

#unit_priceObject

Returns the value of attribute unit_price.



34
35
36
# File 'lib/client/payment.rb', line 34

def unit_price
  @unit_price
end

#variantsObject

Returns the value of attribute variants.



35
36
37
# File 'lib/client/payment.rb', line 35

def variants
  @variants
end

Instance Method Details

#process_refund(hash = {}, &block) ⇒ Object Also known as: create_refund

Process refund for this payment payment.process_refund(type: ‘QFL’, body: ‘Customer is not satisfied’)



48
49
50
51
# File 'lib/client/payment.rb', line 48

def process_refund(hash = {}, &block)
  hash[:payment_id] = self.payment_id
  @client.create_refund(hash, &block)
end

#to_sObject



53
54
55
56
# File 'lib/client/payment.rb', line 53

def to_s
  sprintf("Instamojo Payment(payment_id: %s, quantity: %s, amount: %s, status: %s, link_slug: %s, buyer_name: %s)",
          payment_id, quantity, amount, status, link_slug, buyer_name)
end