Module: Wizypay::CardMethods
- Includes:
- SimpleHmac::Helper
- Defined in:
- lib/wizypay/card_methods.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #base_path ⇒ Object
- #cancel ⇒ Object
- #created_at ⇒ Object
- #operations ⇒ Object
- #refund(amount) ⇒ Object
- #refunds ⇒ Object
- #save ⇒ Object
- #url ⇒ Object
Instance Method Details
#base_path ⇒ Object
41 42 43 |
# File 'lib/wizypay/card_methods.rb', line 41 def base_path self.class.base_path end |
#cancel ⇒ Object
45 46 47 |
# File 'lib/wizypay/card_methods.rb', line 45 def cancel ApiClient.post("#{base_path}/#{URI::encode_www_form_component reference}/cancel") end |
#created_at ⇒ Object
76 77 78 79 |
# File 'lib/wizypay/card_methods.rb', line 76 def created_at return nil unless super.present? Time.parse(super) end |
#operations ⇒ Object
81 82 83 |
# File 'lib/wizypay/card_methods.rb', line 81 def operations Collection.new(VdcOperation, super['data'], super['meta']) end |
#refund(amount) ⇒ Object
49 50 51 |
# 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 ⇒ Object
85 86 87 |
# File 'lib/wizypay/card_methods.rb', line 85 def refunds Collection.new(Refund, super['data'], super['meta']) end |
#save ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# 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 ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/wizypay/card_methods.rb', line 53 def url = Time.now.utc.httpdate security = sign_string("#{reference}\n#{}", ApiClient.api_secret) query_string = { key: ApiClient.api_key, timestamp: , reference: reference, security: security }.map { |k, v| "#{k}=#{URI::encode_www_form_component(v)}" }.join('&') "#{ApiClient.api_endpoint}/widget?#{query_string}" end |