Align Payment DTO with current Whop payments schema#1
Merged
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
PaymentDTO required a flat integeramountfield that no longer exists in Whop's current payments API (verified against retrieve-payment docs). As a resultpayments->get()and->refund()would throwMissingArgumentsExceptionon every real response.Fix
amountfield.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 genuine0and must not be conflated in a payments SDK.applicationFeenow read from theapplication_feeobject (.amount), with flat-numeric andapplication_fee_amountfallbacks. Type?int→?float.subStatusnow readssubstatus(current field name), falling back to legacysub_status.Breaking change
Payment::$amountis removed (it never matched the live schema). Documented in CHANGELOG under Unreleased.Verification
Note:
RefundResponse::$amountis left as-is — it's already nullable so it degrades gracefully (non-breaking); can be aligned separately if desired.