payment_kit 1.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +102 -0
- data/LICENSE.txt +21 -0
- data/README.md +1008 -0
- data/Rakefile +41 -0
- data/app/controllers/payment_kit/webhook_controller.rb +45 -0
- data/config/routes.rb +5 -0
- data/lib/payment_kit/client.rb +449 -0
- data/lib/payment_kit/configuration.rb +117 -0
- data/lib/payment_kit/engine.rb +10 -0
- data/lib/payment_kit/errors.rb +103 -0
- data/lib/payment_kit/instrumentation.rb +109 -0
- data/lib/payment_kit/namespace.rb +27 -0
- data/lib/payment_kit/notification_adapter.rb +21 -0
- data/lib/payment_kit/resources/catalog.rb +36 -0
- data/lib/payment_kit/resources/customers.rb +62 -0
- data/lib/payment_kit/resources/invoices.rb +64 -0
- data/lib/payment_kit/resources/payments.rb +71 -0
- data/lib/payment_kit/resources/subscriptions.rb +129 -0
- data/lib/payment_kit/version.rb +6 -0
- data/lib/payment_kit/webhook.rb +64 -0
- data/lib/payment_kit.rb +204 -0
- metadata +90 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d2f63c858885c4bf00426e709a6475f55231eb337acb424be9d8e7b565e1ce4b
|
|
4
|
+
data.tar.gz: b4abb4c5010b83a53cea2bfdb534b8899dfbdff7cc2085465c2004f05fed1918
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 45f546f9b176b82079e97f13238175164ccced5dd719aafb6b605e144e9eb135babcd7ff64b00168911c2328590133449a3352fcfffafcf3a3214f8345f41d63
|
|
7
|
+
data.tar.gz: 006fdae0b337efd41a072f19295b6bdbfd6dd99edcc06845aef006702e2798a1232d78cbaccd19858cafb457d4e37739ac06c8bb1863a2e6f0ae0f5b277c780c
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
## [1.0.0] - 2026-08-17
|
|
2
|
+
|
|
3
|
+
First public release.
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Webhook event bus: `subscribe` / `all` / `instrument` / `process_webhook`
|
|
8
|
+
- `PaymentKit::Webhook.construct_event` with multi-secret verification (supports
|
|
9
|
+
the `roll-secret` rotation grace period)
|
|
10
|
+
- Optional `PaymentKit::Engine` + `WebhookController` (Rails)
|
|
11
|
+
- `PaymentKit.event_retriever` hook to deduplicate redelivered webhooks, and
|
|
12
|
+
`PaymentKit.error_handler` to report subscriber failures without triggering
|
|
13
|
+
PaymentKit's 5-attempt retry schedule
|
|
14
|
+
- `PaymentKit::CardError` (HTTP 402) and `PaymentKit::ConflictError` (HTTP 409)
|
|
15
|
+
- Errors expose `error_code`, `retryable?`, `problem` and RFC 7807 extension
|
|
16
|
+
members such as `invoice_id` / `subscription_id`
|
|
17
|
+
- `PaymentKit::Client::AuthenticationError` and friends as aliases of the
|
|
18
|
+
module-level error classes, for applications written against a nested namespace
|
|
19
|
+
- `idempotency_key:` on every write method; `PUT`/`PATCH` now also send an
|
|
20
|
+
auto-generated key, reused across internal retries
|
|
21
|
+
- Subscription endpoints: `schedule_cancellation`, `cancel_scheduled_cancellation`,
|
|
22
|
+
`cancel_scheduled_pause`, `cancel_pending_change`, `retrieve_change_request`,
|
|
23
|
+
`apply_subscription_changes`
|
|
24
|
+
- Customer credit endpoints: `set_credit_balance`, `create_credit_note`,
|
|
25
|
+
`list_credit_notes`, `list_customers`
|
|
26
|
+
- Invoice endpoints: `list_invoices`, `list_invoice_items`
|
|
27
|
+
- Payment endpoints: `create_payment_method`, `deactivate_payment_method`,
|
|
28
|
+
`list_payment_intents`, `list_refunds_by_intent`, `list_attempts_by_intent`
|
|
29
|
+
- Catalog endpoints: `retrieve_product`, `create_product`, `update_product`,
|
|
30
|
+
`list_product_prices`
|
|
31
|
+
- `PaymentKit::Instrumentation` with `request_begin` / `request_end` hooks around
|
|
32
|
+
outbound API calls, carrying `method`, `path`, `status`, `duration`,
|
|
33
|
+
`num_retries` and `request_id`
|
|
34
|
+
- `Client#raw_request` escape hatch for endpoints the gem does not wrap, with
|
|
35
|
+
`account_scoped: false` for surfaces outside the account prefix (customer portal)
|
|
36
|
+
- `PaymentKit::PermissionError` (HTTP 403) and `PaymentKit::SignatureVerificationError`,
|
|
37
|
+
both subclasses of `AuthenticationError` so existing rescues keep working
|
|
38
|
+
- `PaymentKit.subscriber_error_handler` for per-subscriber failure isolation,
|
|
39
|
+
complementing the request-scoped `error_handler`
|
|
40
|
+
- `PaymentKit.configure` accepts a zero-arity block, evaluated against the module,
|
|
41
|
+
for registering subscribers without repeating the receiver
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
|
|
45
|
+
- `409` is retried only when PaymentKit flags it (`retryable: true` or a known
|
|
46
|
+
side-effect-free `error_code` such as `invoice_locked`) instead of always
|
|
47
|
+
- Collection paths now match the API reference (`/customers/`, `/prices/`,
|
|
48
|
+
`/products/`, `/payments/intents/`), avoiding a `307` round trip
|
|
49
|
+
- A webhook body that verifies but fails to parse raises `InvalidRequestError`
|
|
50
|
+
rather than `AuthenticationError`, and is reported correctly when several
|
|
51
|
+
signing secrets are configured
|
|
52
|
+
- `WebhookController` answers `401` for a bad signature (was `400`), `400` for an
|
|
53
|
+
unparseable body, and reads `request.raw_post` so verification sees the exact
|
|
54
|
+
bytes after middleware has consumed the stream
|
|
55
|
+
- `instrument` raises `InvalidRequestError` for an event with no `type` instead
|
|
56
|
+
of dispatching it under the bare namespace
|
|
57
|
+
- A `2xx` response with an unparseable body raises `APIError` instead of
|
|
58
|
+
silently returning `{}`
|
|
59
|
+
- Endpoint methods moved into `PaymentKit::Resources::*` modules
|
|
60
|
+
- HTTP 403 raises `PermissionError` rather than a bare `AuthenticationError`
|
|
61
|
+
- A numeric `Retry-After` header now drives the retry delay (capped at 32s)
|
|
62
|
+
instead of the exponential backoff curve
|
|
63
|
+
- `request_id` falls back to the `Request-Id` response header when the error body
|
|
64
|
+
does not carry one
|
|
65
|
+
- Depend on `activesupport` for `ActiveSupport::Notifications`
|
|
66
|
+
|
|
67
|
+
### Documentation
|
|
68
|
+
|
|
69
|
+
- RDoc API reference: `rake rdoc` / `rake rerdoc` build into `doc/`, and the
|
|
70
|
+
gemspec carries `rdoc_options` + `extra_rdoc_files` so
|
|
71
|
+
`gem install payment_kit --document=rdoc` produces the same output. The doc
|
|
72
|
+
task degrades gracefully when RDoc is absent, so `rake spec` and `rake rubocop`
|
|
73
|
+
are unaffected
|
|
74
|
+
- Every public class, module, constant, attribute and method now carries an RDoc
|
|
75
|
+
comment (100% documented, up from 45%); internal helpers are marked `:nodoc:`
|
|
76
|
+
- Converted the remaining YARD-style `@param`/`@return`/`@raise`/`@deprecated`
|
|
77
|
+
tags and `{Reference}` links to RDoc markup, which RDoc rendered literally
|
|
78
|
+
- README documents every implemented endpoint with a copy-paste Ruby example,
|
|
79
|
+
plus a method index mapping each client method to its HTTP verb and path
|
|
80
|
+
- Endpoint parameters, required fields and enum values now follow the
|
|
81
|
+
[PaymentKit API reference](https://docs.paymentkit.com/api-reference/introduction):
|
|
82
|
+
customers use `first_name`/`last_name`, credit amounts use `amount_atom`,
|
|
83
|
+
`create_credit_note` documents its four `reason` values, `update_subscription_items`
|
|
84
|
+
documents `proration_behavior` as required, and change requests document
|
|
85
|
+
`item_changes` actions and `apply_at_end`
|
|
86
|
+
- Removed third-party payment-provider terminology from the README, CHANGELOG and
|
|
87
|
+
source comments; the architecture is described in PaymentKit's own terms
|
|
88
|
+
- Corrected the stated runtime dependencies: the gem requires `activesupport`
|
|
89
|
+
(Rails remains optional, needed only for the mountable webhook engine)
|
|
90
|
+
- Corrected the client overview: `POST`/`PUT`/`PATCH` all send an automatic
|
|
91
|
+
`Idempotency-Key`, and `409` is retried only when flagged retryable
|
|
92
|
+
|
|
93
|
+
### Deprecated
|
|
94
|
+
|
|
95
|
+
- `create_balance_transaction` — use `set_credit_balance`. The endpoint sets an
|
|
96
|
+
absolute target balance, not a delta.
|
|
97
|
+
- `change_plan` — PaymentKit documents it as the legacy single-call endpoint,
|
|
98
|
+
planned for deprecation. Use the change-request workflow.
|
|
99
|
+
|
|
100
|
+
## [0.1.0] - 2026-08-16
|
|
101
|
+
|
|
102
|
+
- Initial PaymentKit Ruby HTTP client (`Configuration`, `Client`, typed errors, webhook verification)
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ammad Javaid
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|