pagarme 2.3.0 → 2.4.0

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
- SHA256:
3
- metadata.gz: 8038539ca34d2ee84026309a4e5b984a928c2ce9fc03c88815d8feb6d78fe2ad
4
- data.tar.gz: 31a54704b88c6b8cf267230cc2c5c5a7674fd9dc0f20f62e45a1769f8193e1e9
2
+ SHA1:
3
+ metadata.gz: '09cbd478941d7e533cc69f34d79544eadff6f8df'
4
+ data.tar.gz: 5ab0f69c6eb9ca71e1bf74e3416b1af98b98c6b5
5
5
  SHA512:
6
- metadata.gz: 98e830178072ad3ccbdf999f60909bd09c5a2cbdf02ee37e3387aec815b11266e3fbfa43929d986408700eaee3a6c0d01c635c00b5e2659abada0ddff2ac2af2
7
- data.tar.gz: e2d01c0b5ac463233b538908eadbac7ede42b8c1c32c4ea7eceb3187224ff4cd142dffc2446e01a02cd3d7f7e322021d332728abba07b14553957c1a5ea31e0b
6
+ metadata.gz: bc8bdcf0f45d79fbed47c7951e7bc6dc24f4805bffb82a308a019317e479c4b8794d912cd179525877468b75ae8b62a6bc3df8093bfb2e70c77c5deb42c9f6d0
7
+ data.tar.gz: 2bf71508679143a2c743bab7ecd52f5915687ebd9584f2e6ad6e5c8a33ac661a4c2751a7019f4711ea8771f16a7e256020613da980d4580ff8370e6ba0249ece
data/README.md CHANGED
@@ -55,6 +55,25 @@ To create a credit card transaction, you need a [card\_hash](https://docs.pagar.
55
55
 
56
56
  More about [Creating a Credit Card Transaction](https://docs.pagar.me/docs/realizando-uma-transacao-de-cartao-de-credito).
57
57
 
58
+ #### Creating a Customer
59
+
60
+ ```ruby
61
+ customer = PagarMe::Customer.create(
62
+ name: 'Morpheus Fishburne',
63
+ email: 'mopheus@nabucodonozor.com',
64
+ type: 'individual',
65
+ external_id: "#3311",
66
+ country: 'br',
67
+ birthday: "1965-01-01",
68
+ documents: [
69
+ {type: "cpf", number: "86870624194"}
70
+ ],
71
+ phone_numbers: ["+5511999998888", "+5511888889999"]
72
+ )
73
+ ```
74
+
75
+ More about [Creating a Customer](https://docs.pagar.me/v2017-08-28/reference#criando-um-cliente).
76
+
58
77
  #### Creating a Boleto Transaction
59
78
 
60
79
  ```ruby
@@ -10,7 +10,8 @@ module PagarMe
10
10
  DEFAULT_HEADERS = {
11
11
  'Content-Type' => 'application/json; charset=utf8',
12
12
  'Accept' => 'application/json',
13
- 'User-Agent' => "pagarme-ruby/#{PagarMe::VERSION}"
13
+ 'User-Agent' => "pagarme-ruby/#{PagarMe::VERSION}",
14
+ 'X-PagarMe-User-Agent' => "pagarme-ruby/#{PagarMe::VERSION}"
14
15
  }
15
16
 
16
17
  def initialize(path, method, options={})
@@ -1,3 +1,3 @@
1
1
  module PagarMe
2
- VERSION = '2.3.0'
2
+ VERSION = '2.4.0'
3
3
  end
@@ -4,7 +4,7 @@ module PagarMe
4
4
  class BalanceTest < PagarMeTestCase
5
5
 
6
6
  should 'change amount amount after transaction being paid' do
7
- transaction = PagarMe::Transaction.charge transaction_with_boleto_params
7
+ transaction = PagarMe::Transaction.charge transaction_with_customer_with_boleto_params
8
8
  previous_balance = PagarMe::Balance.balance
9
9
 
10
10
  transaction.status = :paid
@@ -17,7 +17,7 @@ module PagarMe
17
17
  should 'change recipient amount after transaction being paid' do
18
18
  recipient = PagarMe::Recipient.create recipient_with_nested_bank_account_params
19
19
  split_rules = [ { recipient_id: recipient.id, percentage: 100 } ]
20
- transaction = PagarMe::Transaction.charge transaction_with_boleto_params(split_rules: split_rules)
20
+ transaction = PagarMe::Transaction.charge transaction_with_customer_with_boleto_params(split_rules: split_rules)
21
21
 
22
22
  assert_empty_balance recipient.balance
23
23
 
@@ -30,7 +30,7 @@ module PagarMe
30
30
  should 'change recipient amount after recipient receive money' do
31
31
  recipient = PagarMe::Recipient.create recipient_with_nested_bank_account_params
32
32
  split_rules = [ { recipient_id: recipient.id, percentage: 100 } ]
33
- transaction = PagarMe::Transaction.charge transaction_with_boleto_params(split_rules: split_rules)
33
+ transaction = PagarMe::Transaction.charge transaction_with_customer_with_boleto_params(split_rules: split_rules)
34
34
 
35
35
  assert_empty_balance recipient.balance
36
36
 
@@ -0,0 +1,23 @@
1
+ require_relative '../../test_helper'
2
+
3
+ module PagarMe
4
+ class CustomerTest < PagarMeTestCase
5
+ should 'be able to create' do
6
+ customer = PagarMe::Customer.create external_id_customer_params[:customer]
7
+ assert customer.id
8
+ assert_equal customer.name, 'Morpheus Fishburne'
9
+ assert_equal customer.type, 'individual'
10
+ assert_equal customer.external_id, "#3311"
11
+ assert_equal customer.country, 'br'
12
+ assert_equal customer.birthday, "1965-01-01"
13
+ assert customer.phone_numbers.any?
14
+ assert_equal customer.phone_numbers, ["+5511999998888", "+5511888889999"]
15
+ end
16
+
17
+ should 'be able to find by id' do
18
+ customer = PagarMe::Customer.create external_id_customer_params[:customer]
19
+ found_customer = PagarMe::Customer.find_by_id customer.id
20
+ assert_equal customer.id, found_customer.id
21
+ end
22
+ end
23
+ end
@@ -20,7 +20,8 @@ module PagarMe
20
20
  assert_plan_created PagarMe::Plan.create(plan_params)
21
21
 
22
22
  # find_by_hash is possibly consistent, wait to try to ensure!!!
23
- sleep 1
23
+ sleep 5
24
+
24
25
  found_plans = PagarMe::Plan.find_by trial_days: 5
25
26
 
26
27
  assert found_plans.size > 0
@@ -12,10 +12,11 @@ module PagarMe
12
12
 
13
13
  should 'be able to see subscription transactions' do
14
14
  plan = PagarMe::Plan.create no_trial_plan_params
15
- subscription = PagarMe::Subscription.create subscription_with_customer_params(plan: plan)
15
+ subscription = PagarMe::Subscription.create subscription_with_customer_with_card_params(plan: plan)
16
16
  assert_no_trial_subscription_created subscription, plan
17
17
 
18
- sleep 2
18
+ sleep 5
19
+
19
20
  assert subscription.transactions.count > 0
20
21
  assert_equal subscription.transactions.first.status, 'paid'
21
22
  end
@@ -49,7 +49,7 @@ module PagarMe
49
49
  end
50
50
 
51
51
  should 'be able to create transaction with boleto' do
52
- transaction = PagarMe::Transaction.charge transaction_with_boleto_params
52
+ transaction = PagarMe::Transaction.charge transaction_with_customer_with_boleto_params
53
53
  assert_transaction_with_bolelo_on_waiting_payment transaction
54
54
  end
55
55
 
@@ -89,7 +89,7 @@ module PagarMe
89
89
  end
90
90
 
91
91
  should 'require parameters on the refund with boleto' do
92
- transaction = PagarMe::Transaction.create transaction_with_boleto_params
92
+ transaction = PagarMe::Transaction.create transaction_with_customer_with_boleto_params
93
93
  assert_equal transaction.status, 'waiting_payment'
94
94
 
95
95
  assert_raises(PagarMe::ValidationError){ transaction.refund }
@@ -35,7 +35,7 @@ class PagarMeTestCase < Test::Unit::TestCase
35
35
  protected
36
36
  def ensure_positive_balance
37
37
  VCR.use_cassette 'TestCase/ensure_positive_balance' do
38
- transaction = PagarMe::Transaction.charge transaction_with_boleto_params(amount: 100_000_00)
38
+ transaction = PagarMe::Transaction.charge transaction_with_customer_with_boleto_params(amount: 100_000_00)
39
39
  transaction.status = :paid
40
40
  transaction.save
41
41
  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.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Franceschi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-08-29 00:00:00.000000000 Z
12
+ date: 2019-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -223,6 +223,7 @@ files:
223
223
  - test/pagarme/resources/bank_account_test.rb
224
224
  - test/pagarme/resources/bulk_anticipation_test.rb
225
225
  - test/pagarme/resources/card_test.rb
226
+ - test/pagarme/resources/customer_test.rb
226
227
  - test/pagarme/resources/payable_test.rb
227
228
  - test/pagarme/resources/payment_link.rb
228
229
  - test/pagarme/resources/plan_test.rb
@@ -252,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
253
  version: '0'
253
254
  requirements: []
254
255
  rubyforge_project:
255
- rubygems_version: 2.7.6
256
+ rubygems_version: 2.5.2.3
256
257
  signing_key:
257
258
  specification_version: 4
258
259
  summary: Allows integration with Pagar.me
@@ -265,6 +266,7 @@ test_files:
265
266
  - test/pagarme/resources/bank_account_test.rb
266
267
  - test/pagarme/resources/bulk_anticipation_test.rb
267
268
  - test/pagarme/resources/card_test.rb
269
+ - test/pagarme/resources/customer_test.rb
268
270
  - test/pagarme/resources/payable_test.rb
269
271
  - test/pagarme/resources/payment_link.rb
270
272
  - test/pagarme/resources/plan_test.rb