mberatsanli/laravel-adapty

1.0.6 2022-12-12 18:36 UTC

This package is auto-updated.

Last update: 2024-09-12 22:19:54 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

一个用于Adapty SDK的Laravel包。 请随意贡献...

安装

您可以通过composer安装此包

composer require mberatsanli/laravel-adapty

您可以使用以下命令发布配置文件

php artisan vendor:publish --tag="adapty-config"

这是发布配置文件的内容

return [
    'base_url' => env('ADAPTY_BASE_URL', 'https://api.adapty.io/api/v1/sdk'),

    'secret_token' => env('ADAPTY_SECRET_TOKEN'), // Your adapty secret token.

    'webhook' => [
        'path' => env('ADAPTY_WEBHOOK_PATH', '/adapty/webhook'), // webhook endpoint's path
        'middleware' => [] // If you want to use middleware on the webhook endpoint, you can adjust that configuration
    ],
];

使用方法

// Create a user
$createResponse = \MBS\LaravelAdapty\LaravelAdapty::createUser('<USER ID>');

// Get information about the user
$informationResponse = \MBS\LaravelAdapty\LaravelAdapty::userInformation('<USER ID -- OR -- Adapty Profile ID>');

// Set attributes to the user
$setAttributesResponse = \MBS\LaravelAdapty\LaravelAdapty::setUserAttributes('<USER ID -- OR -- Adapty Profile ID>', [
    // see https://docs.adapty.io/docs/server-side-api-specs#set-the-users-attribute
]);

// see https://docs.adapty.io/docs/getting-started-with-server-side-api#case-2-grant-a-subscription
$grantRequest = \MBS\LaravelAdapty\Http\Requests\GrantSubscriptionRequest::make(7, ....);
$grantResponse = \MBS\LaravelAdapty\LaravelAdapty::grantSubscription('<USER ID -- OR -- Adapty Profile ID>', $grantRequest);

// See https://docs.adapty.io/docs/server-side-api-specs#revoke-subscription-from-a-user
$revokeSubscriptionResponse = \MBS\LaravelAdapty\LaravelAdapty::revokeSubscription(profileId: '<USER ID -- OR -- Adapty Profile ID>', accessLevel: 'premium', isRefund: <bool>)

测试

目前没有可用的测试

composer test

变更日志

请参阅 CHANGELOG 了解最近的变化信息。

贡献

请随意贡献...

鸣谢

许可协议

MIT许可协议(MIT)。请参阅 许可文件 了解更多信息。