module Wizypay::CardMethods

Public Instance Methods

base_path() click to toggle source
# File lib/wizypay/card_methods.rb, line 41
def base_path
  self.class.base_path
end
cancel() click to toggle source
# File lib/wizypay/card_methods.rb, line 45
def cancel
  ApiClient.post("#{base_path}/#{URI::encode_www_form_component reference}/cancel")
end
cancelled_at() click to toggle source
Calls superclass method
# File lib/wizypay/card_methods.rb, line 81
def cancelled_at
  return nil unless super.present?
  Time.parse(super)
end
created_at() click to toggle source
Calls superclass method
# File lib/wizypay/card_methods.rb, line 76
def created_at
  return nil unless super.present?
  Time.parse(super)
end
operations() click to toggle source
Calls superclass method
# File lib/wizypay/card_methods.rb, line 86
def operations
  Collection.new(VdcOperation, super['data'], super['meta'])
end
refund(amount) click to toggle source
# File lib/wizypay/card_methods.rb, line 49
def refund(amount)
  ApiClient.post("#{base_path}/#{URI::encode_www_form_component reference}/refund", amount: amount)
end
refunds() click to toggle source
Calls superclass method
# File lib/wizypay/card_methods.rb, line 90
def refunds
  Collection.new(Refund, super['data'], super['meta'])
end
save() click to toggle source
# File lib/wizypay/card_methods.rb, line 65
def save
  reinitialize ApiClient.post(base_path, to_h)
rescue => e
  begin
    cancel
  rescue RestClient::Exception
    #no-op
  end
  raise e
end
url() click to toggle source
# File lib/wizypay/card_methods.rb, line 53
def url
  timestamp    = Time.now.utc.httpdate
  security     = sign_string("#{reference}\n#{timestamp}", ApiClient.api_secret)
  query_string = {
      key:       ApiClient.api_key,
      timestamp: timestamp,
      reference: reference,
      security:  security
  }.map { |k, v| "#{k}=#{URI::encode_www_form_component(v)}" }.join('&')
  "#{ApiClient.api_endpoint}/widget?#{query_string}"
end