pagseguro-oficial 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -1
  3. data/CONTRIBUTING.md +39 -0
  4. data/Dockerfile +20 -0
  5. data/README.md +22 -0
  6. data/docker-compose.yml +5 -0
  7. data/examples/checkout/create_payment_request.rb +1 -1
  8. data/examples/direct/create_transaction_using_boleto.rb +1 -1
  9. data/examples/direct/create_transaction_using_credit_card.rb +1 -1
  10. data/examples/direct/create_transaction_using_online_debit.rb +1 -1
  11. data/examples/preapproval/cancel_preapproval.rb +26 -0
  12. data/examples/preapproval/change_preapproval_payment.rb +50 -0
  13. data/examples/preapproval/change_preapproval_status.rb +29 -0
  14. data/examples/preapproval/charge_preapproval.rb +36 -0
  15. data/examples/preapproval/create_preapproval.rb +68 -0
  16. data/examples/preapproval/create_preapproval_auto.rb +53 -0
  17. data/examples/preapproval/create_preapproval_discount.rb +30 -0
  18. data/examples/preapproval/create_preapproval_manual.rb +58 -0
  19. data/examples/preapproval/create_preapproval_transparent.rb +41 -0
  20. data/examples/preapproval/preapproval_retry.rb +29 -0
  21. data/examples/preapproval/search/search_by_date_interval.rb +45 -0
  22. data/examples/preapproval/search/search_by_days_interval.rb +46 -0
  23. data/examples/preapproval/search/search_by_notification_code.rb +50 -0
  24. data/examples/preapproval/search/search_by_subscription_code.rb +50 -0
  25. data/examples/preapproval/search/search_subscription_payment_orders.rb +53 -0
  26. data/examples/split_payment/create_payment_request.rb +1 -1
  27. data/examples/split_payment/create_transaction_using_boleto.rb +118 -0
  28. data/examples/split_payment/create_transaction_using_credit_card.rb +152 -0
  29. data/lib/pagseguro.rb +33 -1
  30. data/lib/pagseguro/credit_card_transaction_request.rb +1 -1
  31. data/lib/pagseguro/document.rb +8 -0
  32. data/lib/pagseguro/holder.rb +8 -0
  33. data/lib/pagseguro/manual_subscription_charger.rb +59 -0
  34. data/lib/pagseguro/manual_subscription_charger/request_serializer.rb +50 -0
  35. data/lib/pagseguro/manual_subscription_charger/response.rb +36 -0
  36. data/lib/pagseguro/manual_subscription_charger/response_serializer.rb +17 -0
  37. data/lib/pagseguro/payment_request/request_serializer.rb +25 -1
  38. data/lib/pagseguro/receiver.rb +3 -0
  39. data/lib/pagseguro/request.rb +32 -2
  40. data/lib/pagseguro/sender.rb +21 -3
  41. data/lib/pagseguro/subscription.rb +132 -0
  42. data/lib/pagseguro/subscription/request_serializer.rb +129 -0
  43. data/lib/pagseguro/subscription/response.rb +49 -0
  44. data/lib/pagseguro/subscription/response_serializer.rb +62 -0
  45. data/lib/pagseguro/subscription/subscription_search.rb +135 -0
  46. data/lib/pagseguro/subscription_canceller.rb +30 -0
  47. data/lib/pagseguro/subscription_canceller/response.rb +34 -0
  48. data/lib/pagseguro/subscription_change_payment.rb +46 -0
  49. data/lib/pagseguro/subscription_change_payment/request_serializer.rb +80 -0
  50. data/lib/pagseguro/subscription_change_payment/response.rb +26 -0
  51. data/lib/pagseguro/subscription_change_status.rb +50 -0
  52. data/lib/pagseguro/subscription_change_status/request_serializer.rb +28 -0
  53. data/lib/pagseguro/subscription_change_status/response.rb +26 -0
  54. data/lib/pagseguro/subscription_discount.rb +41 -0
  55. data/lib/pagseguro/subscription_discount/request_serializer.rb +34 -0
  56. data/lib/pagseguro/subscription_discount/response.rb +34 -0
  57. data/lib/pagseguro/subscription_payment_method.rb +21 -0
  58. data/lib/pagseguro/subscription_payment_order.rb +57 -0
  59. data/lib/pagseguro/subscription_payment_order/response.rb +37 -0
  60. data/lib/pagseguro/subscription_payment_order/response_serializer.rb +51 -0
  61. data/lib/pagseguro/subscription_plan.rb +69 -0
  62. data/lib/pagseguro/subscription_plan/request_serializer.rb +81 -0
  63. data/lib/pagseguro/subscription_plan/response.rb +36 -0
  64. data/lib/pagseguro/subscription_plan/response_serializer.rb +17 -0
  65. data/lib/pagseguro/subscription_retry.rb +35 -0
  66. data/lib/pagseguro/subscription_retry/response.rb +34 -0
  67. data/lib/pagseguro/subscription_search_payment_orders.rb +131 -0
  68. data/lib/pagseguro/subscription_transaction.rb +29 -0
  69. data/lib/pagseguro/subscription_transactions.rb +5 -0
  70. data/lib/pagseguro/transaction.rb +0 -10
  71. data/lib/pagseguro/transaction/serializer.rb +19 -2
  72. data/lib/pagseguro/transaction_request.rb +26 -1
  73. data/lib/pagseguro/transaction_request/request_serializer.rb +164 -1
  74. data/lib/pagseguro/version.rb +1 -1
  75. data/spec/fixtures/manual_subscription_charger/fail.xml +6 -0
  76. data/spec/fixtures/manual_subscription_charger/success.xml +4 -0
  77. data/spec/fixtures/subscription/fail.xml +6 -0
  78. data/spec/fixtures/subscription/find_success.xml +28 -0
  79. data/spec/fixtures/subscription/search_success.xml +18 -0
  80. data/spec/fixtures/subscription/success.xml +4 -0
  81. data/spec/fixtures/subscription_canceller/fail.xml +6 -0
  82. data/spec/fixtures/subscription_change_payment/fail.xml +7 -0
  83. data/spec/fixtures/subscription_change_status/fail.xml +7 -0
  84. data/spec/fixtures/subscription_discount/fail.xml +6 -0
  85. data/spec/fixtures/subscription_payment_order/success.xml +18 -0
  86. data/spec/fixtures/subscription_plan/fail.xml +6 -0
  87. data/spec/fixtures/subscription_plan/success.xml +4 -0
  88. data/spec/fixtures/subscription_retry/fail.xml +7 -0
  89. data/spec/fixtures/subscription_search_payment_orders/success.xml +43 -0
  90. data/spec/fixtures/transactions/without_status_and_type.xml +71 -0
  91. data/spec/pagseguro/credit_card_transaction_request_spec.rb +1 -1
  92. data/spec/pagseguro/document_spec.rb +15 -0
  93. data/spec/pagseguro/holder_spec.rb +1 -0
  94. data/spec/pagseguro/manual_subscription_charger/request_serializer_spec.rb +79 -0
  95. data/spec/pagseguro/manual_subscription_charger/response_serializer_spec.rb +10 -0
  96. data/spec/pagseguro/manual_subscription_charger/response_spec.rb +65 -0
  97. data/spec/pagseguro/manual_subscription_charger_spec.rb +68 -0
  98. data/spec/pagseguro/payment_request/request_serializer_spec.rb +54 -22
  99. data/spec/pagseguro/receiver_spec.rb +1 -0
  100. data/spec/pagseguro/sender_spec.rb +16 -2
  101. data/spec/pagseguro/subscription/request_serializer_spec.rb +233 -0
  102. data/spec/pagseguro/subscription/response_serializer_spec.rb +46 -0
  103. data/spec/pagseguro/subscription/response_spec.rb +79 -0
  104. data/spec/pagseguro/subscription/subscription_search_spec.rb +154 -0
  105. data/spec/pagseguro/subscription_canceller/response_spec.rb +58 -0
  106. data/spec/pagseguro/subscription_canceller_spec.rb +57 -0
  107. data/spec/pagseguro/subscription_change_payment/request_serializer_spec.rb +150 -0
  108. data/spec/pagseguro/subscription_change_payment/response_spec.rb +41 -0
  109. data/spec/pagseguro/subscription_change_payment_spec.rb +60 -0
  110. data/spec/pagseguro/subscription_change_status/request_serializer_spec.rb +19 -0
  111. data/spec/pagseguro/subscription_change_status/response_spec.rb +41 -0
  112. data/spec/pagseguro/subscription_change_status_spec.rb +53 -0
  113. data/spec/pagseguro/subscription_discount/request_serializer_spec.rb +27 -0
  114. data/spec/pagseguro/subscription_discount/response_spec.rb +58 -0
  115. data/spec/pagseguro/subscription_discount_spec.rb +60 -0
  116. data/spec/pagseguro/subscription_payment_method_spec.rb +10 -0
  117. data/spec/pagseguro/subscription_payment_order/response_serializer_spec.rb +24 -0
  118. data/spec/pagseguro/subscription_payment_order/response_spec.rb +55 -0
  119. data/spec/pagseguro/subscription_payment_order_spec.rb +27 -0
  120. data/spec/pagseguro/subscription_plan/request_serializer_spec.rb +253 -0
  121. data/spec/pagseguro/subscription_plan/response_serializer_spec.rb +10 -0
  122. data/spec/pagseguro/subscription_plan/response_spec.rb +65 -0
  123. data/spec/pagseguro/subscription_plan_spec.rb +118 -0
  124. data/spec/pagseguro/subscription_retry/response_spec.rb +58 -0
  125. data/spec/pagseguro/subscription_retry_spec.rb +62 -0
  126. data/spec/pagseguro/subscription_search_payment_order_spec.rb +129 -0
  127. data/spec/pagseguro/subscription_spec.rb +137 -0
  128. data/spec/pagseguro/subscription_transaction_spec.rb +24 -0
  129. data/spec/pagseguro/subscription_transactions_spec.rb +37 -0
  130. data/spec/pagseguro/transaction/response_spec.rb +0 -42
  131. data/spec/pagseguro/transaction/serializer_spec.rb +5 -6
  132. data/spec/pagseguro/transaction_request/request_serializer_spec.rb +623 -159
  133. data/spec/pagseguro/transaction_request_spec.rb +26 -0
  134. data/spec/pagseguro/transaction_spec.rb +0 -48
  135. data/spec/spec_helper.rb +1 -0
  136. metadata +154 -8
  137. data/examples/checkout/search/search_transaction_status_history.rb +0 -22
  138. data/lib/pagseguro/transaction/status_collection.rb +0 -20
  139. data/spec/fixtures/transactions/status_history.xml +0 -12
  140. data/spec/pagseguro/transaction/status_collection_spec.rb +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fca1219acbd801903f2b2bb735bed9ce7803b064
