paypro 0.0.1 → 2.0.0

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.
Files changed (67) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/build.yml +54 -0
  3. data/.gitignore +8 -44
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +36 -17
  6. data/Gemfile +14 -2
  7. data/LICENSE +1 -1
  8. data/README.md +77 -15
  9. data/Rakefile +7 -1
  10. data/bin/console +8 -0
  11. data/bin/setup +8 -0
  12. data/lib/data/{ca-bundle.crt → cacert.pem} +1724 -2013
  13. data/lib/pay_pro/api_client.rb +131 -0
  14. data/lib/pay_pro/client.rb +67 -0
  15. data/lib/pay_pro/config.rb +30 -0
  16. data/lib/pay_pro/endpoint.rb +19 -0
  17. data/lib/pay_pro/endpoints/chargebacks.rb +14 -0
  18. data/lib/pay_pro/endpoints/customers.rb +15 -0
  19. data/lib/pay_pro/endpoints/events.rb +14 -0
  20. data/lib/pay_pro/endpoints/installment_plan_periods.rb +13 -0
  21. data/lib/pay_pro/endpoints/installment_plans.rb +15 -0
  22. data/lib/pay_pro/endpoints/mandates.rb +15 -0
  23. data/lib/pay_pro/endpoints/pay_methods.rb +13 -0
  24. data/lib/pay_pro/endpoints/payments.rb +15 -0
  25. data/lib/pay_pro/endpoints/refunds.rb +14 -0
  26. data/lib/pay_pro/endpoints/subscription_periods.rb +13 -0
  27. data/lib/pay_pro/endpoints/subscriptions.rb +15 -0
  28. data/lib/pay_pro/endpoints/webhooks.rb +15 -0
  29. data/lib/pay_pro/entities/chargeback.rb +5 -0
  30. data/lib/pay_pro/entities/customer.rb +10 -0
  31. data/lib/pay_pro/entities/entity.rb +41 -0
  32. data/lib/pay_pro/entities/event.rb +5 -0
  33. data/lib/pay_pro/entities/installment_plan.rb +29 -0
  34. data/lib/pay_pro/entities/installment_plan_period.rb +5 -0
  35. data/lib/pay_pro/entities/list.rb +65 -0
  36. data/lib/pay_pro/entities/mandate.rb +5 -0
  37. data/lib/pay_pro/entities/pay_method.rb +6 -0
  38. data/lib/pay_pro/entities/payment.rb +23 -0
  39. data/lib/pay_pro/entities/refund.rb +11 -0
  40. data/lib/pay_pro/entities/resource.rb +13 -0
  41. data/lib/pay_pro/entities/subscription.rb +38 -0
  42. data/lib/pay_pro/entities/subscription_period.rb +5 -0
  43. data/lib/pay_pro/entities/webhook.rb +30 -0
  44. data/lib/pay_pro/errors.rb +36 -0
  45. data/lib/pay_pro/operations/creatable.rb +11 -0
  46. data/lib/pay_pro/operations/deletable.rb +11 -0
  47. data/lib/pay_pro/operations/getable.rb +11 -0
  48. data/lib/pay_pro/operations/listable.rb +11 -0
  49. data/lib/pay_pro/operations/requestable.rb +12 -0
  50. data/lib/pay_pro/operations/updatable.rb +11 -0
  51. data/lib/pay_pro/response.rb +21 -0
  52. data/lib/pay_pro/signature.rb +59 -0
  53. data/lib/pay_pro/util.rb +48 -0
  54. data/lib/pay_pro/version.rb +5 -0
  55. data/lib/pay_pro.rb +77 -0
  56. data/paypro.gemspec +20 -11
  57. metadata +69 -45
  58. data/.circleci/config.yml +0 -54
  59. data/VERSION +0 -1
  60. data/examples/create_payment.rb +0 -5
  61. data/lib/paypro/client.rb +0 -66
  62. data/lib/paypro/errors.rb +0 -4
  63. data/lib/paypro/version.rb +0 -3
  64. data/lib/paypro.rb +0 -14
  65. data/spec/paypro/client_spec.rb +0 -112
  66. data/spec/paypro_spec.rb +0 -11
  67. data/spec/spec_helper.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c6bd8a3eec2325e4cac9984dea2799f476a239b8
4
- data.tar.gz: 7daab9b2d8ae429bfcc575c288abc0cb87b57ef1
2
+ SHA256:
3
+ metadata.gz: 1b607a221258fa5d8bfe0bda8f604acb345d0e89066f8f86089386932762b3ca
4
+ data.tar.gz: ebc0b753e9d234c911a34af6e95a7bf733c85b60ff1c2f316bb73e2e812f98ae
5
5
  SHA512:
