Sha256: cbb3146cd46d0a2323bc82bdace69dcec6437c820b6f4af2b1536fda728a5893

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

module Platon
  class CallbackService
    class Error < Struct.new(:message)
      def success?
        false
      end
    end

    class << self
      def call(params)
        if params['sign'] == callback_signature(params).to_str
          Platon::Status.new(params['status'])
        else
          Error.new('Error: Invalid signature')
        end
      end

      private

      def callback_signature(params)
        Digest::MD5.hexdigest([
                                  params['email'].to_s.reverse,
                                  Platon::Configure.cfg.account_password,
                                  params['order'],
                                  (params['card'][0, 6] + params['card'][-4, 4]).reverse
                              ].map { |_| _.to_s.upcase }.join)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
platon.ua-1.0.1 app/services/platon/callback_service.rb