Class: Upay::Token
- Inherits:
-
Object
- Object
- Upay::Token
- Defined in:
- lib/upay/token.rb
Instance Method Summary collapse
- #code ⇒ Object
- #code=(code) ⇒ Object
- #create ⇒ Object
- #creditCardTokenId ⇒ Object
- #creditCardTokenId=(creditCardTokenId) ⇒ Object
- #destroy ⇒ Object
- #error ⇒ Object
- #error=(error) ⇒ Object
- #expirationDate ⇒ Object
- #expirationDate=(expirationDate) ⇒ Object
- #identificationNumber ⇒ Object
- #identificationNumber=(identificationNumber) ⇒ Object
-
#initialize(args = {}) ⇒ Token
constructor
A new instance of Token.
- #name ⇒ Object
- #name=(name) ⇒ Object
- #number ⇒ Object
- #number=(number) ⇒ Object
- #payerId ⇒ Object
- #payerId=(payerId) ⇒ Object
- #paymentMethod ⇒ Object
- #paymentMethod=(paymentMethod) ⇒ Object
- #show ⇒ Object
- #to_hash ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(args = {}) ⇒ Token
Returns a new instance of Token.
53 54 55 56 57 |
# File 'lib/upay/token.rb', line 53 def initialize(args = {}) args.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end |
Instance Method Details
#code ⇒ Object
13 |
# File 'lib/upay/token.rb', line 13 def code; @code end |
#code=(code) ⇒ Object
14 15 16 |
# File 'lib/upay/token.rb', line 14 def code=(code); @code = code end |
#create ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/upay/token.rb', line 59 def create data = {} data["creditCardToken"] = self.to_hash response = Requestor.new.request( PAYMENTS_API_URL, "CREATE_TOKEN", data) self.code = response["response"]["code"] self.error = response["response"]["error"] if response["response"]["error"] == nil self.creditCardTokenId = response["response"]["creditCardToken"]["creditCardTokenId"] end response end |
#creditCardTokenId ⇒ Object
43 |
# File 'lib/upay/token.rb', line 43 def creditCardTokenId; @creditCardTokenId end |
#creditCardTokenId=(creditCardTokenId) ⇒ Object
44 45 46 |
# File 'lib/upay/token.rb', line 44 def creditCardTokenId=(creditCardTokenId); @creditCardTokenId = creditCardTokenId end |
#destroy ⇒ Object
73 74 75 76 |
# File 'lib/upay/token.rb', line 73 def destroy data = {:removeCreditCardToken => { :payerId => self.payerId, :creditCardTokenId => self.creditCardTokenId}} response = Requestor.new.request( PAYMENTS_API_URL, "REMOVE_TOKEN", data) end |
#error ⇒ Object
18 |
# File 'lib/upay/token.rb', line 18 def error; @error end |
#error=(error) ⇒ Object
19 20 21 |
# File 'lib/upay/token.rb', line 19 def error=(error); @error = error end |
#expirationDate ⇒ Object
38 |
# File 'lib/upay/token.rb', line 38 def expirationDate; @expirationDate end |
#expirationDate=(expirationDate) ⇒ Object
39 40 41 |
# File 'lib/upay/token.rb', line 39 def expirationDate=(expirationDate); @expirationDate = expirationDate end |
#identificationNumber ⇒ Object
23 |
# File 'lib/upay/token.rb', line 23 def identificationNumber; @identificationNumber end |
#identificationNumber=(identificationNumber) ⇒ Object
24 25 26 |
# File 'lib/upay/token.rb', line 24 def identificationNumber=(identificationNumber); @identificationNumber = identificationNumber end |
#name ⇒ Object
8 |
# File 'lib/upay/token.rb', line 8 def name; @name end |
#name=(name) ⇒ Object
9 10 11 |
# File 'lib/upay/token.rb', line 9 def name=(name); @name = name end |
#number ⇒ Object
33 |
# File 'lib/upay/token.rb', line 33 def number; @number end |
#number=(number) ⇒ Object
34 35 36 |
# File 'lib/upay/token.rb', line 34 def number=(number); @number = number end |
#payerId ⇒ Object
3 |
# File 'lib/upay/token.rb', line 3 def payerId; @payerId end |
#payerId=(payerId) ⇒ Object
4 5 6 |
# File 'lib/upay/token.rb', line 4 def payerId=(payerId); @payerId = payerId end |
#paymentMethod ⇒ Object
28 |
# File 'lib/upay/token.rb', line 28 def paymentMethod; @paymentMethod end |
#paymentMethod=(paymentMethod) ⇒ Object
29 30 31 |
# File 'lib/upay/token.rb', line 29 def paymentMethod=(paymentMethod); @paymentMethod = paymentMethod end |
#show ⇒ Object
78 79 80 81 |
# File 'lib/upay/token.rb', line 78 def show data = {:removeCreditCardInformation => { :payerId => self.payerId, :creditCardTokenId => self.creditCardTokenId}} response = Requestor.new.request( PAYMENTS_API_URL, "GET_TOKENS", data) end |
#to_hash ⇒ Object
83 84 85 |
# File 'lib/upay/token.rb', line 83 def to_hash self.instance_variables.each_with_object({}) { |var,hash| hash[var.to_s.delete("@")] = self.instance_variable_get(var)} end |
#valid? ⇒ Boolean
48 49 50 51 |
# File 'lib/upay/token.rb', line 48 def valid? validator = TokenValidator.new validator.valid?(self) end |