Class: ProcessOut::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/processout/card.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data = {}) ⇒ Card

Initializes the Card object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/processout/card.rb', line 227

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.token = data.fetch(:token, nil)
  self.scheme = data.fetch(:scheme, nil)
  self.co_scheme = data.fetch(:co_scheme, nil)
  self.preferred_scheme = data.fetch(:preferred_scheme, nil)
  self.type = data.fetch(:type, nil)
  self.bank_name = data.fetch(:bank_name, nil)
  self.brand = data.fetch(:brand, nil)
  self.category = data.fetch(:category, nil)
  self.iin = data.fetch(:iin, nil)
  self.last_4_digits = data.fetch(:last_4_digits, nil)
  self.exp_month = data.fetch(:exp_month, nil)
  self.exp_year = data.fetch(:exp_year, nil)
  self.cvc_check = data.fetch(:cvc_check, nil)
  self.avs_check = data.fetch(:avs_check, nil)
  self.name = data.fetch(:name, nil)
  self.address1 = data.fetch(:address1, nil)
  self.address2 = data.fetch(:address2, nil)
  self.city = data.fetch(:city, nil)
  self.state = data.fetch(:state, nil)
  self.zip = data.fetch(:zip, nil)
  self.country_code = data.fetch(:country_code, nil)
  self.billing_country_code = data.fetch(:billing_country_code, nil)
  self.ip_address = data.fetch(:ip_address, nil)
  self.fingerprint = data.fetch(:fingerprint, nil)
  self.token_type = data.fetch(:token_type, nil)
  self.used = data.fetch(:used, nil)
  self.has_been_authorized = data.fetch(:has_been_authorized, nil)
  self. = data.fetch(:metadata, nil)
  self.expires_soon = data.fetch(:expires_soon, nil)
  self.sandbox = data.fetch(:sandbox, nil)
  self.created_at = data.fetch(:created_at, nil)
  self.preferred_card_type = data.fetch(:preferred_card_type, nil)
  self.initial_scheme_transaction_id = data.fetch(:initial_scheme_transaction_id, nil)
  self. = data.fetch(:payment_account_reference, nil)
  
end

Instance Attribute Details

#address1Object

Returns the value of attribute address1.



29
30
31
# File 'lib/processout/card.rb', line 29

def address1
  @address1
end

#address2Object

Returns the value of attribute address2.



30
31
32
# File 'lib/processout/card.rb', line 30

def address2
  @address2
end

#avs_checkObject

Returns the value of attribute avs_check.



27
28
29
# File 'lib/processout/card.rb', line 27

def avs_check
  @avs_check
end

#bank_nameObject

Returns the value of attribute bank_name.



19
20
21
# File 'lib/processout/card.rb', line 19

def bank_name
  @bank_name
end

#billing_country_codeObject

Returns the value of attribute billing_country_code.



35
36
37
# File 'lib/processout/card.rb', line 35

def billing_country_code
  @billing_country_code
end

#brandObject

Returns the value of attribute brand.



20
21
22
# File 'lib/processout/card.rb', line 20

def brand
  @brand
end

#categoryObject

Returns the value of attribute category.



21
22
23
# File 'lib/processout/card.rb', line 21

def category
  @category
end

#cityObject

Returns the value of attribute city.



31
32
33
# File 'lib/processout/card.rb', line 31

def city
  @city
end

#co_schemeObject

Returns the value of attribute co_scheme.



16
17
18
# File 'lib/processout/card.rb', line 16

def co_scheme
  @co_scheme
end

#country_codeObject

Returns the value of attribute country_code.



34
35
36
# File 'lib/processout/card.rb', line 34

def country_code
  @country_code
end

#created_atObject

Returns the value of attribute created_at.



44
45
46
# File 'lib/processout/card.rb', line 44

def created_at
  @created_at
end

#cvc_checkObject

Returns the value of attribute cvc_check.



26
27
28
# File 'lib/processout/card.rb', line 26

def cvc_check
  @cvc_check
end