6
- metadata.gz: 46859aa059d6dd303bd030194ffba0b09860c5c483eb27881d1473c7f36d397682b787e5784f42159dffea47e94ce4c00bef223105c13e8f7779b2e831b390ae
7
- data.tar.gz: 60058dc4571627502ffa2ede304885c303e94839b1f72967f82ea6c814beb616eeecd94af786eff20c051d9a417b067ad6131d7c57b7bea43c3583212ae1ad3b
6
+ metadata.gz: 0c481bd099168f64341e52b444ab2780737910d51932864912d57becb6ae8a618c2042b4046059d4a7ec8ad34d1a5189e15acca6e19c68487c494fde6083c2bf
7
+ data.tar.gz: 0aed28248485b406f8a3d15acc98acf8ec7932077f35f625c251f4df731fa4aae33fe34e640461fffd2501468b061450151e399ba7507f299bc42392fbead0c6
@@ -0,0 +1,54 @@
1
+ name: build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - 'master'
7
+ pull_request:
8
+ branches:
9
+ - '**'
10
+
11
+ jobs:
12
+ build:
13
+ name: Build
14
+ needs: test
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: 3.0
23
+ - name: Build
24
+ run: gem build paypro.gemspec
25
+
26
+ lint:
27
+ name: Lint
28
+ runs-on: ubuntu-latest
29
+
30
+ steps:
31
+ - uses: actions/checkout@v3
32
+ - name: Set up Ruby
33
+ uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: 3.0
36
+ - name: Lint
37
+ run: bundle install && bundle exec rubocop
38
+
39
+ test:
40
+ name: Test (${{ matrix.ruby-version }})
41
+ needs: lint
42
+ runs-on: ubuntu-latest
43
+ strategy:
44
+ matrix:
45
+ ruby-version: ['3.0', 3.1, 3.2]
46
+
47
+ steps:
48
+ - uses: actions/checkout@v3
49
+ - name: Set up Ruby
50
+ uses: ruby/setup-ruby@v1
51
+ with:
52
+ ruby-version: ${{ matrix.ruby-version }}
53
+ - name: Test
54
+ run: bundle install && bundle exec rspec
data/.gitignore CHANGED
@@ -1,50 +1,14 @@
1
- *.gem
2
- *.rbc
3
- /.config
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
4
  /coverage/
5
- /InstalledFiles
5
+ /doc/
6
6
  /pkg/
7
7
  /spec/reports/
8
- /spec/examples.txt
9
- /test/tmp/
10
- /test/version_tmp/
11
8
  /tmp/
9
+ *.DS_Store
12
10
 
13
- # Used by dotenv library to load environment variables.
14
- # .env
15
-
16
- ## Specific to RubyMotion:
17
- .dat*
18
- .repl_history
19
- build/
20
- *.bridgesupport
21
- build-iPhoneOS/
22
- build-iPhoneSimulator/
23
-
24
- ## Specific to RubyMotion (use of CocoaPods):
25
- #
26
- # We recommend against adding the Pods directory to your .gitignore. However
27
- # you should judge for yourself, the pros and cons are mentioned at:
28
- # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
- #
30
- # vendor/Pods/
31
-
32
- ## Documentation cache and generated files:
33
- /.yardoc/
34
- /_yardoc/
35
- /doc/
36
- /rdoc/
37
-
38
- ## Environment normalization:
39
- /.bundle/
40
- /vendor/bundle
41
- /lib/bundler/man/
42
-
43
- # for a library or gem, you might want to ignore these files since the code is
44
- # intended to run in multiple environments; otherwise, check them in:
45
- # Gemfile.lock
46
- # .ruby-version
47
- # .ruby-gemset
11
+ .rspec_status
12
+ .ruby-version
48
13
 
49
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
- .rvmrc
14
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,20 +1,39 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+
1
5
  AllCops:
2
- Exclude:
3
- - "db/**/*"
4
- - "tmp/**/*"
5
- - "vendor/**/*"
6
- - "bin/**/*"
7
- - "log/**/*"
8
- - "public/**/*"
9
- TargetRubyVersion: 2.4
10
- Metrics/LineLength:
11
- Enabled: true
12
- Max: 120
13
- Style/FrozenStringLiteralComment:
14
- Description: 'Ruby 3.0 transition for frozen string literals'
6
+ NewCops: enable
7
+ SuggestExtensions: false
8
+ TargetRubyVersion: 3.0
9
+
10
+ # We disable this to allow automatic releases
11
+ Gemspec/RequireMFA:
12
+ Enabled: false
13
+
14
+ Metrics/AbcSize:
15
+ Max: 30
16
+
17
+ Metrics/ClassLength:
18
+ CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
19
+ Max: 100
20
+
21
+ Metrics/MethodLength:
22
+ Max: 30
23
+
24
+ RSpec/ExampleLength:
25
+ CountAsOne: ['array', 'hash', 'heredoc']
26
+ Max: 10
27
+
28
+ RSpec/MultipleMemoizedHelpers:
15
29
  Enabled: false
16
- Style/BlockLength:
30
+
31
+ RSpec/NestedGroups:
32
+ Max: 5
33
+
34
+ Style/Documentation:
35
+ Enabled: false
36
+
37
+ Style/FrozenStringLiteralComment:
17
38
  Exclude:
18
- - 'Rakefile'
19
- - '**/*.rake'
20
- - 'spec/**/*.rb'
39
+ - 'bin/**'
data/Gemfile CHANGED
@@ -1,8 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
5
+ # Specify your gem's dependencies in paypro.gemspec
3
6
  gemspec
