Class: ProcessOut::Transaction
- Inherits:
-
Object
- Object
- ProcessOut::Transaction
- Defined in:
- lib/processout/transaction.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#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.
-
#card_id ⇒ Object
Returns the value of attribute card_id.
-
#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.
-
#customer_id ⇒ Object
Returns the value of attribute customer_id.
-
#error_code ⇒ Object
Returns the value of attribute error_code.
-
#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.
-
#invoice ⇒ Object
Returns the value of attribute invoice.
-
#invoice_id ⇒ Object
Returns the value of attribute invoice_id.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#operations ⇒ Object
Returns the value of attribute operations.
-
#processout_fee ⇒ Object
Returns the value of attribute processout_fee.
-
#project ⇒ Object
Returns the value of attribute project.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#refunds ⇒ Object
Returns the value of attribute refunds.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
-
#status ⇒ Object
Returns the value of attribute status.
-
#subscription ⇒ Object
Returns the value of attribute subscription.
-
#subscription_id ⇒ Object
Returns the value of attribute subscription_id.
-
#token ⇒ Object
Returns the value of attribute token.
-
#token_id ⇒ Object
Returns the value of attribute token_id.
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
271 272 273 274 275 276 277 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 304 305 |
# File 'lib/processout/transaction.rb', line 271 def initialize(client, data = {}) @client = client self.id = data.fetch(:id, nil) self.project = data.fetch(:project, nil) self.project_id = data.fetch(:project_id, nil) self.invoice = data.fetch(:invoice, nil) self.invoice_id = data.fetch(:invoice_id, nil) self.customer = data.fetch(:customer, nil) self.customer_id = data.fetch(:customer_id, nil) self.subscription = data.fetch(:subscription, nil) self.subscription_id = data.fetch(:subscription_id, nil) self.token = data.fetch(:token, nil) self.token_id = data.fetch(:token_id, nil) self.card = data.fetch(:card, nil) self.card_id = data.fetch(:card_id, nil) self.operations = data.fetch(:operations, nil) self.refunds = data.fetch(:refunds, nil) self.name = data.fetch(:name, nil) self.amount = data.fetch(:amount, nil) self. = data.fetch(:authorized_amount, nil) self.captured_amount = data.fetch(:captured_amount, nil) self.currency = data.fetch(:currency, nil) self.error_code = data.fetch(:error_code, 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
#amount ⇒ Object
Returns the value of attribute amount.
26 27 28 |
# File 'lib/processout/transaction.rb', line 26 def amount @amount end |
#authorized ⇒ Object
Returns the value of attribute authorized.
32 33 34 |
# File 'lib/processout/transaction.rb', line 32 def end |
#authorized_amount ⇒ Object
Returns the value of attribute authorized_amount.
27 28 29 |
# File 'lib/processout/transaction.rb', line 27 def end |
#captured ⇒ Object
Returns the value of attribute captured.
33 34 35 |
# File 'lib/processout/transaction.rb', line 33 def captured @captured end |
#captured_amount ⇒ Object
Returns the value of attribute captured_amount.
28 29 30 |
# File 'lib/processout/transaction.rb', line 28 def captured_amount @captured_amount end |
#card ⇒ Object
Returns the value of attribute card.
21 22 23 |
# File 'lib/processout/transaction.rb', line 21 def card @card end |
#card_id ⇒ Object
Returns the value of attribute card_id.
22 23 24 |
# File 'lib/processout/transaction.rb', line 22 def card_id @card_id end |
#created_at ⇒ Object
Returns the value of attribute created_at.
39 40 41 |
# File 'lib/processout/transaction.rb', line 39 def created_at @created_at end |
#currency ⇒ Object
Returns the value of attribute currency.
29 30 31 |
# File 'lib/processout/transaction.rb', line 29 def currency @currency end |
#customer ⇒ Object
Returns the value of attribute customer.
15 16 17 |
# File 'lib/processout/transaction.rb', line 15 def customer @customer end |
#customer_id ⇒ Object
Returns the value of attribute customer_id.
16 17 18 |
# File 'lib/processout/transaction.rb', line 16 def customer_id @customer_id end |
#error_code ⇒ Object
Returns the value of attribute error_code.
30 31 32 |
# File 'lib/processout/transaction.rb', line 30 def error_code @error_code end |
#estimated_fee ⇒ Object
Returns the value of attribute estimated_fee.
35 36 37 |
# File 'lib/processout/transaction.rb', line 35 def estimated_fee @estimated_fee end |
#gateway_fee ⇒ Object
Returns the value of attribute gateway_fee.
36 37 38 |
# File 'lib/processout/transaction.rb', line 36 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 |
#invoice ⇒ Object
Returns the value of attribute invoice.
13 14 15 |
# File 'lib/processout/transaction.rb', line 13 def invoice @invoice end |
#invoice_id ⇒ Object
Returns the value of attribute invoice_id.
14 15 16 |
# File 'lib/processout/transaction.rb', line 14 def invoice_id @invoice_id end |
#metadata ⇒ Object
Returns the value of attribute metadata.
37 38 39 |
# File 'lib/processout/transaction.rb', line 37 def end |
#name ⇒ Object
Returns the value of attribute name.
25 26 27 |
# File 'lib/processout/transaction.rb', line 25 def name @name end |
#operations ⇒ Object
Returns the value of attribute operations.
23 24 25 |
# File 'lib/processout/transaction.rb', line 23 def operations @operations end |
#processout_fee ⇒ Object
Returns the value of attribute processout_fee.
34 35 36 |
# File 'lib/processout/transaction.rb', line 34 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 |
#project_id ⇒ Object
Returns the value of attribute project_id.
12 13 14 |
# File 'lib/processout/transaction.rb', line 12 def project_id @project_id end |
#refunds ⇒ Object
Returns the value of attribute refunds.
24 25 26 |
# File 'lib/processout/transaction.rb', line 24 def refunds @refunds end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
38 39 40 |
# File 'lib/processout/transaction.rb', line 38 def sandbox @sandbox end |
#status ⇒ Object
Returns the value of attribute status.
31 32 33 |
# File 'lib/processout/transaction.rb', line 31 def status @status end |
#subscription ⇒ Object
Returns the value of attribute subscription.
17 18 19 |
# File 'lib/processout/transaction.rb', line 17 def subscription @subscription end |
#subscription_id ⇒ Object
Returns the value of attribute subscription_id.
18 19 20 |
# File 'lib/processout/transaction.rb', line 18 def subscription_id @subscription_id end |
#token ⇒ Object
Returns the value of attribute token.
19 20 21 |
# File 'lib/processout/transaction.rb', line 19 def token @token end |
#token_id ⇒ Object
Returns the value of attribute token_id.
20 21 22 |
# File 'lib/processout/transaction.rb', line 20 def token_id @token_id end |
Instance Method Details
#all(options = {}) ⇒ Object
Get all the transactions. Params:
options-
Hashof options
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
# File 'lib/processout/transaction.rb', line 512 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
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
# File 'lib/processout/transaction.rb', line 457 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
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 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 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
# File 'lib/processout/transaction.rb', line 315 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? "project_id" self.project_id = data["project_id"] end if data.include? "invoice" self.invoice = data["invoice"] end if data.include? "invoice_id" self.invoice_id = data["invoice_id"] end if data.include? "customer" self.customer = data["customer"] end if data.include? "customer_id" self.customer_id = data["customer_id"] end if data.include? "subscription" self.subscription = data["subscription"] end if data.include? "subscription_id" self.subscription_id = data["subscription_id"] end if data.include? "token" self.token = data["token"] end if data.include? "token_id" self.token_id = data["token_id"] end if data.include? "card" self.card = data["card"] end if data.include? "card_id" self.card_id = data["card_id"] end if data.include? "operations" self.operations = data["operations"] end if data.include? "refunds" self.refunds = data["refunds"] end if data.include? "name" self.name = data["name"] end if data.include? "amount" self.amount = data["amount"] 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? "error_code" self.error_code = data["error_code"] 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
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/processout/transaction.rb', line 543 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
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/processout/transaction.rb', line 488 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
308 309 310 |
# File 'lib/processout/transaction.rb', line 308 def new(data = {}) Transaction.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data-
Hashof data
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/processout/transaction.rb', line 416 def prefill(data) if data.nil? return self end self.id = data.fetch(:id, self.id) self.project = data.fetch(:project, self.project) self.project_id = data.fetch(:project_id, self.project_id) self.invoice = data.fetch(:invoice, self.invoice) self.invoice_id = data.fetch(:invoice_id, self.invoice_id) self.customer = data.fetch(:customer, self.customer) self.customer_id = data.fetch(:customer_id, self.customer_id) self.subscription = data.fetch(:subscription, self.subscription) self.subscription_id = data.fetch(:subscription_id, self.subscription_id) self.token = data.fetch(:token, self.token) self.token_id = data.fetch(:token_id, self.token_id) self.card = data.fetch(:card, self.card) self.card_id = data.fetch(:card_id, self.card_id) self.operations = data.fetch(:operations, self.operations) self.refunds = data.fetch(:refunds, self.refunds) self.name = data.fetch(:name, self.name) self.amount = data.fetch(:amount, self.amount) self. = data.fetch(:authorized_amount, self.) self.captured_amount = data.fetch(:captured_amount, self.captured_amount) self.currency = data.fetch(:currency, self.currency) self.error_code = data.fetch(:error_code, self.error_code) 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 |