PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Melih Berat SANLI   Laravel Adapty   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Laravel Adapty
Help implement in-app purchases using Adapty
Author: By
Last change:
Date: 1 year ago
Size: 3,146 bytes
 

Contents

Class file image Download

Laravel Adapty

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

A Laravel package for the Adapty SDK. Please feel free to contribute...

Installation

You can install the package via composer:

composer require mberatsanli/laravel-adapty

You can publish the config file with:

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

This is the contents of the published config file:

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
    ],
];

Usage

// 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\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>)

Testing

No tests available for now

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please feel free to contributing...

Credits

License

The MIT License (MIT). Please see License File for more information.