lib/scanpay.rb
# handlePing: Convert body to JSON and validate signature
Convert body to JSON and validate signature
Convert body to JSON and validate signature
def handlePing(body='', signature='')
      digest = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), @apikey, body)
      is_valid = timesafe_equals(Base64.strict_encode64(digest), signature)
      raise 'invalid signature' unless is_valid
      o = JSON.parse(body)
      return o if (o['shopid'].is_a? Integer) && (o['seq'].is_a? Integer)
      raise 'invalid ping'
    end
def handlePing ( body = '' , signature = '' ) digest = OpenSSL :: HMAC . digest ( OpenSSL :: Digest . new ( 'sha256' ) , @apikey , body ) is_valid = timesafe_equals ( Base64 . strict_encode64 ( digest ) , signature ) raise 'invalid signature' unless is_valid o = JSON . parse ( body ) return o if ( o [ 'shopid' ] . is_a? Integer ) && ( o [ 'seq' ] . is_a? Integer ) raise 'invalid ping' end
handlePing: Convert body to JSON and validate signature
handlePing : Convert body to JSON and validate signature
body
<not_specific>
signature
<not_specific>