Class: GoCardlessPro::Resources::Refund

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

Overview

Refund objects represent (partial) refunds of a [payment](#core-endpoints-payments) back to the [customer](#core-endpoints-customers).

GoCardless will notify you via a [webhook](#appendix-webhooks) whenever a refund is created, and will update the ‘amount_refunded` property of the payment.

Defined Under Namespace

Classes: Links

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, response = nil) ⇒ Refund

Initialize a refund resource instance

Parameters:

  • object (Hash)

    an object returned from the API



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gocardless_pro/resources/refund.rb', line 34

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

  @amount = object['amount']
  @created_at = object['created_at']
  @currency = object['currency']
  @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/refund.rb', line 23

def amount
  @amount
end

#created_atObject (readonly)

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



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

def currency
  @currency
end

#fxObject (readonly)

Returns the value of attribute fx.



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

def fx
  @fx
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



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

def 
  @metadata
end

#referenceObject (readonly)

Returns the value of attribute reference.



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

def reference
  @reference
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#api_responseObject



49
50
51
# File 'lib/gocardless_pro/resources/refund.rb', line 49

def api_response
  ApiResponse.new(@response)
end

Return the links that the resource has



54
55
56
# File 'lib/gocardless_pro/resources/refund.rb', line 54

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

#to_hObject

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



59
60
61
# File 'lib/gocardless_pro/resources/refund.rb', line 59

def to_h
  @object
end