#exp_monthObject

Returns the value of attribute exp_month.



24
25
26
# File 'lib/processout/card.rb', line 24

def exp_month
  @exp_month
end

#exp_yearObject

Returns the value of attribute exp_year.



25
26
27
# File 'lib/processout/card.rb', line 25

def exp_year
  @exp_year
end

#expires_soonObject

Returns the value of attribute expires_soon.



42
43
44
# File 'lib/processout/card.rb', line 42

def expires_soon
  @expires_soon
end

#fingerprintObject

Returns the value of attribute fingerprint.



37
38
39
# File 'lib/processout/card.rb', line 37

def fingerprint
  @fingerprint
end

#has_been_authorizedObject

Returns the value of attribute has_been_authorized.



40
41
42
# File 'lib/processout/card.rb', line 40

def has_been_authorized
  @has_been_authorized
end

#idObject

Returns the value of attribute id.



11
12
13
# File 'lib/processout/card.rb', line 11

def id
  @id
end

#iinObject

Returns the value of attribute iin.



22
23
24
# File 'lib/processout/card.rb', line 22

def iin
  @iin
end

#initial_scheme_transaction_idObject

Returns the value of attribute initial_scheme_transaction_id.



46
47
48
# File 'lib/processout/card.rb', line 46

def initial_scheme_transaction_id
  @initial_scheme_transaction_id
end

#ip_addressObject

Returns the value of attribute ip_address.



36
37
38
# File 'lib/processout/card.rb', line 36

def ip_address
  @ip_address
end

#last_4_digitsObject

Returns the value of attribute last_4_digits.



23
24
25
# File 'lib/processout/card.rb', line 23

def last_4_digits
  @last_4_digits
end

#metadataObject

Returns the value of attribute metadata.



41
42
43
# File 'lib/processout/card.rb', line 41

def 
  @metadata
end

#nameObject

Returns the value of attribute name.



28
29
30
# File 'lib/processout/card.rb', line 28

def name
  @name
end

#payment_account_referenceObject

Returns the value of attribute payment_account_reference.



47
48
49
# File 'lib/processout/card.rb', line 47

def 
  @payment_account_reference
end

#preferred_card_typeObject

Returns the value of attribute preferred_card_type.



45
46
47
# File 'lib/processout/card.rb', line 45

def preferred_card_type
  @preferred_card_type
end

#preferred_schemeObject

Returns the value of attribute preferred_scheme.



17
18
19
# File 'lib/processout/card.rb', line 17

def preferred_scheme
  @preferred_scheme
end

#projectObject

Returns the value of attribute project.



12
13
14
# File 'lib/processout/card.rb', line 12

def project
  @project
end

#project_idObject

Returns the value of attribute project_id.



13
14
15
# File 'lib/processout/card.rb', line 13

def project_id
  @project_id
end

#sandboxObject

Returns the value of attribute sandbox.



43
44
45
# File 'lib/processout/card.rb', line 43

def sandbox
  @sandbox
end

#schemeObject

Returns the value of attribute scheme.



15
16
17
# File 'lib/processout/card.rb', line 15

def scheme
  @scheme
end

#stateObject

Returns the value of attribute state.



32
33
34
# File 'lib/processout/card.rb', line 32

def state
  @state
end

#tokenObject

Returns the value of attribute token.



14
15
16
# File 'lib/processout/card.rb', line 14

def token
  @token
end

#token_typeObject

Returns the value of attribute token_type.



38
39
40
# File 'lib/processout/card.rb', line 38

def token_type
  @token_type
end

#typeObject

Returns the value of attribute type.



18
19
20
# File 'lib/processout/card.rb', line 18

def type
  @type
end

#usedObject

Returns the value of attribute used.



39
40
41
# File 'lib/processout/card.rb', line 39

def used
  @used
end

#zipObject

Returns the value of attribute zip.



33
34
35
# File 'lib/processout/card.rb', line 33

def zip
  @zip
end

Instance Method Details

#all(options = {}) ⇒ Object

