Class: OffsitePayments::Integrations::Latipay::Interface
- Inherits:
-
Object
- Object
- OffsitePayments::Integrations::Latipay::Interface
show all
- Includes:
- ActiveUtils::PostsData
- Defined in:
- lib/offsite_payments/integrations/latipay.rb
Defined Under Namespace
Classes: RequestError
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(api_key, user_id) ⇒ Interface
Returns a new instance of Interface.
20
21
22
23
|
# File 'lib/offsite_payments/integrations/latipay.rb', line 20
def initialize(api_key, user_id)
@api_key = api_key
@user_id = user_id
end
|
Class Method Details
.base_url ⇒ Object
16
17
18
|
# File 'lib/offsite_payments/integrations/latipay.rb', line 16
def self.base_url
"https://api.latipay.net/v2"
end
|
Instance Method Details
#sign(fields) ⇒ Object
25
26
27
28
|
# File 'lib/offsite_payments/integrations/latipay.rb', line 25
def sign(fields)
message = fields.compact.sort.map{ |k,v| "#{k.to_s}=#{v}" }.join('&').concat(@api_key)
OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, @api_key, message)
end
|
#verify_signature(message, signature) ⇒ Object
30
31
32
|
# File 'lib/offsite_payments/integrations/latipay.rb', line 30
def verify_signature(message, signature)
signature == OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, @api_key, message)
end
|