Fix v2.0.0 examples to use resource-based API#15
Merged
Merged
Conversation
- create_purchase.php: \$chip->createPurchase() → \$chip->purchases->create()
- get_purchase.php: \$chip->getPurchase() → \$chip->purchases->get()
- payment_methods.php: \$chip->getPaymentMethods() → \$chip->paymentMethods->list('MYR')
- public_key.php: \$chip->getPublicKey() → \$chip->publicKey->get()
- webhook.php: \$chip->getPublicKey() → \$chip->publicKey->get()
- callback.php: \$chip->getPublicKey() → \$chip->publicKey->get()
- account_balance.php: \$chip->getBalance() → \$chip->account->balance()
- client_crud.php: \$chip->createClient() → \$chip->clients->create(), etc.
- statements.php: \$chip->listStatements() → \$chip->statements->list(), etc.
- webhook_management.php: \$chip->listWebhooks() → \$chip->webhooks->list(), etc.
- purchase_builder.php: fix to use actual PurchaseBuilder::create() API with real method names
Co-Authored-By: Claude Opus 4.7 <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.
What does this change?
This PR updates the SDK example scripts to align with a major architectural refactor in the underlying
chip-fpxlibrary. The SDK has transitioned from a flat method structure on the mainChipApiclass to a more organized, resource-grouped approach (Domain-Driven Design).Why is this necessary?
The previous examples became obsolete and would result in "Method not found" errors because the SDK now encapsulates functionality within specific resource properties.
Key Improvements:
$chip->purchases->create()instead of$chip->createPurchase()). This affects purchases, clients, accounts, payment methods, public keys, statements, and webhooks.create()entry point and cleaner method names (removing thewithprefix).webhook_management.php, the model properties were updated to match the latest API schema whereurlhas been renamed tocallbackandevent_typeis now handled viatitle..gitattributesfile to ensure that development-related folders (/tests,/examples) and configuration files are excluded when the package is installed via Composer or exported, reducing the package footprint.Asana / Jira / Trello task link
How to test
chip-fpxSDK.examples/config.php.php examples/api/account_balance.phpand verify it returns the current balance using the new$chip->account->balance()syntax.php examples/api/client_crud.phpand verify that clients can be created, listed, and updated via the$chip->clientsresource.php examples/api/create_purchase.phpandexamples/api/purchase_builder.phpto ensure the checkout URL generation is still functional.webhook_management.phpby checking if webhooks are correctly listed and created using the newcallbackandtitlefields.git archiveto ensure the files listed in.gitattributesare correctly excluded.Potential Risks & Senior Review Items
purchases,clients,statements,webhooks) to ensure they match the SDK's property names exactly.paymentMethods->list('MYR')now includes a currency string. Review if this should be hardcoded or pulled from a config.url/event_typetocallback/titleis consistent with the backend API specifications.Is this PR warrant an automatic approval?
No. While these are example files, they serve as the primary documentation for integration. A manual verification is required to ensure no typos were introduced in the method chaining and that the builder methods (like
addProduct) align with the latest SDK implementation.Images