paypro 1.0.0 → 2.1.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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +54 -0
  3. data/.gitignore +9 -47
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +37 -15
  6. data/Gemfile +12 -2
  7. data/LICENSE +1 -1
  8. data/README.md +65 -23
  9. data/Rakefile +5 -1
  10. data/bin/console +8 -0
  11. data/bin/setup +8 -0
  12. data/lib/data/{ca-bundle.crt → cacert.pem} +617 -298
  13. data/lib/pay_pro/api_client.rb +141 -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 +25 -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/{paypro → pay_pro}/version.rb +1 -1
  55. data/lib/pay_pro.rb +77 -0
  56. data/paypro.gemspec +18 -11
  57. metadata +67 -48
  58. data/.circleci/config.yml +0 -74
  59. data/VERSION +0 -1
  60. data/examples/create_payment.rb +0 -7
  61. data/lib/paypro/client.rb +0 -68
  62. data/lib/paypro/errors.rb +0 -7
  63. data/lib/paypro.rb +0 -16
  64. data/spec/paypro/client_spec.rb +0 -114
  65. data/spec/paypro_spec.rb +0 -13
  66. data/spec/spec_helper.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b86b1ac203166a746393b0d9772b47322cf3708c5482a2929354dab4c86acb6
4
- data.tar.gz: d6f199ff056d773a99c5e50843e5ad376b688a041854c6f9274e17f3ff6aef86
3
+ metadata.gz: 0564a67b210cd7adbc23d04d6d82bb1dc618fbc7bd8c8916233c5e8301b84509
4
+ data.tar.gz: bf2048e8ea71ff85b3f24ae91be9a9d946b2640e62bafac150433aba259a4409
5
5
  SHA512:
6
- metadata.gz: 1bcb6e549b47d3dcb2d34ca899db63a7a093c3f0d268cf2937f2f0223b9743a8e9ee4f41196543493b29801cdca817d86c35f252d2844f64e956cc18d8a9e810
7
- data.tar.gz: 0ec7c145fc4d0fa792039b1f3d7a2c548659bbc0941e21bc142c30935505a1b20a68364d8ae24e12eacd16136af8356d4d729d8ced7859f1c6aeef1887b54b97
6
+ metadata.gz: 1190b371b19d5cf6bd4eb909be5b718f299bcf006ded6a8c48bb8b4b7f881ca2a33d760db4c13063d63dee87240a02abaf0c89cc2c5efa96bf82ffbb45f54977
7
+ data.tar.gz: 77bd89f811f21519371c134d79fded8062adb8223765a6a68889e81adfe2c89c310455364d693a5b2c2d67ffa20b3c764d1b0fb55994f7dc99c00017e29a0db3
@@ -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,53 +1,15 @@
1
- *.gem
2
- *.rbc
3
- /.config
1
+ /.bundle/
2
+ /.idea
3
+ /.yardoc
4
+ /_yardoc/
4
5
  /coverage/
5
- /InstalledFiles
6
+ /doc/
6
7
  /pkg/
7
8
  /spec/reports/
8
- /spec/examples.txt
9
- /test/tmp/
10
- /test/version_tmp/
11
9
  /tmp/
10
+ *.DS_Store
12
11
 
13
- # Don't ship Gemfile.lock
14
- Gemfile.lock
15
-
16
- # Used by dotenv library to load environment variables.
17
- # .env
18
-
19
- ## Specific to RubyMotion:
20
- .dat*
21
- .repl_history
22
- build/
23
- *.bridgesupport
24
- build-iPhoneOS/
25
- build-iPhoneSimulator/
26
-
27
- ## Specific to RubyMotion (use of CocoaPods):
28
- #
29
- # We recommend against adding the Pods directory to your .gitignore. However
30
- # you should judge for yourself, the pros and cons are mentioned at:
31
- # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
- #
33
- # vendor/Pods/
12
+ .rspec_status
13
+ .ruby-version
34
14
 