4
- data.tar.gz: 7b9daf1da4f391c5896fe9d53b20a18fd18786ea
3
+ metadata.gz: 1e753af9a11f3f30119c860834bf9bf329116a3e
4
+ data.tar.gz: fe1f186de7dc6723e836564c8207083603820fb1
5
5
  SHA512:
6
- metadata.gz: 2a405d53942d7a402fce7510d23d1b0b37cddc78c4e5bb9e32cdbd3905a8af8e119c0160cf3fd02c9e933f7464c0200a3085da0b1555da81c50ca181997b8a35
7
- data.tar.gz: 68a7d881ac81697f229c5d389dbc5d09446e416c9f3b9fa00555b640a1bddacba3dce5e000df4a1f809f787e05f6b1f35be20e87bd57c7caa1fc29f911473a42
6
+ metadata.gz: bed8920899306d08f3e0f59fb5ee727496308b7754ad9bf8226efae5f0f24716e8297999ccc8794ec77cbd8c402bd000d9c6580ba1c56e2d66f3212b8fe66c9c
7
+ data.tar.gz: 43b2bfdf5dee8de08dc45548e457a395b59ff680570e9a448afdd2d0ce2b5a23d75a538bf6a79ad5e43187393a9d7d2dc40bf03429d930c3dbc706a2c58d7a93
@@ -1,6 +1,18 @@
1
- ## Next release - 2.5.0
1
+ 2.6.0
2
+
3
+ - Assinatura
4
+ - Adicionado arquivo de configuração docker e docker-compose
5
+ - Atualização e refatoração de exemplos
6
+
7
+ 2.5.0
2
8
 
