Class: Zoop::PaymentMethodCommon

Inherits:
Model show all
Defined in:
lib/zoop/payment_method_common.rb

Direct Known Subclasses

BankAccount, Card

Constant Summary

Constants inherited from ZoopObject

ZoopObject::RESOURCES

Instance Attribute Summary

Attributes inherited from ZoopObject

#attributes

Instance Method Summary collapse

Methods inherited from Model

class_name, create, #destroy, find_by_id, #save, underscored_class_name, #update, url, #url

Methods inherited from ZoopObject

#==, #[]=, convert, #empty?, #initialize, #respond_to?, #to_hash, #to_s, #unsaved_attributes

Constructor Details

This class inherits a constructor from Zoop::ZoopObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Zoop::ZoopObject

Instance Method Details

#associate(customer_id) ⇒ Object

Raises:



12
13
14
15
# File 'lib/zoop/payment_method_common.rb', line 12

def associate(customer_id)
  raise RequestError.new('Invalid Token ID') unless token.present?
  self.class.associate(customer: customer_id.to_s, token: token.to_s)
end

#createObject



4
5
6
7
8
9
10
# File 'lib/zoop/payment_method_common.rb', line 4

def create
  return super if self.token.present?

  token = Zoop::Token.create(to_hash)
  token.payment_method.token = token.id
  token.payment_method
end