Class: ProcessOut::Transaction
- Inherits:
-
Object
- Object
- ProcessOut::Transaction
- Defined in:
- lib/processout/transaction.rb
Instance Attribute Summary collapse
-
#authorized ⇒ Object
Returns the value of attribute authorized.
-
#authorized_amount ⇒ Object
Returns the value of attribute authorized_amount.
-
#captured ⇒ Object
Returns the value of attribute captured.
-
#captured_amount ⇒ Object
Returns the value of attribute captured_amount.
-
#card ⇒ Object
Returns the value of attribute card.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#estimated_fee ⇒ Object
Returns the value of attribute estimated_fee.
-
#gateway_fee ⇒ Object
Returns the value of attribute gateway_fee.
-
#id ⇒ Object
Returns the value of attribute id.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#processout_fee ⇒ Object
Returns the value of attribute processout_fee.
-
#project ⇒ Object
Returns the value of attribute project.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
-
#status ⇒ Object
Returns the value of attribute status.
-
#subscription ⇒ Object
Returns the value of attribute subscription.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Get all the transactions.
-
#fetch_refunds(options = {}) ⇒ Object
Get the transaction’s refunds.
-
#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, options = {}) ⇒ Object
Find a transaction by its ID.
-
#find_refund(refund_id, options = {}) ⇒ Object
Find a transaction’s refund by its ID.
-
#initialize(client, data = {}) ⇒ Transaction
constructor
- Initializes the Transaction object Params:
client ProcessOutclient instancedata-
data that can be used to fill the object.
- Initializes the Transaction object Params:
-
#new(data = {}) ⇒ Object
Create a new Transaction using the current client.
-
#prefill(data) ⇒ Object
- Prefills the object with the data passed as parameters Params:
data -
Hashof data.
- Prefills the object with the data passed as parameters Params:
Constructor Details
#initialize(client, data = {}) ⇒ Transaction
Initializes the Transaction object Params:
client-
ProcessOutclient instance data-
data that can be used to fill the object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/processout/transaction.rb', line 147 def initialize(client, data = {}) @client = client self.id = data.fetch(:id, nil) self.project = data.fetch(:project, nil) self.customer = data.fetch(:customer, nil) self.subscription = data.fetch(:subscription, nil) self.token = data.fetch(:token, nil) self.card = data.fetch(:card, nil) self.name = data.fetch(:name, nil) self. = data.fetch(:authorized_amount, nil) self.captured_amount = data.fetch(:captured_amount, nil) self.currency = data.fetch(:currency, nil) self.status = data.fetch(:status, nil) self. = data.fetch(:authorized, nil) self.captured = data.fetch(:captured, nil) self.processout_fee = data.fetch(:processout_fee, nil) self.estimated_fee = data.fetch(:estimated_fee, nil) self.gateway_fee = data.fetch(:gateway_fee, nil) self. = data.fetch(:metadata, nil) self.sandbox = data.fetch(:sandbox, nil) self.created_at = data.fetch(:created_at, nil) end |
Instance Attribute Details
#authorized ⇒ Object
Returns the value of attribute authorized.
21 22 23 |
# File 'lib/processout/transaction.rb', line 21 def end |
#authorized_amount ⇒ Object
Returns the value of attribute authorized_amount.
17 18 19 |
# File 'lib/processout/transaction.rb', line 17 def end |
#captured ⇒ Object
Returns the value of attribute captured.
22 23 24 |
# File 'lib/processout/transaction.rb', line 22 def captured @captured end |
#captured_amount ⇒ Object
Returns the value of attribute captured_amount.
18 19 20 |
# File 'lib/processout/transaction.rb', line 18 def captured_amount @captured_amount end |
#card ⇒ Object
Returns the value of attribute card.
15 16 17 |
# File 'lib/processout/transaction.rb', line 15 def card @card end |
#created_at ⇒ Object
Returns the value of attribute created_at.
28 29 30 |
# File 'lib/processout/transaction.rb', line 28 def created_at @created_at end |
#currency ⇒ Object
Returns the value of attribute currency.
19 20 21 |
# File 'lib/processout/transaction.rb', line 19 def currency @currency end |
#customer ⇒ Object
Returns the value of attribute customer.
12 13 14 |
# File 'lib/processout/transaction.rb', line 12 def customer @customer end |
#estimated_fee ⇒ Object
Returns the value of attribute estimated_fee.
24 25 26 |
# File 'lib/processout/transaction.rb', line 24 def estimated_fee @estimated_fee end |
#gateway_fee ⇒ Object
Returns the value of attribute gateway_fee.
25 26 27 |
# File 'lib/processout/transaction.rb', line 25 def gateway_fee @gateway_fee end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/processout/transaction.rb', line 10 def id @id end |
#metadata ⇒ Object
Returns the value of attribute metadata.
26 27 28 |
# File 'lib/processout/transaction.rb', line 26 def end |
#name ⇒ Object
Returns the value of attribute name.
16 17 18 |
# File 'lib/processout/transaction.rb', line 16 def name @name end |
#processout_fee ⇒ Object
Returns the value of attribute processout_fee.
23 24 25 |
# File 'lib/processout/transaction.rb', line 23 def processout_fee @processout_fee end |
#project ⇒ Object
Returns the value of attribute project.
11 12 13 |
# File 'lib/processout/transaction.rb', line 11 def project @project end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
27 28 29 |
# File 'lib/processout/transaction.rb', line 27 def sandbox @sandbox end |
#status ⇒ Object
Returns the value of attribute status.
20 21 22 |
# File 'lib/processout/transaction.rb', line 20 def status @status end |
#subscription ⇒ Object
Returns the value of attribute subscription.
13 14 15 |
# File 'lib/processout/transaction.rb', line 13 def subscription @subscription end |
#token ⇒ Object
Returns the value of attribute token.
14 15 16 |
# File 'lib/processout/transaction.rb', line 14 def token @token end |
Instance Method Details
#all(options = {}) ⇒ Object
Get all the transactions. Params:
options-
Hashof options
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/processout/transaction.rb', line 333 def all( = {}) self.prefill() request = Request.new(@client) path = "/transactions" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['transactions'] tmp = Transaction.new(@client) tmp.fill_with_data(v) a.push(tmp) end return_values.push(a) return_values[0] end |
#fetch_refunds(options = {}) ⇒ Object
Get the transaction’s refunds. Params:
options-
Hashof options
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/processout/transaction.rb', line 278 def fetch_refunds( = {}) self.prefill() request = Request.new(@client) path = "/transactions/" + CGI.escape(@id) + "/refunds" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['refunds'] tmp = Refund.new(@client) tmp.fill_with_data(v) a.push(tmp) end return_values.push(a) 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
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/processout/transaction.rb', line 180 def fill_with_data(data) if data.nil? return self end if data.include? "id" self.id = data["id"] end if data.include? "project" self.project = data["project"] end if data.include? "customer" self.customer = data["customer"] end if data.include? "subscription" self.subscription = data["subscription"] end if data.include? "token" self.token = data["token"] end if data.include? "card" self.card = data["card"] end if data.include? "name" self.name = data["name"] end if data.include? "authorized_amount" self. = data["authorized_amount"] end if data.include? "captured_amount" self.captured_amount = data["captured_amount"] end if data.include? "currency" self.currency = data["currency"] end if data.include? "status" self.status = data["status"] end if data.include? "authorized" self. = data["authorized"] end if data.include? "captured" self.captured = data["captured"] end if data.include? "processout_fee" self.processout_fee = data["processout_fee"] end if data.include? "estimated_fee" self.estimated_fee = data["estimated_fee"] end if data.include? "gateway_fee" self.gateway_fee = data["gateway_fee"] end if data.include? "metadata" self. = data["metadata"] end if data.include? "sandbox" self.sandbox = data["sandbox"] end if data.include? "created_at" self.created_at = data["created_at"] end self end |
#find(transaction_id, options = {}) ⇒ Object
Find a transaction by its ID. Params:
transaction_id-
ID of the transaction
options-
Hashof options
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File 'lib/processout/transaction.rb', line 364 def find(transaction_id, = {}) self.prefill() request = Request.new(@client) path = "/transactions/" + CGI.escape(transaction_id) + "" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body body = body["transaction"] obj = Transaction.new(@client) return_values.push(obj.fill_with_data(body)) return_values[0] end |
#find_refund(refund_id, options = {}) ⇒ Object
Find a transaction’s refund by its ID. Params:
refund_id-
ID of the refund
options-
Hashof options
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/processout/transaction.rb', line 309 def find_refund(refund_id, = {}) self.prefill() request = Request.new(@client) path = "/transactions/" + CGI.escape(@id) + "/refunds/" + CGI.escape(refund_id) + "" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body body = body["refund"] refund = Refund.new(@client) return_values.push(refund.fill_with_data(body)) return_values[0] end |
#new(data = {}) ⇒ Object
Create a new Transaction using the current client
173 174 175 |
# File 'lib/processout/transaction.rb', line 173 def new(data = {}) Transaction.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data-
Hashof data
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/processout/transaction.rb', line 248 def prefill(data) if data.nil? return self end self.id = data.fetch(:id, self.id) self.project = data.fetch(:project, self.project) self.customer = data.fetch(:customer, self.customer) self.subscription = data.fetch(:subscription, self.subscription) self.token = data.fetch(:token, self.token) self.card = data.fetch(:card, self.card) self.name = data.fetch(:name, self.name) self. = data.fetch(:authorized_amount, self.) self.captured_amount = data.fetch(:captured_amount, self.captured_amount) self.currency = data.fetch(:currency, self.currency) self.status = data.fetch(:status, self.status) self. = data.fetch(:authorized, self.) self.captured = data.fetch(:captured, self.captured) self.processout_fee = data.fetch(:processout_fee, self.processout_fee) self.estimated_fee = data.fetch(:estimated_fee, self.estimated_fee) self.gateway_fee = data.fetch(:gateway_fee, self.gateway_fee) self. = data.fetch(:metadata, self.) self.sandbox = data.fetch(:sandbox, self.sandbox) self.created_at = data.fetch(:created_at, self.created_at) self end |