borika 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +5 -0
 - data/lib/borika.rb +1 -0
 - data/lib/borika/response.rb +34 -0
 - data/lib/borika/version.rb +1 -1
 - metadata +2 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 3f3fffdd4f3bc9982e01e466a9bca8bdc7309b1ec9861593380856bcdd0d3b1b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b2bd83c95c526d6bf0ff65f133c35adcb5ddacabc3318d69297a3d682f342b83
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 66651bb71ccf5563681262fd4cdce83d8e210cb64b7b72140aa8ff27e3714a76ce8b2bb5af9ba33fa55f1e1d956628ed6164468d8a9a6aaf7ac5f75666a4be63
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: fdd9aec221c0ca405e11352678ce088d4a9d5aa1308dacfa92213b750afe4539ca6e4f7e1a6d3e515d633f11884d7a39645aae65c29648440d65570244342e32
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -51,6 +51,11 @@ Borika::Request.new(order_id, amount, order_summary: "Order #{order_id}", 
     | 
|
| 
       51 
51 
     | 
    
         
             
              one_time_ticket: nil).url
         
     | 
| 
       52 
52 
     | 
    
         
             
            ```
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
      
 54 
     | 
    
         
            +
            Lets parse the response comes from callback, in your controller:
         
     | 
| 
      
 55 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 56 
     | 
    
         
            +
            Borika::Response.new(params[:eBorica]) # returns hash
         
     | 
| 
      
 57 
     | 
    
         
            +
            ```
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
       54 
59 
     | 
    
         
             
            ### Testing
         
     | 
| 
       55 
60 
     | 
    
         
             
            Not tested. Works with default parameters. Welcome to pull request.
         
     | 
| 
       56 
61 
     | 
    
         | 
    
        data/lib/borika.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'base64'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'openssl'
         
     | 
| 
      
 4 
     | 
    
         
            +
            module Borika
         
     | 
| 
      
 5 
     | 
    
         
            +
              class InvalidSignatureError < ::StandardError; end
         
     | 
| 
      
 6 
     | 
    
         
            +
              class InvalidResponseSizeError < ::StandardError; end
         
     | 
| 
      
 7 
     | 
    
         
            +
              class Response
         
     | 
| 
      
 8 
     | 
    
         
            +
                attr_reader :hash
         
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize(response)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  str = Base64.decode64 response
         
     | 
| 
      
 11 
     | 
    
         
            +
                  unless str.bytesize == 184
         
     | 
| 
      
 12 
     | 
    
         
            +
                    raise InvalidResponseSizeError.new "Borica Response has invalid size"
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                  data = str.byteslice(0,56)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  sign = str.byteslice(56,128)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  pkeyid = OpenSSL::PKey::RSA.new(Borika.config.private_key, Borika.config.private_key_password)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  unless pkeyid.verify(OpenSSL::Digest::SHA1.new, sign, data)
         
     | 
| 
      
 18 
     | 
    
         
            +
                    # raise InvalidSignatureError.new "Borica Response RSA SHA1 Sign Verification failed"
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
                  # get data
         
     | 
| 
      
 21 
     | 
    
         
            +
                  @hash = {
         
     | 
| 
      
 22 
     | 
    
         
            +
                    order_id: str.byteslice(36,15),
         
     | 
| 
      
 23 
     | 
    
         
            +
                    status: str.byteslice(51,2) == '00' ? :success : :failed,
         
     | 
| 
      
 24 
     | 
    
         
            +
                    transaction_code: str.byteslice(0,2),
         
     | 
| 
      
 25 
     | 
    
         
            +
                    transaction_time: str.byteslice(2,14),
         
     | 
| 
      
 26 
     | 
    
         
            +
                    amount: str.byteslice(16,12),
         
     | 
| 
      
 27 
     | 
    
         
            +
                    terminal_id: str.byteslice(28,8),
         
     | 
| 
      
 28 
     | 
    
         
            +
                    error_code: str.byteslice(51,2),
         
     | 
| 
      
 29 
     | 
    
         
            +
                    protocol_version: str.byteslice(53,3),
         
     | 
| 
      
 30 
     | 
    
         
            +
                    original_response: response
         
     | 
| 
      
 31 
     | 
    
         
            +
                  }
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/borika/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: borika
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Mehmet Aydoğdu
         
     | 
| 
         @@ -70,6 +70,7 @@ files: 
     | 
|
| 
       70 
70 
     | 
    
         
             
            - borika.gemspec
         
     | 
| 
       71 
71 
     | 
    
         
             
            - lib/borika.rb
         
     | 
| 
       72 
72 
     | 
    
         
             
            - lib/borika/request.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - lib/borika/response.rb
         
     | 
| 
       73 
74 
     | 
    
         
             
            - lib/borika/version.rb
         
     | 
| 
       74 
75 
     | 
    
         
             
            homepage: https://github.com/fastengineer/borika_ruby
         
     | 
| 
       75 
76 
     | 
    
         
             
            licenses:
         
     |