Skip to content

Adopt latest OpenAPI spec from vatlify#29

Merged
sandervanhooft merged 5 commits into
mainfrom
claude/tender-tesla-86c01c
May 29, 2026
Merged

Adopt latest OpenAPI spec from vatlify#29
sandervanhooft merged 5 commits into
mainfrom
claude/tender-tesla-86c01c

Conversation

@sandervanhooft
Copy link
Copy Markdown
Member

@sandervanhooft sandervanhooft commented May 28, 2026

Summary

  • Replace openapi.yaml with the latest bundled spec from sandervanhooft/vatlify main (docs/openapi/dist/openapi.bundled.yaml), adopted verbatim.
  • Add the new webhook event-type constants for parity with the spec: payment.failed, subscription.resumed, checkout.paid, checkout.failed, checkout.canceled.
  • Rename Vatly\API\Types\WebhookEventVatly\API\Types\WebhookEventName to remove the collision with Vatly\API\Resources\WebhookEvent and match the eventName field it documents (and the sibling *Status enum naming). Safe to rename at v0.1.0-alpha.
  • Adopt the inline mandate summary now exposed on subscription responses (payment method on file).
  • Standardize on US English: rename Subscription::$cancelledAt$canceledAt to match the spec.

What the new spec brings in

  • Idempotency: Idempotency-Key request params, Idempotent-Replayed response headers, and 409 Conflict responses across mutating endpoints (SDK already sends idempotency keys).
  • Schemas tightened with additionalProperties: false throughout.
  • Money: currency-aware decimal precision via a oneOf over ISO 4217 minor units (2 / 0 / 3 decimals) — replaces the earlier single permissive pattern. Validation is server-side; Money stays a passthrough DTO.
  • Webhook events: createdAt / testmode fields (now required) and new event types.
  • Subscription mandate: subscription responses now carry an inline mandate object (method, maskedIdentifier), or null when the subscription has no mandate yet.
  • US-English canceledAt: the subscription schema now uses canceledAt (was cancelledAt), and the resume-endpoint prose keys resumability off status (on_grace_period) rather than endedAt/endsAt.

Mandate support (SDK)

  • New Vatly\API\Types\Mandate DTO (method string + nullable maskedIdentifier), mirroring the Money DTO pattern.
  • ResourceFactory hydrates mandate, handling the null case.
  • Subscription::$mandate typed as ?Mandate.
  • docs/Subscriptions.md properties table updated; test coverage added (incl. the null-mandate case).

Notes

  • While adopting, we caught that vatlify emitted subscription_cancellation_grace_period_completed (all-underscore) for one event, inconsistent with its dot-notation siblings — root cause was EventNameTransformer only inserting the . for *Was*/*Has* class names. Reported and fixed upstream (sandervanhooft/vatlify#1452); this PR adopts the corrected dot form subscription.cancellation_grace_period_completed.
  • The cancelledAtcanceledAt (US English) standardization and the currency-aware Money validation were filed upstream (sandervanhooft/vatlify#1454); both have now shipped and are adopted here. The SDK property rename keeps hydration matching the JSON key.
  • docs/Webhooks.md updated with the new events and the renamed class reference.

Test plan

  • composer test — 109 tests, 562 assertions passing
  • openapi.yaml validates as YAML

sandervanhooft and others added 5 commits May 29, 2026 00:13
…t constants

Sync openapi.yaml with vatlify main's bundled spec (idempotency support,
currency enum, additionalProperties, webhook createdAt/testmode, new event
types) and add the matching webhook event-type constants to the SDK.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Avoids the name collision with Resources\WebhookEvent and matches the
`eventName` field it documents plus the sibling *Status enum naming.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The latest vatlify OpenAPI spec exposes an inline `mandate` summary
(payment method on file) on subscription responses. Adopt the spec
verbatim and add SDK support: a minimal Mandate DTO, ResourceFactory
hydration (with null handling), the Subscription::$mandate property,
docs, and test coverage including the null case.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…re Money)

vatlify shipped the two fixes from sandervanhooft/vatlify#1454:
- Standardize on US English: `cancelledAt` -> `canceledAt` on the
  Subscription schema (and resume-endpoint prose keyed off `status`
  rather than `endedAt`/`endsAt`).
- Money is now validated currency-aware via a `oneOf` over ISO 4217
  minor units (2 / 0 / 3 decimals) instead of one permissive pattern.

Adopt the spec verbatim and rename `Subscription::$cancelledAt` ->
`$canceledAt` so hydration keeps matching the JSON key. `Money` stays a
passthrough DTO (server enforces precision).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The properties table, helper-method examples, and status list had drifted
from src/API/Resources/Subscription.php and src/API/Types/SubscriptionStatus.php.

- Replace invented fields (planId, currentPeriodStart/End, trialStart/End,
  metadata, createdAt) with the real resource properties, and add the ones
  that were missing (resource, name, description, billingAddress, basePrice,
  quantity, interval, intervalCount, renewedAt/Until, nextRenewalAt, links).
- Fix helper-method example: isActive/isTrial/isOnGracePeriod/isCanceled
  (drop the non-existent isCreated/onTrial/onGracePeriod/isPaused).
- Add the missing `canceled` status; keep the verified `created`/`paused`
  statuses (both defined in SubscriptionStatus.php and the spec enum) and
  align descriptions with SubscriptionStatus.
- Update code examples to real property names (subscriptionPlanId, renewedUntil).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sandervanhooft sandervanhooft merged commit 3570831 into main May 29, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant