Class: ProcessOut::Refund
- Inherits:
-
Object
- Object
- ProcessOut::Refund
- Defined in:
- lib/processout/refund.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#information ⇒ Object
Returns the value of attribute information.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#reason ⇒ Object
Returns the value of attribute reason.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
-
#transaction ⇒ Object
Returns the value of attribute transaction.
Instance Method Summary collapse
-
#apply(transaction_id, options = nil) ⇒ Object
Apply a refund to a transaction.
-
#fill_with_data(data) ⇒ Object
- Fills the object with data coming from the API Params:
data -
Hashof data coming from the API.
- Fills the object with data coming from the API Params:
-
#find(transaction_id, refund_id, options = nil) ⇒ Object
Find a transaction’s refund by its ID.
-
#initialize(client) ⇒ Refund
constructor
- Initializes the Refund object Params:
client -
ProcessOutclient instance.
- Initializes the Refund object Params:
Constructor Details
#initialize(client) ⇒ Refund
Initializes the Refund object Params:
client-
ProcessOutclient instance
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/processout/refund.rb', line 63 def initialize(client) @client = client @id = "" @transaction = nil @reason = "" @information = "" @amount = "" = Hash.new @sandbox = false @created_at = "" end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
14 15 16 |
# File 'lib/processout/refund.rb', line 14 def amount @amount end |
#created_at ⇒ Object
Returns the value of attribute created_at.
17 18 19 |
# File 'lib/processout/refund.rb', line 17 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/processout/refund.rb', line 10 def id @id end |
#information ⇒ Object
Returns the value of attribute information.
13 14 15 |
# File 'lib/processout/refund.rb', line 13 def information @information end |
#metadata ⇒ Object
Returns the value of attribute metadata.
15 16 17 |
# File 'lib/processout/refund.rb', line 15 def end |
#reason ⇒ Object
Returns the value of attribute reason.
12 13 14 |
# File 'lib/processout/refund.rb', line 12 def reason @reason end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
16 17 18 |
# File 'lib/processout/refund.rb', line 16 def sandbox @sandbox end |
#transaction ⇒ Object
Returns the value of attribute transaction.
11 12 13 |
# File 'lib/processout/refund.rb', line 11 def transaction @transaction end |
Instance Method Details
#apply(transaction_id, options = nil) ⇒ Object
Apply a refund to a transaction. Params:
transaction_id-
ID of the transaction
options-
Hashof options
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/processout/refund.rb', line 140 def apply(transaction_id, = nil) request = Request.new(@client) path = "/transactions/" + CGI.escape(transaction_id) + "/refunds" data = { "amount": @amount, "metadata": , "reason": @reason, "information": @information } response = Response.new(request.post(path, data, )) return_values = Array.new return_values.push(response.success) return_values[0] end |
#fill_with_data(data) ⇒ Object
Fills the object with data coming from the API Params:
data-
Hashof data coming from the API
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/processout/refund.rb', line 80 def fill_with_data(data) if data.include? "id" @id = data["id"] end if data.include? "transaction" @transaction = data["transaction"] end if data.include? "reason" @reason = data["reason"] end if data.include? "information" @information = data["information"] end if data.include? "amount" @amount = data["amount"] end if data.include? "metadata" = data["metadata"] end if data.include? "sandbox" @sandbox = data["sandbox"] end if data.include? "created_at" @created_at = data["created_at"] end self end |
#find(transaction_id, refund_id, options = nil) ⇒ Object
Find a transaction’s refund by its ID. Params:
transaction_id-
ID of the transaction
refund_id-
ID of the refund
options-
Hashof options
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/processout/refund.rb', line 114 def find(transaction_id, refund_id, = nil) request = Request.new(@client) path = "/transactions/" + CGI.escape(transaction_id) + "/refunds/" + CGI.escape(refund_id) + "" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body body = body["refund"] obj = Refund.new(@client) return_values.push(obj.fill_with_data(body)) return_values[0] end |