Skip to content

Upgrade SDK to support Payload API V2#13

Merged
ianhalpern merged 5 commits into
masterfrom
feature/PL-154-api-v2-support
Jan 21, 2026
Merged

Upgrade SDK to support Payload API V2#13
ianhalpern merged 5 commits into
masterfrom
feature/PL-154-api-v2-support

Conversation

@ianhalpern
Copy link
Copy Markdown
Contributor

Description

This PR adds support for API v2 by implementing the X-API-Version header functionality and adding new API v2 object classes to the PHP SDK.

This update allows developers to specify which version of the Payload API they want to use by setting Payload\API::$api_version. When set, all API requests will include an X-API-Version header with the specified value, enabling compatibility with API v2 endpoints and features.

Changes include:

  • Add API::$api_version static property for API version configuration
  • Add X-API-Version header to all API requests when API::$api_version is set
  • Add 12 new API v2 object classes: Profile, BillingItem, Intent, InvoiceItem, PaymentAllocation, Entity, Stakeholder,
    ProcessingAgreement, Transfer, TransactionOperation, CheckFront, and CheckBack
  • Update import.php to include all new object classes
  • Create comprehensive unit tests with mocked curl calls for X-API-Version header functionality

Type of change

  • New feature (non-breaking change which adds functionality)
  • Enhancement (non-breaking change which enhances functionality)

Usage Example

<?php
require_once('import.php');

// Set API credentials
Payload\API::$api_key = 'your_api_key';

// Enable API v2
Payload\API::$api_version = 'v2.0';

// All requests will now include X-API-Version: v2.0 header
$profile = Payload\Profile::create([
    'name' => 'Example Profile'
]);

@ianhalpern ianhalpern force-pushed the feature/PL-154-api-v2-support branch from c3c88d5 to 176b6f9 Compare December 9, 2025 16:05
@ianhalpern ianhalpern force-pushed the feature/PL-154-api-v2-support branch from 176b6f9 to f69d19a Compare December 9, 2025 17:56
@ianhalpern ianhalpern requested a review from a team December 9, 2025 18:58
Comment thread README.md
```php
use Payload\API as pl;
pl::$api_version = 'v2.0';
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to add an example using sessions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP doesn't have session support yet.

@ianhalpern ianhalpern merged commit 327da32 into master Jan 21, 2026
1 check passed
ianhalpern added a commit that referenced this pull request Jan 21, 2026
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