Get all the cards. Params:

options

Hash of options



491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'lib/processout/card.rb', line 491

def all(options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/cards"
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  a    = Array.new
  body = response.body
  for v in body['cards']
    tmp = Card.new(@client)
    tmp.fill_with_data(v)
    a.push(tmp)
  end

  return_values.push(a)
  

  
  return_values[0]
end

#anonymize(options = {}) ⇒ Object

Anonymize the card. Params:

options

Hash of options



549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
# File 'lib/processout/card.rb', line 549

def anonymize(options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/cards/" + CGI.escape(@id) + ""
  data    = {

  }

  response = Response.new(request.delete(path, data, options))
  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

Hash of data coming from the API



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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/processout/card.rb', line 321

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? "token"
    self.token = data["token"]
  end
  if data.include? "scheme"
    self.scheme = data["scheme"]
  end
  if data.include? "co_scheme"
    self.co_scheme = data["co_scheme"]
  end
  if data.include? "preferred_scheme"
    self.preferred_scheme = data["preferred_scheme"]
  end
  if data.include? "type"
    self.type = data["type"]
  end
  if data.include? "bank_name"
    self.bank_name = data["bank_name"]
  end
  if data.include? "brand"
    self.brand = data["brand"]
  end
  if data.include? "category"
    self.category = data["category"]
  end
  if data.include? "iin"
    self.iin = data["iin"]
  end
  if data.include? "last_4_digits"
    self.last_4_digits = data["last_4_digits"]
  end
  if data.include? "exp_month"
    self.exp_month = data["exp_month"]
  end
  if data.include? "exp_year"
    self.exp_year = data["exp_year"]
  end
  if data.include? "cvc_check"
    self.cvc_check = data["cvc_check"]
  end
  if data.include? "avs_check"
    self.avs_check = data["avs_check"]
  end
  if data.include? "name"
    self.name = data["name"]
  end
  if data.include? "address1"
    self.address1 = data["address1"]
  end
  if data.include? "address2"
    self.address2 = data["address2"]
  end
  if data.include? "city"
    self.city = data["city"]
  end
  if data.include? "state"
    self.state = data["state"]
  end
  if data.include? "zip"
    self.zip = data["zip"]
  end
  if data.include? "country_code"
    self.country_code = data["country_code"]
  end
  if data.include? "billing_country_code"
    self.billing_country_code = data["billing_country_code"]
  end
  if data.include? "ip_address"
    self.ip_address = data["ip_address"]
  end
  if data.include? "fingerprint"
    self.fingerprint = data["fingerprint"]
  end
  if data.include? "token_type"
    self.token_type = data["token_type"]
  end
  if data.include? "used"
    self.used = data["used"]
  end
  if data.include? "has_been_authorized"
    self.has_been_authorized = data["has_been_authorized"]
  end
  if data.include? "metadata"
    self. = data["metadata"]
  end
  if data.include? "expires_soon"
    self.expires_soon = data["expires_soon"]
  end
  if data.include? "sandbox"
    self.sandbox = data["sandbox"]
  end
  if data.include? "created_at"
    self.created_at = data["created_at"]
  end
  if data.include? "preferred_card_type"
    self.preferred_card_type = data["preferred_card_type"]
  end
  if data.include? "initial_scheme_transaction_id"
    self.initial_scheme_transaction_id = data["initial_scheme_transaction_id"]
  end
  if data.include? "payment_account_reference"
    self. = data["payment_account_reference"]
  end
  
  self
end

#find(card_id, options = {}) ⇒ Object

Find a card by its ID. Params:

card_id

ID of the card

options

Hash of options



522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/processout/card.rb', line 522

def find(card_id, options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/cards/" + CGI.escape(card_id) + ""
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  body = response.body
  body = body.key?("card") ? body["card"] : nil
  
  
  obj = Card.new(@client)
  return_values.push(obj.fill_with_data(body))
  

  
  return_values[0]
end

#new(data = {}) ⇒ Object

Create a new Card using the current client



271
272
273
# File 'lib/processout/card.rb', line 271

def new(data = {})
  Card.new(@client, data)
end

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



443
444
445
446
447
448
449
450
451
452
453
454
455
456
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
483
484
485
486
# File 'lib/processout/card.rb', line 443

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.token = data.fetch(:token, self.token)
  self.scheme = data.fetch(:scheme, self.scheme)
  self.co_scheme = data.fetch(:co_scheme, self.co_scheme)
  self.preferred_scheme = data.fetch(:preferred_scheme, self.preferred_scheme)
  self.type = data.fetch(:type, self.type)
  self.bank_name = data.fetch(:bank_name, self.bank_name)
  self.brand = data.fetch(:brand, self.brand)
  self.category = data.fetch(:category, self.category)
  self.iin = data.fetch(:iin, self.iin)
  self.last_4_digits = data.fetch(:last_4_digits, self.last_4_digits)
  self.exp_month = data.fetch(:exp_month, self.exp_month)
  self.exp_year = data.fetch(:exp_year, self.exp_year)
  self.cvc_check = data.fetch(:cvc_check, self.cvc_check)
  self.avs_check = data.fetch(:avs_check, self.avs_check)
  self.name = data.fetch(:name, self.name)
  self.address1 = data.fetch(:address1, self.address1)
  self.address2 = data.fetch(:address2, self.address2)
  self.city = data.fetch(:city, self.city)
  self.state = data.fetch(:state, self.state)
  self.zip = data.fetch(:zip, self.zip)
  self.country_code = data.fetch(:country_code, self.country_code)
  self.billing_country_code = data.fetch(:billing_country_code, self.billing_country_code)
  self.ip_address = data.fetch(:ip_address, self.ip_address)
  self.fingerprint = data.fetch(:fingerprint, self.fingerprint)
  self.token_type = data.fetch(:token_type, self.token_type)
  self.used = data.fetch(:used, self.used)
  self.has_been_authorized = data.fetch(:has_been_authorized, self.has_been_authorized)
  self. = data.fetch(:metadata, self.)
  self.expires_soon = data.fetch(:expires_soon, self.expires_soon)
  self.sandbox = data.fetch(:sandbox, self.sandbox)
  self.created_at = data.fetch(:created_at, self.created_at)
  self.preferred_card_type = data.fetch(:preferred_card_type, self.preferred_card_type)
  self.initial_scheme_transaction_id = data.fetch(:initial_scheme_transaction_id, self.initial_scheme_transaction_id)
  self. = data.fetch(:payment_account_reference, self.)
  
  self
end

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



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
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/processout/card.rb', line 276

def to_json(options)
  {
      "id": self.id,
      "project": self.project,
      "project_id": self.project_id,
      "token": self.token,
      "scheme": self.scheme,
      "co_scheme": self.co_scheme,
      "preferred_scheme": self.preferred_scheme,
      "type": self.type,
      "bank_name": self.bank_name,
      "brand": self.brand,
      "category": self.category,
      "iin": self.iin,
      "last_4_digits": self.last_4_digits,
      "exp_month": self.exp_month,
      "exp_year": self.exp_year,
      "cvc_check": self.cvc_check,
      "avs_check": self.avs_check,
      "name": self.name,
      "address1": self.address1,
      "address2": self.address2,
      "city": self.city,
      "state": self.state,
      "zip": self.zip,
      "country_code": self.country_code,
      "billing_country_code": self.billing_country_code,
      "ip_address": self.ip_address,
      "fingerprint": self.fingerprint,
      "token_type": self.token_type,
      "used": self.used,
      "has_been_authorized": self.has_been_authorized,
      "metadata": self.,
      "expires_soon": self.expires_soon,
      "sandbox": self.sandbox,
      "created_at": self.created_at,
      "preferred_card_type": self.preferred_card_type,
      "initial_scheme_transaction_id": self.initial_scheme_transaction_id,
      "payment_account_reference": self.,
  }.to_json
end