Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
dea634d
Bump PHP requirement to ^8.0 and fix nullable type declarations
wzul May 13, 2026
2c1e7d2
Add custom exception hierarchy for API error handling
wzul May 13, 2026
e7509b9
Add error handling, PSR-3 logging, and configurable timeout
wzul May 13, 2026
4329ab3
Add PHPStan and PHP-CS-Fixer configuration
wzul May 13, 2026
b768d69
Add PurchaseBuilder fluent API
wzul May 13, 2026
ea64a3f
Expand test coverage
wzul May 13, 2026
654b6f1
Add GitHub Actions CI and PR summary automation
wzul May 13, 2026
414b0a0
Update documentation
wzul May 13, 2026
7bd9f5d
Add .php-cs-fixer.cache to .gitignore
wzul May 13, 2026
6292a94
Merge main into feature/sdk-improvements
wzul May 13, 2026
b69db8d
Update GitHub Actions to latest versions and add release automation
wzul May 13, 2026
d5e4a8a
Expand test coverage and fix PHPStan errors from billing models
wzul May 13, 2026
4bf7a04
Add required description to composer.json for strict validation
wzul May 13, 2026
75c4848
Bump minimum dependency versions based on latest stable releases
wzul May 13, 2026
05719f4
Bump PHP requirement to 8.1 and upgrade dev dependencies to latest
wzul May 13, 2026
224277f
Update CHANGELOG.md for v1.2.0 with all recent changes
wzul May 13, 2026
113ced2
Add missing endpoints and models for full CHIP Collect API parity
wzul May 13, 2026
93ada0e
Update examples to PHP 8.1 and add new endpoint demos
wzul May 14, 2026
df35a5f
Fix README docs and CHANGELOG date for v1.2.0
wzul May 14, 2026
937179e
Fix model properties and types to match OpenAPI spec
wzul May 14, 2026
ac26660
Fix JsonMapper compatibility for array generic annotations
wzul May 14, 2026
86117c9
Bump version to 2.0.0 and add migration guide
wzul May 14, 2026
b751b0f
Rewrite SDK to resource-based architecture with HTTP abstraction for …
wzul May 14, 2026
2b068e4
Add PHP 8.4 to CI test matrix
wzul May 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Changelog

on:
pull_request:
branches: [main]
paths:
- 'lib/**'
- 'tests/**'
- 'composer.json'

jobs:
check:
runs-on: ubuntu-latest
name: Check CHANGELOG updated

steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Verify CHANGELOG.md was updated
run: |
git fetch origin ${{ github.base_ref }} --depth=1
if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -q 'CHANGELOG.md'; then
echo "CHANGELOG.md was updated"
exit 0
else
echo "ERROR: CHANGELOG.md was not updated. Please document your changes."
exit 1
fi
81 changes: 81 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1', '8.2', '8.3', '8.4']

name: PHP ${{ matrix.php-version }}

steps:
- uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none

- name: Validate composer.json
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run tests
run: composer test

static-analysis:
runs-on: ubuntu-latest
name: Static Analysis

steps:
- uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run PHPStan
run: composer phpstan

code-style:
runs-on: ubuntu-latest
name: Code Style

steps:
- uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Check code style
run: composer cs-check
49 changes: 49 additions & 0 deletions .github/workflows/pr-summary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Auto Generate PR Summary

on:
pull_request:
types: [opened, synchronize]

jobs:
generate-summary:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'

- name: Install dependencies
run: pip install requests

- name: Get PR Diff
run: |
git diff origin/${{ github.base_ref }}...HEAD > pr_diff.txt

- name: Generate Summary with Ollama Cloud
id: ollama
env:
OLLAMA_API_KEY: ${{ secrets.OLLAMA_API_KEY }}
GH_TOKEN: ${{ github.token }}
run: |
gh pr view ${{ github.event.pull_request.number }} --json body -q .body > current_body.md || touch current_body.md
python scripts/generate_pr_summary.py pr_diff.txt current_body.md > summary.md

echo "SUMMARY<<EOF" >> $GITHUB_ENV
cat summary.md >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Update PR Description
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr edit ${{ github.event.pull_request.number }} --body "$SUMMARY"
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
create-release:
runs-on: ubuntu-latest
name: Create GitHub Release

steps:
- uses: actions/checkout@v6

- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"

- name: Extract release notes from CHANGELOG
id: notes
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
# Extract section for this version from CHANGELOG.md
awk "/^## \\[$VERSION\\]/ {flag=1; next} /^## \\[/ {flag=0} flag" CHANGELOG.md > release_notes.md
if [ ! -s release_notes.md ]; then
echo "No release notes found for $VERSION in CHANGELOG.md"
exit 1
fi
echo "notes<<EOF" >> "$GITHUB_OUTPUT"
cat release_notes.md >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.version.outputs.VERSION }}
body_path: release_notes.md
draft: false
prerelease: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ vendor/
# misc
composer.lock
.DS_Store
.php-cs-fixer.cache

# text editor settings
.vscode/
Expand Down
35 changes: 35 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/lib')
->in(__DIR__ . '/tests')
->in(__DIR__ . '/examples');

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
138 changes: 138 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.0.0] - 2026-05-14

### Added

