twovmodules/revenuecat-sdk
最新稳定版本:1.0.0
Composer 安装命令:
composer require twovmodules/revenuecat-sdk
包简介
PHP SDK for RevenueCat payment service
README 文档
README
📌 Description
This SDK provides a convenient interface for working with the RevenueCat API, following PSR standards. It supports managing projects, customers, subscriptions, entitlements, and other RevenueCat entities.
🚀 Installation
composer require twovmodules/revenuecat-sdk
🛠 Minimum Requirements
- PHP 8.2+
- PSR-7, PSR-17, PSR-18 compatible HTTP client (e.g., Guzzle)
📖 Quick Start
1. Initialize the Minimal Client
use Twovmodules\RevenueCat\RevenueCatClient; use Twovmodules\RevenueCat\Configuration; use GuzzleHttp\Psr7\HttpFactory; use GuzzleHttp\Client; $configuration = new Configuration('_your_api_key_here_'); $guzzleClient = new Client; $requestFactory = new HttpFactory(); $streamFactory = new HttpFactory(); $revenueCat = new RevenueCatClient( psrHttpClient: $guzzleClient, configuration: $configuration, requestFactory: $requestFactory, streamFactory: $streamFactory );
2. Retrieve a List of Customers
$customers = $revenueCat->customers()->list('project_id'); foreach ($customers as $customer) { echo $customer->id . "\n"; }
3. Create a New Customer
use Twovmodules\RevenueCat\Dto\Request\CreateCustomerDto; $request = new CreateCustomerDto(id: 'customer_123'); $customer = $revenueCat->customers()->create($request, 'project_id'); echo "Customer created: " . $customer->id;
📚 Available Services
apps()— Operations about apps.projects()— Operations about projects.customers()— Operations about customers.offerings()— Operations about offerings.subscriptions()— Operations about subscriptions.entitlements()— Operations about entitlements.products()— Operations about products.invoices()— Operations about invoices.overviewMetrics()— Operations about chart metrics.packages()— Operations about packages.purchases()— Operations about purchases.
⚠️ Error Handling
try { $apps = $revenueCat->apps()->list('project_id'); } catch (RevenueCatException $e) { // Handle specific RevenueCat errors echo "Error: " . $e->getMessage(); } catch (\Exception $e) { // Handle other exceptions echo "Unexpected error: " . $e->getMessage(); }
📖 More Information
📄 License
This SDK is open-sourced under MIT License.
统计信息
- 总下载量: 1.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-10