Open
Conversation
Prevents deprecation warnings when API responses include fields not explicitly declared as class properties. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Ensures consistent behavior regardless of the underlying HTTP client's default protocol version setting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds errors property to AbstractLineItem and AbstractTransaction so validation errors from the API are accessible on nested objects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Exposes the account id property and allows passing include params (churn_recognition, churn_when_zero_mrr) to Account::retrieve(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removes envelope wrapping requirement from callers — the SDK now wraps params in subscription_event internally. Adds retracted_event_id for disable support and validation error tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds UpdateTrait to Invoice and introduces static methods for update-status and disable operations with corresponding tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace deprecated whitelist/filter config with coverage/include for PHPUnit 10+ compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the PHP SDK to support additional API capabilities (invoice update/disable/update-status actions, account “include” query params, and richer error payloads), and aligns subscription event update/delete/create calls to a flat-params calling style with request-body envelope handled internally.
Changes:
- Add invoice update capabilities (generic update via
UpdateTrait, plusupdateStatus()anddisable()helpers) and corresponding unit tests. - Extend “show” retrieval to support optional query params (used by
Account::retrieve()include flags) and expand account fields tested (addsid). - Adjust subscription event update/delete request formatting (flat params at call site; internal envelope wrapping) and add
retracted_event_id+ additional request-body assertions in tests.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/SubscriptionEventTest.php | Updates tests to use flat params for create/update/destroy, adds request-body assertions, adds disable/missing-param cases. |
| tests/Unit/InvoiceTest.php | Adds tests for invoice status updates, disabling, updating, and nested errors on line items/transactions. |
| tests/Unit/Http/ClientTest.php | Asserts protocol version is set to HTTP/1.1. |
| tests/Unit/AccountTest.php | Adds account id assertion and tests retrieve with include query params. |
| src/Transactions/AbstractTransaction.php | Adds errors field to support error payloads on transactions. |
| src/SubscriptionEvent.php | Removes envelope-unwrapping constructor and adds retracted_event_id. |
| src/Service/UpdateWithParamsTrait.php | Updates docstring to reflect flat-params usage. |
| src/Service/ShowTrait.php | Adds optional query parameters support to “show” retrieval. |
| src/Service/RequestService.php | Changes subscription-event update/destroy-with-params to accept flat params and internally wrap request body. |
| src/Service/DestroyWithParamsTrait.php | Updates docstring to reflect flat-params usage. |
| src/Resource/AbstractModel.php | Adds #[\AllowDynamicProperties] attribute to suppress dynamic-property deprecations. |
| src/LineItems/AbstractLineItem.php | Adds errors field to support error payloads on invoice line items. |
| src/Invoice.php | Adds update support and new endpoints (updateStatus, disable), plus required constants for UpdateTrait. |
| src/Http/Client.php | Forces PSR-7 request protocol version to 1.1. |
| src/Account.php | Adds id property and phpdoc. |
| phpunit.xml.dist | Updates PHPUnit coverage configuration to <coverage><include>… format. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Accept both flat and wrapped params in updateWithParams/destroyWithParams for backward compatibility with existing SDK consumers - Restore SubscriptionEvent constructor envelope unwrapping - Improve validation error message clarity Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…n types - Extract duplicated validation into normalizeEnvelopeParams() and use ENTRY_KEY constant - Merge get()/getWithQuery() into single get() method with optional $query param - Add return type declarations to Invoice::updateStatus() and Invoice::disable() - Fix Invoice::disable() to send disabled flag in request body - Default $errors to null on AbstractLineItem and AbstractTransaction - Update phpunit.xml.dist schema to 11.0 - Add negative test for Invoice::update() with missing resource ID Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Batch of PHP SDK improvements covering new endpoints, interface fixes, bug fixes, and DX improvements.
Endpoint Support
errorson line items and transactionsincludeparams onv1/accountendpoint (churn_recognition,churn_when_zero_mrr)idfield to Retrieve Account Details responseupdate-statusendpoint supportdisableendpoint supportupdateviaUpdateTraitInterface Fixes
retracted_event_idfor disable support['subscription_event' => [...]]shape still acceptedBug Fixes
#[AllowDynamicProperties]to prevent PHP 8.2+ deprecation warningsDX Improvements
phpunit.xml.distdeprecation warnings for PHPUnit 10+ compatibilitynormalizeEnvelopeParams()withENTRY_KEYconstantget()/getWithQuery()into single method with optional$queryparamBackwards compatibility review
All changes are backwards compatible for public API consumers. No existing code needs modification.
Invoice::update(),updateStatus(),disable()Account::$idpropertySubscriptionEvent::$retracted_event_idAbstractLineItem::$errors,AbstractTransaction::$errorsShowTrait::retrieve()gains optional$queryparamupdateWithParams()/destroyWithParams()accept flat params['subscription_event' => [...]]format still acceptedSubscriptionEventconstructor accepts flat paramsENTRY_KEY,RESOURCE_NAME,RESOURCE_IDconstants#[\AllowDynamicProperties]onAbstractModelphpunit.xml.distschema 9.3 → 11.0RequestService::getWithQuery()merged intoget()SchemaInvalidExceptionupdateWithParams/destroyWithParamsreferenced undefined$idon mainLinear tickets
Test plan
Testing instructions
Test account:
WiktorOnboarding(ID:acc_d0ea225e-f0f1-40ab-92cf-659dce5f2b76). To obtain the API key, impersonatewiktor.plaga@chartmogul.comin the admin panel and navigate to Profile > API Keys.PIP-304: Validation errors on line items and transactions
What changed:
LineItemandTransactionobjects now expose anerrorsproperty from the API response.How to test:
validation_type=allorvalidation_type=invalidto trigger error payloadserrorsis accessible on line items and transactionsExpected:
errorsis eithernull(valid) or an associative array of field-level errors. No "undefined property" warnings.PIP-76: Account include params (churn_recognition, churn_when_zero_mrr)
What changed:
Account::retrieve()now accepts an optional second argument for query parameters.How to test:
Expected: Both calls succeed. The second call sends
?churn_recognition=1&churn_when_zero_mrr=1as query params (visible in network/debug logs).PIP-120: Account ID in retrieve response
What changed: The
idproperty is now exposed on theAccountobject.How to test:
Expected:
$account->idreturns a string likeacct_XXXXXXXX-...(notnull).Invoice update-status endpoint
What changed: New static method
Invoice::updateStatus($uuid, $data).How to test:
Expected: Returns an
Invoiceobject. The API sends aPATCHto/v1/invoices/{uuid}/update-statuswith body{"status": "void"}.Invoice disable endpoint
What changed: New static method
Invoice::disable($uuid).How to test:
Expected: Returns an
Invoiceobject. The API sends aPATCHto/v1/invoices/{uuid}/disablewith body{"disabled": true}.Invoice generic update via UpdateTrait
What changed:
Invoice::update()is now available for general-purpose invoice updates.How to test:
Expected: Returns an
Invoiceobject. SendsPATCH /v1/invoices/{uuid}with body{"currency": "EUR"}.SubscriptionEvent: flat params interface
What changed:
updateWithParams()anddestroyWithParams()now accept flat params (nosubscription_eventenvelope needed). The old wrapped format still works for backward compatibility.How to test:
Expected: Both flat and wrapped param styles work. No errors or deprecation warnings.
SubscriptionEvent: disable (retracted_event_id)
What changed:
retracted_event_idfield is now supported for disabling subscription events.How to test:
Expected: Returns a
SubscriptionEventwithretracted_event_idaccessible (may benull).PIP-94: AllowDynamicProperties (PHP 8.2+)
What changed:
#[\AllowDynamicProperties]attribute added toAbstractModelto suppress deprecation warnings.How to test:
Expected: No
Deprecated: Creation of dynamic propertywarnings on PHP 8.2+. On PHP 7.x/8.0/8.1, the attribute is silently ignored (treated as a comment).PIP-190: HTTP protocol version frozen to 1.1
What changed: All SDK requests now explicitly use HTTP/1.1.
How to test:
Expected: SDK requests use HTTP/1.1. No timeout issues related to HTTP/2 chunked transfer encoding.
DX: phpunit.xml.dist fix
What changed: Replaced deprecated
<filter><whitelist>with<coverage><include>for PHPUnit 10+.How to test:
Expected: No
phpunit.xml.distdeprecation warnings in test output. All unit tests pass.🤖 Generated with Claude Code