pushpay-ruby 0.2.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.
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe PushPay::Organization do
6
+ let(:orgs) { described_class.new(PushPay.client) }
7
+ let(:base_url) { "https://api.pushpay.io" }
8
+
9
+ describe "#find" do
10
+ it "gets an organization by key" do
11
+ stub_request(:get, "#{base_url}/v1/organization/org_123")
12
+ .to_return(status: 200, body: { key: "org_123", name: "Test Org" }.to_json,
13
+ headers: { "Content-Type" => "application/json" })
14
+
15
+ result = orgs.find("org_123")
16
+ expect(result["name"]).to eq("Test Org")
17
+ end
18
+ end
19
+
20
+ describe "#in_scope" do
21
+ it "lists accessible organizations" do
22
+ stub_request(:get, "#{base_url}/v1/organizations/in-scope")
23
+ .to_return(status: 200, body: { items: [] }.to_json,
24
+ headers: { "Content-Type" => "application/json" })
25
+
26
+ result = orgs.in_scope
27
+ expect(result["items"]).to eq([])
28
+ end
29
+ end
30
+
31
+ describe "#campuses" do
32
+ it "lists campuses for the configured organization" do
33
+ stub_request(:get, "#{base_url}/v1/organization/test_org_key/campuses")
34
+ .to_return(status: 200, body: { items: [] }.to_json,
35
+ headers: { "Content-Type" => "application/json" })
36
+
37
+ result = orgs.campuses
38
+ expect(result["items"]).to eq([])
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe PushPay::Payment do
6
+ let(:payments) { described_class.new(PushPay.client) }
7
+ let(:base_url) { "https://api.pushpay.io" }
8
+
9
+ describe "#find" do
10
+ it "gets a payment by token" do
11
+ stub_request(:get, "#{base_url}/v1/merchant/test_merchant_key/payment/pay_123")
12
+ .to_return(status: 200, body: { paymentToken: "pay_123", status: "Success" }.to_json,
13
+ headers: { "Content-Type" => "application/json" })
14
+
15
+ result = payments.find("pay_123")
16
+ expect(result["paymentToken"]).to eq("pay_123")
17
+ end
18
+
19
+ it "uses a custom merchant key" do
20
+ stub_request(:get, "#{base_url}/v1/merchant/custom_key/payment/pay_123")
21
+ .to_return(status: 200, body: { paymentToken: "pay_123" }.to_json,
22
+ headers: { "Content-Type" => "application/json" })
23
+
24
+ payments.find("pay_123", merchant_key: "custom_key")
25
+ end
26
+ end
27
+
28
+ describe "#list" do
29
+ it "lists merchant payments" do
30
+ stub_request(:get, "#{base_url}/v1/merchant/test_merchant_key/payments")
31
+ .to_return(status: 200, body: { page: 0, pageSize: 25, items: [] }.to_json,
32
+ headers: { "Content-Type" => "application/json" })
33
+
34
+ result = payments.list
35
+ expect(result["items"]).to eq([])
36
+ end
37
+
38
+ it "passes filter params" do
39
+ stub_request(:get, "#{base_url}/v1/merchant/test_merchant_key/payments")
40
+ .with(query: { status: "Success", pageSize: "10" })
41
+ .to_return(status: 200, body: { items: [] }.to_json,
42
+ headers: { "Content-Type" => "application/json" })
43
+
44
+ payments.list(status: "Success", pageSize: "10")
45
+ end
46
+ end
47
+
48
+ describe "#list_for_organization" do
49
+ it "lists payments across an organization" do
50
+ stub_request(:get, "#{base_url}/v1/organization/test_org_key/payments")
51
+ .to_return(status: 200, body: { items: [] }.to_json,
52
+ headers: { "Content-Type" => "application/json" })
53
+
54
+ result = payments.list_for_organization
55
+ expect(result["items"]).to eq([])
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe PushPay::RecurringPayment do
6
+ let(:recurring) { described_class.new(PushPay.client) }
7
+ let(:base_url) { "https://api.pushpay.io" }
8
+
9
+ describe "#find" do
10
+ it "gets a recurring payment by token" do
11
+ stub_request(:get, "#{base_url}/v1/merchant/test_merchant_key/recurringpayment/rp_123")
12
+ .to_return(status: 200, body: { paymentToken: "rp_123" }.to_json,
13
+ headers: { "Content-Type" => "application/json" })
14
+
15
+ result = recurring.find("rp_123")
16
+ expect(result["paymentToken"]).to eq("rp_123")
17
+ end
18
+ end
19
+
20
+ describe "#list" do
21
+ it "lists merchant recurring payments" do
22
+ stub_request(:get, "#{base_url}/v1/merchant/test_merchant_key/recurringpayments")
23
+ .to_return(status: 200, body: { items: [] }.to_json,
24
+ headers: { "Content-Type" => "application/json" })
25
+
26
+ result = recurring.list
27
+ expect(result["items"]).to eq([])
28
+ end
29
+ end
30
+
31
+ describe "#payments" do
32
+ it "lists payments linked to a recurring schedule" do
33
+ stub_request(:get, "#{base_url}/v1/merchant/test_merchant_key/recurringpayment/rp_123/payments")
34
+ .to_return(status: 200, body: { items: [] }.to_json,
35
+ headers: { "Content-Type" => "application/json" })
36
+
37
+ result = recurring.payments("rp_123")
38
+ expect(result["items"]).to eq([])
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe PushPay::Settlement do
6
+ let(:settlements) { described_class.new(PushPay.client) }
7
+ let(:base_url) { "https://api.pushpay.io" }
8
+
9
+ describe "#find" do
10
+ it "gets a settlement by key" do
11
+ stub_request(:get, "#{base_url}/v1/settlement/set_123")
12
+ .to_return(status: 200, body: { key: "set_123", name: "March Settlement" }.to_json,
13
+ headers: { "Content-Type" => "application/json" })
14
+
15
+ result = settlements.find("set_123")
16
+ expect(result["name"]).to eq("March Settlement")
17
+ end
18
+ end
19
+
20
+ describe "#list" do
21
+ it "lists settlements for a merchant" do
22
+ stub_request(:get, "#{base_url}/v1/merchant/test_merchant_key/settlements")
23
+ .to_return(status: 200, body: { items: [] }.to_json,
24
+ headers: { "Content-Type" => "application/json" })
25
+
26
+ result = settlements.list
27
+ expect(result["items"]).to eq([])
28
+ end
29
+ end
30
+
31
+ describe "#payments" do
32
+ it "lists payments within a settlement" do
33
+ stub_request(:get, "#{base_url}/v1/settlement/set_123/payments")
34
+ .to_return(status: 200, body: { items: [] }.to_json,
35
+ headers: { "Content-Type" => "application/json" })
36
+
37
+ result = settlements.payments("set_123")
38
+ expect(result["items"]).to eq([])
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe PushPay::Webhook do
6
+ let(:webhooks) { described_class.new(PushPay.client) }
7
+ let(:base_url) { "https://api.pushpay.io" }
8
+
9
+ describe "#find" do
10
+ it "gets a webhook by token" do
11
+ stub_request(:get, "#{base_url}/v1/merchant/test_merchant_key/webhook/wh_123")
12
+ .to_return(status: 200, body: { token: "wh_123" }.to_json,
13
+ headers: { "Content-Type" => "application/json" })
14
+
15
+ result = webhooks.find("wh_123")
16
+ expect(result["token"]).to eq("wh_123")
17
+ end
18
+ end
19
+
20
+ describe "#list" do
21
+ it "lists webhooks for a merchant" do
22
+ stub_request(:get, "#{base_url}/v1/merchant/test_merchant_key/webhooks")
23
+ .to_return(status: 200, body: { items: [] }.to_json,
24
+ headers: { "Content-Type" => "application/json" })
25
+
26
+ result = webhooks.list
27
+ expect(result["items"]).to eq([])
28
+ end
29
+ end
30
+
31
+ describe "#create" do
32
+ it "creates a webhook" do
33
+ params = { target: "https://example.com/webhook", eventTypes: ["payment_created"] }
34
+
35
+ stub_request(:post, "#{base_url}/v1/merchant/test_merchant_key/webhooks")
36
+ .with(body: params.to_json)
37
+ .to_return(status: 201, body: { token: "wh_new" }.to_json,
38
+ headers: { "Content-Type" => "application/json" })
39
+
40
+ result = webhooks.create(params)
41
+ expect(result["token"]).to eq("wh_new")
42
+ end
43
+ end
44
+
45
+ describe "#update" do
46
+ it "updates a webhook" do
47
+ stub_request(:put, "#{base_url}/v1/merchant/test_merchant_key/webhook/wh_123")
48
+ .to_return(status: 200, body: { token: "wh_123" }.to_json,
49
+ headers: { "Content-Type" => "application/json" })
50
+
51
+ webhooks.update("wh_123", { target: "https://example.com/new" })
52
+ end
53
+ end
54
+
55
+ describe "#delete" do
56
+ it "deletes a webhook" do
57
+ stub_request(:delete, "#{base_url}/v1/merchant/test_merchant_key/webhook/wh_123")
58
+ .to_return(status: 204, body: nil)
59
+
60
+ webhooks.delete("wh_123")
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "pushpay"
5
+ require "webmock/rspec"
6
+
7
+ RSpec.configure do |config|
8
+ config.expect_with :rspec do |expectations|
9
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
10
+ end
11
+
12
+ config.mock_with :rspec do |mocks|
13
+ mocks.verify_partial_doubles = true
14
+ end
15
+
16
+ config.shared_context_metadata_behavior = :apply_to_host_groups
17
+ config.filter_run_when_matching :focus
18
+ config.example_status_persistence_file_path = "spec/examples.txt"
19
+ config.disable_monkey_patching!
20
+ config.warnings = true
21
+
22
+ if config.files_to_run.one?
23
+ config.default_formatter = "doc"
24
+ end
25
+
26
+ config.order = :random
27
+ Kernel.srand config.seed
28
+
29
+ config.before(:each) do
30
+ WebMock.disable_net_connect!
31
+ PushPay.reset!
32
+ PushPay.configure do |c|
33
+ c.client_id = "test_client_id"
34
+ c.client_secret = "test_client_secret"
35
+ c.merchant_key = "test_merchant_key"
36
+ c.organization_key = "test_org_key"
37
+ end
38
+
39
+ stub_request(:post, "https://auth.pushpay.com/pushpay/oauth/token")
40
+ .to_return(
41
+ status: 200,
42
+ body: { access_token: "test_token", token_type: "bearer", expires_in: 3600 }.to_json,
43
+ headers: { "Content-Type" => "application/json" }
44
+ )
45
+ end
46
+
47
+ config.after(:each) do
48
+ WebMock.reset!
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pushpay-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Eduardo Souza
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-03-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.21'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.21'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dotenv
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '13.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '13.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.12'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.12'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.50'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.50'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.18'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.18'
125
+ description: Ruby gem for integrating with the PushPay payment processing API. Supports
126
+ payments, recurring payments, anticipated payments, funds, merchants, organizations,
127
+ settlements, batches, and webhooks.
128
+ email:
129
+ - eduardo@eduardosouza.com
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - CHANGELOG.md
135
+ - LICENSE.txt
136
+ - README.md
137
+ - lib/pushpay.rb
138
+ - lib/pushpay/anticipated_payment.rb
139
+ - lib/pushpay/base.rb
140
+ - lib/pushpay/batch.rb
141
+ - lib/pushpay/client.rb
142
+ - lib/pushpay/configuration.rb
143
+ - lib/pushpay/errors.rb
144
+ - lib/pushpay/fund.rb
145
+ - lib/pushpay/merchant.rb
146
+ - lib/pushpay/organization.rb
147
+ - lib/pushpay/payment.rb
148
+ - lib/pushpay/recurring_payment.rb
149
+ - lib/pushpay/settlement.rb
150
+ - lib/pushpay/version.rb
151
+ - lib/pushpay/webhook.rb
152
+ - spec/examples.txt
153
+ - spec/pushpay/anticipated_payment_spec.rb
154
+ - spec/pushpay/batch_spec.rb
155
+ - spec/pushpay/client_spec.rb
156
+ - spec/pushpay/configuration_spec.rb
157
+ - spec/pushpay/fund_spec.rb
158
+ - spec/pushpay/merchant_spec.rb
159
+ - spec/pushpay/organization_spec.rb
160
+ - spec/pushpay/payment_spec.rb
161
+ - spec/pushpay/recurring_payment_spec.rb
162
+ - spec/pushpay/settlement_spec.rb
163
+ - spec/pushpay/webhook_spec.rb
164
+ - spec/spec_helper.rb
165
+ homepage: https://github.com/esouza/pushpay-ruby
166
+ licenses:
167
+ - MIT
168
+ metadata:
169
+ homepage_uri: https://github.com/esouza/pushpay-ruby
170
+ source_code_uri: https://github.com/esouza/pushpay-ruby
171
+ changelog_uri: https://github.com/esouza/pushpay-ruby/blob/main/CHANGELOG.md
172
+ post_install_message:
173
+ rdoc_options: []
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: 2.7.0
181
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ requirements: []
187
+ rubygems_version: 3.5.21
188
+ signing_key:
189
+ specification_version: 4
190
+ summary: Ruby gem for PushPay payment API integration
191
+ test_files: []