4
7
 
5
8
  group :development do
6
- gem 'rspec_junit_formatter', '~> 0.3'
7
- gem 'rubocop', '~> 0.39'
9
+ gem 'debug', '~> 1.8.0'
10
+ gem 'rake', '~> 12.0'
11
+ gem 'rspec', '~> 3.0'
12
+
13
+ gem 'rubocop', '~> 1.57'
14
+ gem 'rubocop-performance', '~> 1.19.0'
15
+ gem 'rubocop-rspec', '~> 2.25.0'
16
+
17
+ gem 'timecop', '~> 0.9.8'
18
+
19
+ gem 'webmock', '~> 3.19.0'
8
20
  end
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017 PayPro
3
+ Copyright (c) 2023 PayPro
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,36 +1,98 @@
1
- ![PayPro](https://paypro.nl/images/logo-ie.png)
2
- # Ruby Client for PayPro API v1
1
+ # PayPro Ruby Library
2
+
3
+ [![build](https://github.com/paypronl/paypro-ruby/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/paypronl/paypro-ruby/actions/workflows/build.yml)
3
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
4
5
 
5
- This library provides a Ruby client to connect with the PayPro API.
6
+ The PayPro Ruby library can be used to make integrating with the PayPro API easier when using Ruby.
7
+ It provides easy to use classes to interact with all resources available through the API.
8
+
9
+ It also provides the following:
10
+
11
+ - Built-in pagination support
12
+ - Easy configuration
13
+ - Webhook request verification helpers
6
14
 
7
15
  ## Requirements
8
16
 
9
- - Ruby >= 2.0.0
17
+ - Ruby >= 3.0.0
10
18
 
11
19
  ## Installation
12
20
 
13
- We provide an installation guide on https://paypro.nl/developers/api-clients/ruby.
21
+ You can install the gem like this:
22
+
23
+ ```sh
24
+ gem install paypro
25
+ ```
26
+
27
+ If you'd rather install the gem through `bundler` you can put this in your Gemfile:
28
+
29
+ ```ruby
30
+ source 'https://rubygems.org'
31
+
32
+ gem 'paypro'
33
+
34
+ ```
14
35
 
15
36
  ## Getting started
16
37
 
17
- Example of creating a payment:
38
+ In order to use the API you need to have a valid API key.
39
+ You can find your API key in the [PayPro dashboard](https://app.paypro.nl/developers/api-keys)
40
+
41
+ Example of using the API:
18
42
 
19
43
  ```ruby
20
44
  require 'paypro'
21
45
 
22
- client = PayPro::Client.new('YOUR_API_KEY')
23
- client.command = 'create_payment';
24
- client.params = { amount: 500, consumer_email: 'test@paypro.nl', pay_method: 'ideal/INGBNL2A' }
25
- client.execute
46
+ client = PayPro::Client.new('pp_...')
47
+
48
+ # Creating a payment
49
+ payment = client.payments.create({ amount: 500, currency: 'EUR', description: 'Test Payment' })
50
+
51
+ # Retrieving all subscriptions
52
+ subscriptions = client.subscriptions.list
53
+
54
+ # Retrieving a single customer
55
+ customer = client.customers.get('CUSSDGDCJVZH5K')
56
+
26
57
  ```
27
58
 
28
- ## Documentation
59
+ ## Per-request configuration
29
60
 
30
- For guides and code examples you can go to https://paypro.nl/developers/docs.
61
+ When you have multiple API keys to use during a single request, you can specify these in all requests.
62
+
63
+ ```ruby
64
+ require 'paypro'
65
+
66
+ client = PayPro::Client.new('pp_...')
67
+
68
+ # Creating a payment
69
+ payment = client.payments.create({ amount: 500, currency: 'EUR', description: 'Test Payment' }, api_key: 'pp_...')
70
+
71
+ # Retrieving five subscriptions
72
+ subscriptions = client.subscriptions.list({ limit: 5 }, api_key: 'pp_...')
73
+
74
+ # Retrieving a single customer
75
+ customer = client.customers.get('CUSSDGDCJVZH5K', api_key: 'pp_...', api_url: 'https://api-test.paypro.nl')
76
+ ```
77
+
78
+ ## Development
31
79
 
32
- ## Contributing
33
80
  If you want to contribute to this project you can fork the repository. Create a new branch, add your feature and create a pull request. We will look at your request and determine if we want to add it.
34
81
 
35
- ## License
36
- [MIT](https://github.com/paypronl/paypro-ruby-v1/blob/master/LICENSE)
82
+ To run all the tests:
83
+
84
+ ```sh
85
+ bundle exec rspec
86
+ ```
87
+
88
+ To run the linter:
89
+
90
+ ```sh
91
+ bundle exec rubocop
92
+ ```
93
+
94
+ To run an `irb` with the gem already required you can use:
95
+
96
+ ```sh
97
+ bin/console
98
+ ```
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
1
4
  require 'rspec/core/rake_task'
2
- Rspec::Core::RakeTask.new('spec')
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'pay_pro'
5
+ require 'debug'
6
+
7
+ require 'irb'
8
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here