Skip to content

Align Payment DTO with current Whop payments schema#1

Merged
ToluTourialai merged 2 commits into
masterfrom
fix/payment-dto-current-schema
Jun 2, 2026
Merged

Align Payment DTO with current Whop payments schema#1
ToluTourialai merged 2 commits into
masterfrom
fix/payment-dto-current-schema

Conversation

@ToluTourialai

Copy link
Copy Markdown
Collaborator

Problem

The Payment DTO required a flat integer amount field that no longer exists in Whop's current payments API (verified against retrieve-payment docs). As a result payments->get() and ->refund() would throw MissingArgumentsException on every real response.

Fix

  • Removed the non-existent required amount field.
  • Added the real nullable monetary fields: total, subtotal, usdTotal, refundedAmount (all ?float). Kept nullable to faithfully mirror the API (number | null) — null means "not finalized / not provided", which is distinct from a genuine 0 and must not be conflated in a payments SDK.
  • applicationFee now read from the application_fee object (.amount), with flat-numeric and application_fee_amount fallbacks. Type ?int?float.
  • subStatus now reads substatus (current field name), falling back to legacy sub_status.

Breaking change

Payment::$amount is removed (it never matched the live schema). Documented in CHANGELOG under Unreleased.

Verification

  • php-cs-fixer: clean
  • PHPStan (level max): clean
  • PHPUnit: 334 tests pass
  • Infection: 97% MSI (Payment.php 100%)

Note: RefundResponse::$amount is left as-is — it's already nullable so it degrades gracefully (non-breaking); can be aligned separately if desired.

The Payment DTO required a flat integer `amount` field that no longer
exists in Whop's payments API, so payments->get() and ->refund() threw
MissingArgumentsException on every real response.

Replace `amount` with the actual nullable monetary fields (total,
subtotal, usdTotal, refundedAmount as ?float), read the application fee
from the `application_fee` object (.amount), and read `substatus`
(current name) with a `sub_status` fallback.
…n RefundResponse amount to ?float

- PaymentResourceTest: replace removed `amount` fixture with `total`, assert it survives resource->DTO path
- RefundResponse: $amount ?int -> ?float so fractional refund amounts aren't dropped (+ tests)
@ToluTourialai ToluTourialai merged commit 36210a5 into master Jun 2, 2026
2 checks passed
@ToluTourialai ToluTourialai deleted the fix/payment-dto-current-schema branch June 2, 2026 10:17
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.

2 participants