Class: GoCardlessPro::Resources::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/gocardless_pro/resources/payment.rb

Overview

Payment objects represent payments from a [customer](#core-endpoints-customers) to a [creditor](#core-endpoints-creditors), taken against a Direct Debit [mandate](#core-endpoints-mandates).

GoCardless will notify you via a [webhook](#appendix-webhooks) whenever the state of a payment changes.

Defined Under Namespace

Classes: Links

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, response = nil) ⇒ Payment

Initialize a payment resource instance

Parameters:

  • object (Hash)

    an object returned from the API



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gocardless_pro/resources/payment.rb', line 37

def initialize(object, response = nil)
  @object = object

  @amount = object['amount']
  @amount_refunded = object['amount_refunded']
  @charge_date = object['charge_date']
  @created_at = object['created_at']
  @currency = object['currency']
  @description = object['description']
  @fx = object['fx']
  @id = object['id']
  @links = object['links']
  @metadata = object['metadata']
  @reference = object['reference']
  @status = object['status']
  @response = response
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



23
24
25
# File 'lib/gocardless_pro/resources/payment.rb', line 23

def amount
  @amount
end

#amount_refundedObject (readonly)

Returns the value of attribute amount_refunded.



24
25
26
# File 'lib/gocardless_pro/resources/payment.rb', line 24

def amount_refunded
  @amount_refunded
end

#charge_dateObject (readonly)

Returns the value of attribute charge_date.



25
26
27
# File 'lib/gocardless_pro/resources/payment.rb', line 25

def charge_date
  @charge_date
end

#created_atObject (readonly)

Returns the value of attribute created_at.



26
27
28
# File 'lib/gocardless_pro/resources/payment.rb', line 26

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



27
28
29
# File 'lib/gocardless_pro/resources/payment.rb', line 27

def currency
  @currency
end

#descriptionObject (readonly)

Returns the value of attribute description.



28
29
30
# File 'lib/gocardless_pro/resources/payment.rb', line 28

def description
  @description
end

#fxObject (readonly)

Returns the value of attribute fx.



29
30
31
# File 'lib/gocardless_pro/resources/payment.rb', line 29

def fx
  @fx
end

#idObject (readonly)

Returns the value of attribute id.



30
31
32
# File 'lib/gocardless_pro/resources/payment.rb', line 30

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



31
32
33
# File 'lib/gocardless_pro/resources/payment.rb', line 31

def 
  @metadata
end

#referenceObject (readonly)

Returns the value of attribute reference.



32
33
34
# File 'lib/gocardless_pro/resources/payment.rb', line 32

def reference
  @reference
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#api_responseObject



55
56
57
# File 'lib/gocardless_pro/resources/payment.rb', line 55

def api_response
  ApiResponse.new(@response)
end

Return the links that the resource has



60
61
62
# File 'lib/gocardless_pro/resources/payment.rb', line 60

def links
  @payment_links ||= Links.new(@links)
end

#to_hObject

Provides the payment resource as a hash of all its readable attributes



65
66
67
# File 'lib/gocardless_pro/resources/payment.rb', line 65

def to_h
  @object
end