- Add custom exception hierarchy for API error handling (`ChipApiException`, `AuthenticationException`, `NotFoundException`, `ValidationException`, `ClientException`, `ServerException`)
- Add PSR-3 logger injection support for request/response observability
- Add configurable request timeout via constructor `$config` array
- Add `PurchaseBuilder` fluent API for constructing purchase objects
- Add PHPStan (level 8) and PHP-CS-Fixer configuration
- Add GitHub Actions CI workflow (tests on PHP 8.1–8.3, static analysis, code style)
- Add GitHub Actions PR summary automation via Ollama Cloud
- Add GitHub Actions changelog validation and release automation
- Expand test coverage: model mapping tests, exception handling tests, logger integration, timeout configuration, billing API tests, webhook verification tests
- Add new endpoints and models: Account (balance, turnover), PublicKey, Statements, Client CRUD, Webhook list/update, Purchase resend invoice
- Add `ClientRecurringToken`, `ClientRecurringTokenList`, `CompanyStatement`, `CompanyStatementList`, `WebhookList` models
- Add `Chip\Http\ClientInterface` internal HTTP abstraction with `GuzzleClient` implementation
- Add `RetryClient` decorator with exponential backoff for 429/5xx responses
- Add resource classes: `PurchasesResource`, `ClientsResource`, `WebhooksResource`, `PaymentMethodsResource`, `AccountResource`, `StatementsResource`, `PublicKeyResource`, `BillingResource`
- Add `fromArray()` static factory methods to all models replacing JsonMapper
- Add pagination iterators (`iterate()`, `iterateTemplates()`, `iterateClients()`) for list endpoints

### Changed

- **Bump PHP requirement from `>=7.2.0` to `^8.1`**
- **Rewrite `ChipApi` from trait-based architecture to resource-based architecture** (`$chip->purchases->create()` instead of `$chip->createPurchase()`)
- **Replace JsonMapper with typed `fromArray()` static factory methods on all models**
- **Add automatic retry with exponential backoff for 429 and 5xx responses**
- **Rewrite `ChipApi::request()` to catch Guzzle HTTP exceptions and throw domain-specific exceptions**
- Upgrade PHPUnit to ^10.5, PHPStan to ^2.1, PHP-CS-Fixer to ^3.95
- Rewrite README with badges, quick-start, API reference, error handling docs
- Rewrite MIGRATION.md with resource API migration guide and pagination docs
- Add CONTRIBUTING.md with development workflow guidelines
- Update CLAUDE.md with new commands and architecture details

### Removed

- Remove `netresearch/jsonmapper` dependency
- Remove `Chip\Traits\Api\*` traits (`Purchase`, `PaymentMethod`, `Client`, `Webhook`, `Billing`, `PublicKey`, `Account`, `Statements`)

### Fixed

- Fix implicitly nullable parameter warnings in `Purchase` trait by using explicit nullable types (`?int`)
- Fix existing tests to pass correct types (string IDs, `Purchase` objects)
- Add property and return types to billing models and traits for PHPStan level 8 compliance
- Fix composer.json missing required `description` field for strict validation
- Fix model properties to match OpenAPI spec: `Product::quantity`, `Product::tax_percent` are now `string|null`; `Purchase::issued` is now `string|null`; `Purchase::status_history` is now `array`

## [1.1.3] - 2024-03-12

### Fixed

- Fix logo not appearing for get payment method
- Fix indentation in billing template client subscriber

## [1.1.2] - 2024-02-13

### Added

- Add billing traits and billing models
- Add `markAsPaid` method for purchases
- Add `BillingTemplateClientAddSubscriber` model
- Add sample test files and test cases

### Changed

- Update API methods and models
- Refactor billing-related code

## [1.1.1] - 2023-04-06

### Added

- Add webhook delete API

### Changed

- Amend PHP version requirement in README

## [1.1.0] - 2023-04-05

### Added

- Add webhooks API (create and get)
- Add `PaymentMethod` model

### Changed

- Refactor code for PHP 8 compatibility
- Bump PHP version requirement to at least 8.0.0

### Fixed

- Fix `payment_method_whitelist` typo
- Ensure non-null values are included via `array_filter`

## [1.0.1] - 2023-02-13

### Added

- Add `force_recurring` property to `Purchase` model
- Add `createClient` method in `Client` trait

### Changed

- Load VCS instead of package to ensure `composer.json` file is readable
- Update README with installation instructions

### Fixed

- Add missing `require` for `chip-sdk-php` in composer examples

## [1.0.0] - 2023-01-05

### Added

- Initial release
- `ChipApi` client with `Purchase`, `PaymentMethod`, `Client`, and `Webhook` traits
- Models: `Purchase`, `PurchaseDetails`, `Product`, `ClientDetails`, `PaymentMethods`, `Webhook`
- `verify()` static method for webhook signature verification using RSA-SHA256
- Basic test suite with Guzzle `MockHandler`

[Unreleased]: https://github.com/CHIPAsia/chip-php-sdk/compare/v2.0.0...HEAD
[2.0.0]: https://github.com/CHIPAsia/chip-php-sdk/compare/v1.1.3...v2.0.0
[1.1.3]: https://github.com/CHIPAsia/chip-php-sdk/compare/v1.1.2...v1.1.3
[1.1.2]: https://github.com/CHIPAsia/chip-php-sdk/compare/v1.1.1...v1.1.2
[1.1.1]: https://github.com/CHIPAsia/chip-php-sdk/compare/v1.1.0...v1.1.1
[1.1.0]: https://github.com/CHIPAsia/chip-php-sdk/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/CHIPAsia/chip-php-sdk/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/CHIPAsia/chip-php-sdk/releases/tag/v1.0.0
Loading