datatrans 4.0.0 → 4.0.1
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/CHANGELOG.md +3 -0
 - data/lib/datatrans/version.rb +1 -1
 - data/lib/datatrans/web/transaction/authorize.rb +6 -2
 - data/spec/web/authorize_spec.rb +20 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f0b065ed93895deb3f8b801fe1060246a21e597bf2b5d3373b502ea6ce6f1ead
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 94f5cd63b06ee0af246adf8dd30a16790fde64e68d22ca53cf005852cfaa4263
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 11c4e5483bbcc2d9833348934fc6b54c7af958a6c41d3cae7a183c4614df56c2e09bfd06b23746ade55e4482c5aa3493edd6d5a3c5eb8fa9fd0680f196f101d4
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c286baa29ea0d26186a864fdd6b5a133a36ebb8c780bfe4d1484db83f5c36aa715ce434b247e93baa80964e3e9612522308f81ede13f7954da6c2e953970c93d
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -5,6 +5,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            ## [Unreleased]
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
            ## 4.0.1 - 2022-03-18
         
     | 
| 
      
 9 
     | 
    
         
            +
            ### Fixed
         
     | 
| 
      
 10 
     | 
    
         
            +
            * Check for successful transaction depends on `status` and not on `response_message` that can be diferent for different payment methods (@schmijos [#8](https://github.com/simplificator/datatrans/pull/8) and @TatianaPan [#39](https://github.com/simplificator/datatrans/pull/39))
         
     | 
| 
       8 
11 
     | 
    
         
             
            ## 4.0.0 - 2022-02-25
         
     | 
| 
       9 
12 
     | 
    
         
             
            ### Changed
         
     | 
| 
       10 
13 
     | 
    
         
             
            * [BREAKING CHANGE] Bump minimum required Ruby version to 2.6 and Rails to 5.2 (@andyundso [#34](https://github.com/simplificator/datatrans/pull/34))
         
     | 
    
        data/lib/datatrans/version.rb
    CHANGED
    
    
| 
         @@ -9,7 +9,7 @@ class Datatrans::Web::Transaction 
     | 
|
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                def successful?
         
     | 
| 
       11 
11 
     | 
    
         
             
                  raise Datatrans::InvalidSignatureError unless valid_signature?
         
     | 
| 
       12 
     | 
    
         
            -
                  response_code == '01' &&  
     | 
| 
      
 12 
     | 
    
         
            +
                  response_code == '01' && status == 'success' && !errors_occurred?
         
     | 
| 
       13 
13 
     | 
    
         
             
                end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                def valid_signature?
         
     | 
| 
         @@ -18,6 +18,10 @@ class Datatrans::Web::Transaction 
     | 
|
| 
       18 
18 
     | 
    
         
             
                  sign(self.datatrans.merchant_id, params[:amount], params[:currency], params[:uppTransactionId]) == params[:sign2]
         
     | 
| 
       19 
19 
     | 
    
         
             
                end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
      
 21 
     | 
    
         
            +
                def status
         
     | 
| 
      
 22 
     | 
    
         
            +
                  params[:status] rescue nil
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       21 
25 
     | 
    
         
             
                def response_code
         
     | 
| 
       22 
26 
     | 
    
         
             
                  params[:responseCode] rescue nil
         
     | 
| 
       23 
27 
     | 
    
         
             
                end
         
     | 
| 
         @@ -79,4 +83,4 @@ class Datatrans::Web::Transaction 
     | 
|
| 
       79 
83 
     | 
    
         | 
| 
       80 
84 
     | 
    
         
             
                include Datatrans::Common
         
     | 
| 
       81 
85 
     | 
    
         
             
              end
         
     | 
| 
       82 
     | 
    
         
            -
            end
         
     | 
| 
      
 86 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/web/authorize_spec.rb
    CHANGED
    
    | 
         @@ -31,6 +31,12 @@ describe Datatrans::Web::Transaction do 
     | 
|
| 
       31 
31 
     | 
    
         
             
                  :acqAuthorizationCode => "173520"
         
     | 
| 
       32 
32 
     | 
    
         
             
                }
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
      
 34 
     | 
    
         
            +
                @successful_swisspost_response = @successful_response.merge({
         
     | 
| 
      
 35 
     | 
    
         
            +
                  :pmethod => "PFC",
         
     | 
| 
      
 36 
     | 
    
         
            +
                  :txtEp2TrxID => "7777777000000001",
         
     | 
| 
      
 37 
     | 
    
         
            +
                  :responseMessage => "YellowPay transaction Ok"
         
     | 
| 
      
 38 
     | 
    
         
            +
                })
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
       34 
40 
     | 
    
         
             
                @failed_response = {
         
     | 
| 
       35 
41 
     | 
    
         
             
                  :status => "error",
         
     | 
| 
       36 
42 
     | 
    
         
             
                  :returnCustomerCountry => "CHE",
         
     | 
| 
         @@ -78,7 +84,7 @@ describe Datatrans::Web::Transaction do 
     | 
|
| 
       78 
84 
     | 
    
         
             
                end
         
     | 
| 
       79 
85 
     | 
    
         | 
| 
       80 
86 
     | 
    
         
             
                it 'should generate valid form field string' do
         
     | 
| 
       81 
     | 
    
         
            -
                  if Gem.loaded_specs['activesupport'].version >= Gem::Version.create(' 
     | 
| 
      
 87 
     | 
    
         
            +
                  if Gem.loaded_specs['activesupport'].version >= Gem::Version.create('6.0')
         
     | 
| 
       82 
88 
     | 
    
         
             
                    expected_output = '<input type="hidden" name="merchantId" id="merchantId" value="1100000000" autocomplete="off" /><input type="hidden" name="hiddenMode" id="hiddenMode" value="yes" autocomplete="off" /><input type="hidden" name="reqtype" id="reqtype" value="NOA" autocomplete="off" /><input type="hidden" name="amount" id="amount" value="1000" autocomplete="off" /><input type="hidden" name="currency" id="currency" value="CHF" autocomplete="off" /><input type="hidden" name="useAlias" id="useAlias" value="yes" autocomplete="off" /><input type="hidden" name="sign" id="sign" value="0402fb3fba8c6fcb40df9b7756e7e637" autocomplete="off" /><input type="hidden" name="refno" id="refno" value="ABCDEF" autocomplete="off" /><input type="hidden" name="uppCustomerDetails" id="uppCustomerDetails" autocomplete="off" /><input type="hidden" name="uppCustomerEmail" id="uppCustomerEmail" value="customer@email.com" autocomplete="off" />'
         
     | 
| 
       83 
89 
     | 
    
         
             
                  else
         
     | 
| 
       84 
90 
     | 
    
         
             
                    expected_output = '<input type="hidden" name="merchantId" id="merchantId" value="1100000000" /><input type="hidden" name="hiddenMode" id="hiddenMode" value="yes" /><input type="hidden" name="reqtype" id="reqtype" value="NOA" /><input type="hidden" name="amount" id="amount" value="1000" /><input type="hidden" name="currency" id="currency" value="CHF" /><input type="hidden" name="useAlias" id="useAlias" value="yes" /><input type="hidden" name="sign" id="sign" value="0402fb3fba8c6fcb40df9b7756e7e637" /><input type="hidden" name="refno" id="refno" value="ABCDEF" /><input type="hidden" name="uppCustomerDetails" id="uppCustomerDetails" /><input type="hidden" name="uppCustomerEmail" id="uppCustomerEmail" value="customer@email.com" />'
         
     | 
| 
         @@ -101,6 +107,19 @@ describe Datatrans::Web::Transaction do 
     | 
|
| 
       101 
107 
     | 
    
         
             
                end
         
     | 
| 
       102 
108 
     | 
    
         
             
              end
         
     | 
| 
       103 
109 
     | 
    
         | 
| 
      
 110 
     | 
    
         
            +
              context "successful response (swiss post)" do
         
     | 
| 
      
 111 
     | 
    
         
            +
                before do
         
     | 
| 
      
 112 
     | 
    
         
            +
                  allow_any_instance_of(Datatrans::Web::Transaction::AuthorizeResponse).to receive(:params).and_return(@successful_swisspost_response)
         
     | 
| 
      
 113 
     | 
    
         
            +
                end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                context "process" do
         
     | 
| 
      
 116 
     | 
    
         
            +
                  it "handles a valid datatrans authorize response" do
         
     | 
| 
      
 117 
     | 
    
         
            +
                    @transaction = Datatrans::Web::Transaction.new(@datatrans, @valid_params)
         
     | 
| 
      
 118 
     | 
    
         
            +
                    expect(@transaction.authorize).to be true
         
     | 
| 
      
 119 
     | 
    
         
            +
                  end
         
     | 
| 
      
 120 
     | 
    
         
            +
                end
         
     | 
| 
      
 121 
     | 
    
         
            +
              end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
       104 
123 
     | 
    
         
             
              context "compromised response" do
         
     | 
| 
       105 
124 
     | 
    
         
             
                before do
         
     | 
| 
       106 
125 
     | 
    
         
             
                  fake_response = @successful_response
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: datatrans
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 4.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.0.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Tobias Miesel
         
     | 
| 
         @@ -11,7 +11,7 @@ authors: 
     | 
|
| 
       11 
11 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       13 
13 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       14 
     | 
    
         
            -
            date: 2022- 
     | 
| 
      
 14 
     | 
    
         
            +
            date: 2022-03-18 00:00:00.000000000 Z
         
     | 
| 
       15 
15 
     | 
    
         
             
            dependencies:
         
     | 
| 
       16 
16 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       17 
17 
     | 
    
         
             
              name: httparty
         
     |