35
- ## Documentation cache and generated files:
36
- /.yardoc/
37
- /_yardoc/
38
- /doc/
39
- /rdoc/
40
-
41
- ## Environment normalization:
42
- /.bundle/
43
- /vendor/bundle
44
- /lib/bundler/man/
45
-
46
- # for a library or gem, you might want to ignore these files since the code is
47
- # intended to run in multiple environments; otherwise, check them in:
48
- # Gemfile.lock
49
- # .ruby-version
50
- # .ruby-gemset
51
-
52
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
- .rvmrc
15
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,17 +1,39 @@
1
+ plugins:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+
1
5
  AllCops:
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:
29
+ Enabled: false
30
+
31
+ RSpec/NestedGroups:
32
+ Max: 5
33
+
34
+ Style/Documentation:
35
+ Enabled: false
36
+
37
+ Style/FrozenStringLiteralComment:
2
38
  Exclude:
3
- - "db/**/*"
4
- - "tmp/**/*"
5
- - "vendor/**/*"
6
- - "bin/**/*"
7
- - "log/**/*"
8
- - "public/**/*"
9
- TargetRubyVersion: 2.4
10
- Layout/LineLength:
11
- Enabled: true
12
- Max: 120
13
- Metrics/BlockLength:
14
- Exclude:
15
- - 'Rakefile'
16
- - '**/*.rake'
17
- - 'spec/**/*.rb'
39
+ - 'bin/**'
data/Gemfile CHANGED
@@ -2,9 +2,19 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ # Specify your gem's dependencies in paypro.gemspec
5
6
  gemspec
6
7
 
7
8
  group :development do
8
- gem 'rspec_junit_formatter', '~> 0.3'
9
- 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.75.5'
14
+ gem 'rubocop-performance', '~> 1.25.0'
15
+ gem 'rubocop-rspec', '~> 3.6.0'
16
+
17
+ gem 'timecop', '~> 0.9.8'
18
+
19
+ gem 'webmock', '~> 3.19.0'
10
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,56 +1,98 @@
1
- ![PayPro](https://www.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
- [![Gem Version](https://badge.fury.io/rb/paypro.svg)](https://badge.fury.io/rb/paypro)
5
- [![circleci](https://img.shields.io/circleci/project/github/RedSparr0w/node-csgo-parser.svg)](https://circleci.com/gh/paypronl/paypro-ruby-v1)
6
5
 
7
- 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
8
14
 
9
15
  ## Requirements
10
16
 
11
- - Ruby >= 2.4.0
17
+ - Ruby >= 3.0.0
12
18
 
13
19
  ## Installation
14
20
 
15
- Installation is pretty standard:
21
+ You can install the gem like this:
16
22
 
17
23
  ```sh
18
- $ gem install paypro
24
+ gem install paypro
19
25
  ```
20
26
 
21
- if you'd rather install the PayPro client using `bundler` you can put this in your Gemfile:
27
+ If you'd rather install the gem through `bundler` you can put this in your Gemfile:
22
28
 
23
29
  ```ruby
24
30
  source 'https://rubygems.org'
25
31
 
26
32
  gem 'paypro'
33
+
27
34
  ```
28
35
 
29
- Or directly from the GitHub repository:
36
+ ## Getting started
37
+
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:
30
42
 
31
43
  ```ruby
32
- gem 'paypro', git: 'https://github.com/paypronl/paypro-ruby-v1'
44
+ require 'paypro'
45
+
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
+
33
57
  ```
34
58
 
35
- ## Getting started
59
+ ## Per-request configuration
36
60
 
37
- Example of creating a payment:
61
+ When you have multiple API keys to use during a single request, you can specify these in all requests.
38
62
 
39
63
  ```ruby
40
64
  require 'paypro'
41
65
 
42
- client = PayPro::Client.new('YOUR_API_KEY')
43
- client.command = 'create_payment';
44
- client.params = { amount: 500, consumer_email: 'test@paypro.nl', pay_method: 'ideal/INGBNL2A' }
45
- client.execute
46
- ```
66
+ client = PayPro::Client.new('pp_...')
47
67
 
48
- ## Documentation
68
+ # Creating a payment
69
+ payment = client.payments.create({ amount: 500, currency: 'EUR', description: 'Test Payment' }, api_key: 'pp_...')
49
70
 
50
- For guides and code examples you can go to https://www.paypro.nl/developers/docs.
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
51
79
 
52
- ## Contributing
53
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.
54
81
 
55
- ## License
56
- [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,4 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'bundler/gem_tasks'
3
4
  require 'rspec/core/rake_task'
4
- 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