3
9
  - Atualizado a sintaxe do rspec
10
+ - Cobertura de todos os tipos de erros http
11
+ - Removido gems não usadas
12
+ - Criado módulo de coleções
13
+ - Adicionado parcelamento por receptor
14
+ - Classe Refund renomeada para TransactionRefund
15
+ - Requisição de autorização com conta existente ou sugestão de cadastro
4
16
 
5
17
  2.4.0
6
18
 
@@ -0,0 +1,39 @@
1
+ PagSeguro is the a library to use [pagseguro's API](https://pagseguro.uol.com.br).
2
+
3
+ It is officially maintened by pagseguro company.
4
+
5
+ Please note that these rules should be acknowledged by everyone, but repository contributors might occasionally deviate from them for practical work, e.g. not fork the repository, but using a branch on the main repository. This should however be an exception.
6
+
7
+ # Developing
8
+
9
+ Please follow this steps:
10
+
11
+ * *Fork* the project at github;
12
+
13
+ * git clone your project, using:
14
+
15
+ % git clone git@github.com/<your-username-here>/ruby
16
+
17
+ * Optionaly you can add main repository as upstream:
18
+
19
+ % git remote add upstream git@github.com:pagseguro/ruby.git
20
+
21
+ * Make sure you are on the right branch, aka, `dev`:
22
+
23
+ % git checkout dev
24
+
25
+ * Create your develop/feature branch:
26
+
27
+ % git checkout -b my-cool-feature
28
+
29
+ * Make your changes of the files and, of course, ensure you write the related tests.
30
+
31
+ * Send your work to your repository:
32
+
33
+ % git push origin my-cool-feature
34
+
35
+ * Now, create a pull request using github. Don't forget to include a clear description of what the pull request want to change and/or fix.
36
+
37
+ # Test
38
+
39
+ It is essential, PR without tests will not be accepted (unless rare ocasions, e. g., changing examples, documentation, …).
@@ -0,0 +1,20 @@
1
+ from ruby:2.2.2
2
+
3
+ env DEBIAN_FRONTEND noninteractive
4
+
5
+ run sed -i '/deb-src/d' /etc/apt/sources.list
6
+ run apt-get update
7
+ run apt-get install -y build-essential
8
+
9
+ workdir /tmp
10
+ copy Gemfile Gemfile
11
+ copy Gemfile.lock Gemfile.lock
12
+ copy pagseguro-oficial.gemspec pagseguro-oficial.gemspec
13
+ run mkdir -p lib/pagseguro
14
+ copy lib/pagseguro/version.rb lib/pagseguro
15
+ run bundle install
16
+
17
+ run mkdir /app
18
+ workdir /app
19
+
20
+ cmd bash
data/README.md CHANGED
@@ -369,6 +369,28 @@ PagSeguro.encoding = "UTF-8" # UTF-8 ou ISO-8859-1
369
369
  Encontre toda a documentação necessária para o checkout transparente aqui:
370
370
  https://github.com/pagseguro/ruby/blob/master/docs/transparent_checkout.md
371
371
 
372
+ ## Docker
373
+
374
+ [Docker](http://www.docker.com/) é uma ferramenta open-source que cria uma
375
+ camada de abstração e automação da virtualização do kernel do
376
+ GNU/Linux[\*](https://en.wikipedia.org/wiki/Docker_(software)).
377
+
378
+ Primeiro certifique-se de que o Docker está instalado e configurado
379
+ corretamente, em seguida construa a imagem:
380
+
381
+ % docker build -t pagseguro .
382
+
383
+ E para entrar na imagem:
384
+
385
+ % docker run --rm -it -v ${PWD}:/app pagseguro
386
+ root@5c480dd6e22a:/app#
387
+
388
+ Ou se preferir você pode usar o
389
+ [docker-compose](https://docs.docker.com/compose/):
390
+
391
+ % docker-compose run script
392
+ root@c6697abac095:/app#
393
+
372
394
  ## Dúvidas?
373
395
 
374
396
  Caso tenha dúvidas ou precise de suporte, acesse nosso [fórum].
@@ -0,0 +1,5 @@
1
+ script:
2
+ build: .
3
+ volumes:
4
+ - .:/app
5
+ - /usr/share/zoneinfo/America/Fortaleza:/etc/localtime:ro
@@ -26,7 +26,7 @@ payment.reference = "REF1234"
26
26
  payment.sender = {
27
27
  name: "Nando Vieira",
28
28
  email: "fnando.vieira@gmail.com",
29
- cpf: "21639716866",
29
+ document: { type: "CPF", value: "21639716866" },
30
30
  phone: {
31
31
  area_code: 11,
32
32
  number: "12345678"
@@ -22,7 +22,7 @@ payment.sender = {
22
22
  hash: "7e215170790948f45e26175c2192c77e88c0e4c361a5860b99d2e9a97af982e6",
23
23
  name: "Joao Comprador",
24
24
  email: "joao@sandbox.pagseguro.com.br",
25
- cpf: "75073461100",
25
+ document: { type: "CPF", value: "75073461100" },
26
26
  phone: {
27
27
  area_code: 11,
28
28
  number: "12345678"
@@ -22,7 +22,7 @@ payment.sender = {
22
22
  hash: "f8d95a0747cdddf277a111ec1bab1d68628e095243b7a56382ec01f260216313",
23
23
  name: "Joao Comprador",
24
24
  email: "joao@sandbox.pagseguro.com.br",
25
- cpf: "75073461100",
25
+ document: { type: "CPF", value: "75073461100" },
26
26
  phone: {
27
27
  area_code: 11,
28
28
  number: "12345678"
@@ -22,7 +22,7 @@ payment.sender = {
22
22
  hash: "7e215170790948f45e26175c2192c77e88c0e4c361a5860b99d2e9a97af982e6",
23
23
  name: "Joao Comprador",
24
24
  email: "joao@sandbox.pagseguro.com.br",
25
- cpf: "75073461100",
25
+ document: { type: "CPF", value: "75073461100" },
26
26
  phone: {
27
27
  area_code: 11,
28
28
  number: "12345678"
@@ -0,0 +1,26 @@
1
+ require_relative '../boot'
2
+
3
+ # Cancel a Subscription.
4
+ #
5
+ # You need to set your AccountCredentials (EMAIL, TOKEN) in the application
6
+ # config.
7
+ #
8
+ # P.S: See the boot file example for more details.
9
+
10
+ code = 'CODE'
11
+ email = 'EMAIL'
12
+ token = 'TOKEN'
13
+
14
+ # Edit the lines above.
15
+
16
+ cancel = PagSeguro::SubscriptionCanceller.new(subscription_code: code)
17
+
18
+ cancel.credentials = PagSeguro::AccountCredentials.new(email, token)
19
+ cancel.save
20
+
21
+ if cancel.errors.any?
22
+ puts '=> ERRORS'
23
+ puts cancel.errors.join('\n')
24
+ else
25
+ print '=> Subscription cancelled correctly.'
26
+ end
@@ -0,0 +1,50 @@
1
+ require_relative '../boot'
2
+
3
+ # Change a Payment.
4
+ #
5
+ # You need to set your AccountCredentials (EMAIL, TOKEN) in the application
6
+ # config.
7
+ #
8
+ # P.S: See the boot file example for more details.
9
+
10
+ email = 'EMAIL'
11
+ token = 'TOKEN'
12
+
13
+ new_payment = PagSeguro::SubscriptionChangePayment.new(
14
+ subscription_code: 'SUBSCRIPTION_CODE',
15
+ sender: {
16
+ hash: 'HASH',
17
+ ip: '192.168.0.1',
18
+ },
19
+ subscription_payment_method: {
20
+ token: 'TOKEN',
21
+ holder: {
22
+ name: 'Nome',
23
+ birth_date: Date.new(1984, 12, 31),
24
+ phone: { area_code: '11', number: '988881234' },
25
+ document: { type: 'CPF', value: '00000000191' },
26
+ billing_address: {
27
+ street: 'Av Brigadeira Faria Lima',
28
+ number: '1384',
29
+ complement: '3 andar',
30
+ district: 'Jd Paulistano',
31
+ city: 'Sao Paulo',
32
+ state: 'SP',
33
+ country: 'BRA',
34
+ postal_code: '01452002'
35
+ }
36
+ }
37
+ }
38
+ )
39
+
40
+ # Edit the lines above.
41
+
42
+ new_payment.credentials = PagSeguro::AccountCredentials.new(email, token)
43
+ new_payment.update
44
+
45
+ if new_payment.errors.any?
46
+ puts '=> ERRORS'
47
+ puts new_payment.errors.join("\n")
48
+ else
49
+ print '=> Subscription correct changed.'
50
+ end
@@ -0,0 +1,29 @@
1
+ require_relative "../boot"
2
+
3
+ # Change Subscription Status
4
+ #
5
+ # You need to set:
6
+ # - AccountCredentials (EMAIL, TOKEN)
7
+ # - Subscription's code
8
+ # - The new status
9
+ #
10
+ # P.S: Take a look at the boot file example for more details
11
+
12
+ user = 'user@example.com'
13
+ token = 'TOKEN'
14
+ code = 'CODE'
15
+ status = :suspended # Now just available the status :active and :suspended
16
+
17
+ credentials = PagSeguro::AccountCredentials.new('user@example.com', 'TOKEN')
18
+
19
+ change = PagSeguro::SubscriptionChangeStatus.new(code, status)
20
+ change.credentials = credentials
21
+ change.save
22
+
23
+ if change.errors.any?
24
+ puts "ERRORS: "
25
+ puts change.errors.inspect
26
+ else
27
+ puts "SUCCESS"
28
+ puts change.inspect
29
+ end
@@ -0,0 +1,36 @@
1
+ require_relative '../boot'
2
+
3
+ # Charge a Manual Subscription.
4
+ #
5
+ # You also can set your AccountCredentials (EMAIL, TOKEN) in the application
6
+ # config.
7
+ #
8
+ # See the boot file example for more details.
9
+
10
+ email = 'EMAIL'
11
+ token = 'TOKEN'
12
+
13
+ charger = PagSeguro::ManualSubscriptionCharger.new(
14
+ reference: 'REFERENCE',
15
+ subscription_code: 'SUBSCRIPTION_CODE',
16
+ )
17
+
18
+ charger.items << {
19
+ id: '0001',
20
+ description: 'Seguro contra roubo',
21
+ amount: 100.0,
22
+ quantity: 1
23
+ }
24
+
25
+ # Edit the lines above.
26
+
27
+ charger.credentials = PagSeguro::AccountCredentials.new(email, token)
28
+ charger.create
29
+
30
+ if charger.errors.any?
31
+ puts '=> ERRORS'
32
+ puts charger.errors.join("\n")
33
+ else
34
+ print '=> Subscription was corrected charged, the transaction code is '
35
+ puts charger.transaction_code
36
+ end
@@ -0,0 +1,68 @@
1
+ require_relative '../boot'
2
+
3
+ # Subscribe your client in a SubscriptionPlan (Transparent Checkout).
4
+ #
5
+ # You need to set your AccountCredentials (EMAIL, TOKEN) in the application config
6
+ #
7
+ # P.S: See the boot file example for more details.
8
+
9
+ email = 'EMAIL'
10
+ token = 'TOKEN'
11
+
12
+ subscription = PagSeguro::Subscription.new(
13
+ plan: 'SUBSCRIPTION_CODE',
14
+ reference: 'SUB-1234',
15
+ sender: {
16
+ name: 'Comprador',
17
+ email: 'user@sandbox.pagseguro.com.br',
18
+ ip: '192.168.0.1',
19
+ hash: 'hash',
20
+ phone: {
21
+ area_code: 12,
22
+ number: '23456789'
23
+ },
24
+ document: { type: 'CPF', value: '23606838450' },
25
+ address: {
26
+ street: 'Av Brigadeira Faria Lima',
27
+ number: '1384',
28
+ complement: '3 andar',
29
+ district: 'Jd Paulistano',
30
+ city: 'Sao Paulo',
31
+ state: 'SP',
32
+ country: 'BRA',
33
+ postal_code: '01452002'
34
+ }
35
+ },
36
+ payment_method: {
37
+ token: 'TOKEN',
38
+ holder: {
39
+ name: 'Nome',
40
+ birth_date: '11/01/1984',
41
+ document: { type: 'CPF', value: '00000000191' },
42
+ billing_address: {
43
+ street: 'Av Brigadeira Faria Lima',
44
+ number: '1384',
45
+ complement: '3 andar',
46
+ district: 'Jd Paulistano',
47
+ city: 'Sao Paulo',
48
+ state: 'SP',
49
+ country: 'BRA',
50
+ postal_code: '01452002'
51
+ },
52
+ phone: { area_code: '11', number: '988881234' }
53
+ }
54
+ }
55
+ )
56
+
57
+ # Edit the lines above.
58
+
59
+ subscription.credentials = PagSeguro::AccountCredentials.new(email, token)
60
+ subscription.create
61
+
62
+ if subscription.errors.any?
63
+ puts '=> ERRORS'
64
+ puts subscription.errors.join('\n')
65
+ else
66
+ print '=> Subscription correct created, its code is '
67
+ puts subscription.code
68
+ end
@@ -0,0 +1,53 @@
1
+ require_relative '../boot'
2
+
3
+ # Create a Subscription Plan (Auto charge)
4
+ #
5
+ # You need to set your AccountCredentials (EMAIL, TOKEN) in the application config
6
+ #
7
+ # P.S: See the boot file example for more details.
8
+
9
+ email = 'EMAIL'
10
+ token = 'TOKEN'
11
+
12
+ plan = PagSeguro::SubscriptionPlan.new(
13
+ charge: 'auto', # Automatic Subscription Plan must always use auto charge type.
14
+
15
+ redirect_url: 'http://www.lojateste.com.br/redirect',
16
+ review_url: 'http://www.lojateste.com.br/review',
17
+ reference: 'AUTOPLAN123',
18
+ name: 'Seguro contra roubo do Notebook',
19
+ details: 'Taxa referente ao seguro contra roubo de Notebook',
20
+ period: 'Monthly',
21
+ final_date: Time.new(2017, 2, 28, 20, 20),
22
+ amount: 100.0,
23
+ max_total_amount: 2400.0,
24
+
25
+ sender: {
26
+ name: 'Nome do Cliente',
27
+ email: 'client@example.com',
28
+ phone: { area_code: 11, number: 123456 },
29
+ address: {
30
+ street: 'Avenida Brigadeiro Faria Lima',
31
+ number: 1384,
32
+ complement: '1 Andar',
33
+ district: 'Jardim Paulistano',
34
+ postal_code: '01452002',
35
+ city: 'São Paulo',
36
+ state: 'SP',
37
+ country: 'BRA',
38
+ }
39
+ }
40
+ )
41
+
42
+ # Edit the lines above.
43
+
44
+ plan.credentials = PagSeguro::AccountCredentials.new(email, token)
45
+ plan.create
46
+
47
+ if plan.errors.any?
48
+ puts '=> ERRORS'
49
+ puts plan.errors.join("\n")
50
+ else
51
+ print '=> Subscription Plan correct created, its code is '
52
+ puts plan.code
53
+ end
@@ -0,0 +1,30 @@
1
+ require_relative '../boot'
2
+
3
+ # Create a Subscription Discount.
4
+ #
5
+ # You need to set your AccountCredentials (EMAIL, TOKEN) in the application
6
+ # config.
7
+ #
8
+ # P.S: See the boot file example for more details.
9
+
10
+ email = 'EMAIL'
11
+ token = 'TOKEN'
12
+
13
+ discount = PagSeguro::SubscriptionDiscount.new(
14
+ # The types of discount are DISCOUNT_PERCENT and DISCOUNT_AMOUNT.
15
+ type: 'DISCOUNT_AMOUNT',
16
+ value: 5.0,
17
+ code: 'PREAPPROVAL_CODE'
18
+ )
19
+
20
+ # Edit the lines above.
21
+
22
+ discount.credentials = PagSeguro::AccountCredentials.new(email, token)
23
+ discount.create
24
+
25
+ if discount.errors.any?
26
+ puts '=> ERRORS'
27
+ puts discount.errors.join("\n")
28
+ else
29
+ puts '=> Subscription Discount correct added.'
30
+ end