Class: FatZebra::Models::Card

Inherits:
Base
  • Object
show all
Defined in:
lib/fat_zebra/models/card.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attribute, #initialize, #inspect, #to_s

Constructor Details

This class inherits a constructor from FatZebra::Models::Base

Class Method Details

.create(card_holder, card_number, expiry, cvv, optional = {}) ⇒ Object

Tokenizes a credit card

Parameters:

  • the (String)

    credit card holder name

  • the (String)

    card number

  • the (String)

    credit card expiry date (mm/yyyy)

  • the (String)

    card CVV

  • optional (Hash) (defaults to: {})

    any additional data which should be merged into the request

Returns:

  • Response



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fat_zebra/models/card.rb', line 18

def create(card_holder, card_number, expiry, cvv, optional = {})
  params = {
    :card_holder => card_holder,
    :card_number => card_number,
    :card_expiry => expiry,
    :cvv => cvv
  }

  params.merge!(optional)
  
  response = FatZebra.gateway.make_request(:post, "credit_cards", params)
  Response.new(response, :card)
end

.update_expiry(token, expiry) ⇒ Response

Update the credit card expiry date

Parameters:

  • token (String)

    the credit card token

  • expiry (String)

    the new expiry date (format: mm/yyyy)

Returns:



38
39
40
41
42
43
44
45
# File 'lib/fat_zebra/models/card.rb', line 38

def update_expiry(token, expiry)
  params = {
          card_expiry: expiry
  }

  response = FatZebra.gateway.make_request(:put, "credit_cards/#{token}", params)
  Response.new(response, :card)
end

Instance Method Details

#successfulObject



6
# File 'lib/fat_zebra/models/card.rb', line 6

def successful; true; end