pagarme 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19db5c088393486c4bc44af6ee169fb3a50a37f5
4
- data.tar.gz: 33157926082f202f8affcc8dc8093831d1acb37e
3
+ metadata.gz: 947c7bc9fea07b5bb4b9c89ab75ef72a7691c264
4
+ data.tar.gz: a6f0985e22ccb24a41e59a9804a04a8e8f3f1fff
5
5
  SHA512:
6
- metadata.gz: 438ca7c4e957ac3561b4663b899fbbccbd7d3c6bbaa4dbaff918307a6cac1ce2fd08025e8476936306c5bd7073a3ab3de0099fa3ea5e0fd5e10426292a20e261
7
- data.tar.gz: 4b61661fd23f341dcd0194019693021aba613b1ab62934565ee136cb7078180befb4df5734f25680d85b897011cda19edaded58916e73dd3ef984eb27287d60c
6
+ metadata.gz: c5a0a905cd64a05a92445205f3e0b5ebe1e3ed6526fce832bff1ffda03b3bf3c61cdeb5956ba9ea1fae9fda5b0a2cf116765d854c62be0633c99570c942d1b81
7
+ data.tar.gz: 58eb341a89fee732876a75eb28e62be22654fafd0ff92c69acdc456711c1b4ed82722e5c2c887343ba8dce3cc48948f68a11c7108d48e77fff92a53a4880baad
@@ -1,7 +1,7 @@
1
1
  module PagarMe
2
2
  class Postback < PagarMeObject
3
3
  def valid?
4
- signature == self.class.signature(payload)
4
+ self.class.valid_request_signature? payload, signature
5
5
  end
6
6
 
7
7
  class << self
@@ -1,3 +1,3 @@
1
1
  module PagarMe
2
- VERSION = '2.1.1'
2
+ VERSION = '2.1.2'
3
3
  end
@@ -122,7 +122,7 @@ class Fixtures
122
122
  def postback_response
123
123
  {
124
124
  payload: "id=406483&fingerprint=9e9496ef28d1154b2db9a446323db90103069330&event=transaction_status_changed&old_status=processing&desired_status=paid&current_status=paid&object=transaction&transaction[object]=transaction&transaction[status]=paid&transaction[refuse_reason]=null&transaction[status_reason]=acquirer&transaction[acquirer_response_code]=0&transaction[acquirer_name]=pagarme&transaction[authorization_code]=18051&transaction[soft_descriptor]=null&transaction[tid]=406483&transaction[nsu]=406483&transaction[date_created]=2016-03-03T19:13:31.000Z&transaction[date_updated]=2016-03-03T19:13:32.000Z&transaction[amount]=1000&transaction[authorized_amount]=1000&transaction[paid_amount]=1000&transaction[refunded_amount]=0&transaction[installments]=1&transaction[id]=406483&transaction[cost]=50&transaction[card_holder_name]=Jose da Silva&transaction[card_last_digits]=4448&transaction[card_first_digits]=490172&transaction[card_brand]=visa&transaction[postback_url]=http://example.com/postback/1&transaction[payment_method]=credit_card&transaction[capture_method]=ecommerce&transaction[antifraud_score]=null&transaction[boleto_url]=null&transaction[boleto_barcode]=null&transaction[boleto_expiration_date]=null&transaction[referer]=api_key&transaction[ip]=179.185.132.108&transaction[subscription_id]=null&transaction[phone][object]=phone&transaction[phone][ddi]=55&transaction[phone][ddd]=21&transaction[phone][number]=922334455&transaction[phone][id]=21123&transaction[address][object]=address&transaction[address][street]=Av. Brigadeiro Faria Lima&transaction[address][complementary]=null&transaction[address][street_number]=2941&transaction[address][neighborhood]=Itaim bibi&transaction[address][city]=São Paulo&transaction[address][state]=SP&transaction[address][zipcode]=1452000&transaction[address][country]=Brasil&transaction[address][id]=21810&transaction[customer][object]=customer&transaction[customer][document_number]=84931126235&transaction[customer][document_type]=cpf&transaction[customer][name]=Jose da Silva&transaction[customer][email]=pagarmetestruby@mailinator.com&transaction[customer][born_at]=1970-10-11T00:00:00.000Z&transaction[customer][gender]=M&transaction[customer][date_created]=2016-03-01T18:38:25.000Z&transaction[customer][id]=43304&transaction[card][object]=card&transaction[card][id]=card_cil9rcdql00gmbp6er9i5q48u&transaction[card][date_created]=2016-03-01T18:38:25.000Z&transaction[card][date_updated]=2016-03-01T18:38:29.000Z&transaction[card][brand]=visa&transaction[card][holder_name]=Jose da Silva&transaction[card][first_digits]=490172&transaction[card][last_digits]=4448&transaction[card][country]=BR&transaction[card][fingerprint]=F0Y0+wH0d8DS&transaction[card][customer]=undefined&transaction[card][valid]=true",
125
- signature: '57925d5954efd85613bbffa121dc06b4e7737256'
125
+ signature: 'sha1=57925d5954efd85613bbffa121dc06b4e7737256'
126
126
  }
127
127
  end
128
128
 
@@ -10,14 +10,14 @@ module PagarMe
10
10
  end
11
11
 
12
12
  should 'be valid when has invalid signature' do
13
- postback = PagarMe::Postback.new postback_response_params(signature: 'invalid signature')
13
+ postback = PagarMe::Postback.new postback_response_params(signature: 'sha1=invalid signature')
14
14
  assert !postback.valid?
15
15
  end
16
16
 
17
17
  should 'validate signature' do
18
18
  params = postback_response_params
19
- assert PagarMe::Postback.valid_request_signature?(params[:payload], "sha1=#{params[:signature]}")
20
- assert !PagarMe::Postback.valid_request_signature?(params[:payload], params[:signature])
19
+ assert PagarMe::Postback.valid_request_signature?(params[:payload], params[:signature])
20
+ assert !PagarMe::Postback.valid_request_signature?(params[:payload], params[:signature][4..-1])
21
21
  assert !PagarMe::Postback.valid_request_signature?(params[:payload], 'invalid signature')
22
22
  end
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagarme
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Franceschi