Skip to content

Commit

Permalink
Merge branch 'ADP-1386-Custom-stores-server-side-api' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Lutik-sun committed Oct 24, 2024
2 parents a95e757 + ad09fc6 commit 6017d9a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 39 deletions.
79 changes: 40 additions & 39 deletions versioned_docs/version-3.0/getting-started-with-server-side-api.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
title: "Getting started with server-side API"
description: ""
metadataTitle: ""
title: "Server-side API"
description: "Explore Adapty's server-side API for managing user subscriptions, syncing subscribers across platforms, updating user attributes, and granting access levels. Learn how to integrate payments from web stores and customize user attributes for better segmentation and A/B testing."
metadataTitle: "Unlock Subscription and User Management with Adapty's Server-Side API"
---

import Zoom from 'react-medium-image-zoom';
import 'react-medium-image-zoom/dist/styles.css';

With the API, you can:
1. Get user's subscription status.
2. Activate a subscription for a user with an [access level](access-level).
3. Get user's attributes.
4. Set user's attributes.

1. Check a user's subscription status.
2. Activate a user's subscription with an [access level](access-level).
3. Retrieve user attributes.
4. Set user attributes.

<Zoom>
<img src={require('./img/Adapty-Communication-Scheme.webp').default}
<img src={require('./img/server.webp').default}
style={{
border: '1px solid #727272', /* border width and color */
width: '700px', /* image width */
Expand All @@ -24,53 +25,53 @@ With the API, you can:
/>
</Zoom>

<p> </p>

:::note
You can't get subscription events via API, but you can use [Webhook](webhook) or direct integration with a service that you're using.
:::

<Zoom>
<img src={require('./img/Adapty_Communication_Scheme.png').default}
style={{
border: '1px solid #727272', /* border width and color */
width: '700px', /* image width */
display: 'block', /* for alignment */
margin: '0 auto' /* center alignment */
}}
/>
</Zoom>
To track subscription events, use [Webhook](webhook) integration in Adapty or integrate directly with your existing service.

To correctly work with API you need to use a unique ID for your users. This may be an email, a phone number, your internal ID. Without such an ID it's impossible to identify the same user on multiple platforms.
:::

## Case 1: Syncing subscribers between web and mobile
To use the API effectively, you need a unique ID for your users. This could be an email, phone number, or your internal ID. Without it, you won’t be able to identify the same user across multiple platforms.

Whenever Web payment providers you use such as Stripe, ChargeBee, or any other, you can sync subscribers. For that:
## Case 1: Syncing subscribers between web and mobile

1. _Use a unique ID for your users_. For example, email or phone number.
2. Check subscription status via API.
3. If a user is freemium, show him a paywall on the Web.
4. After successful payment, update subscription status in Adapty via API.
5. Your subscribers will be automatically in sync with mobile.
1. If you use web payment providers like Stripe, ChargeBee, or others, you can sync your subscribers easily. Here’s how:
1. [Assign a unique ID to each user](identifying-users).
2. [Check their subscription status](server-side-api-specs#retrieve-profile) using the API.
3. If a user is on a freemium plan, display a paywall on your website.
4. After a successful payment, [update the subscription status](server-side-api-specs#set-transaction) in Adapty via API.
5. Your subscribers will automatically stay in sync with your mobile app.

## Case 2: Grant a subscription

:::note
Due to security reasons, you can't grant a subscription via mobile SDK.
:::
:::

If you're selling through your own online store, Amazon Appstore, Microsoft Store, or any other platform besides Google Play and App Store, you’ll need to sync those transactions with Adapty to provide access and track the transaction in analytics.

1. [Assign a unique ID to each user](identifying-users).
2. [Set up a custom store for your products in the Adapty Dashboard](initial-custom).
3. Sync the transaction to Adapty using the [Set transaction](server-side-api-specs#set-transaction) API request.

## Case 3: Grant an access level

Imagine a case, when you run a promotional campaign with offers 7 days of a trial and you want to sync in with mobile experience. To do that:
Let’s say you're running a promotion offering a 7-day free trial and you want the experience to be consistent across platforms. To sync this with the mobile app:

1. Get a unique ID for a user.
2. Set premium access via paid access level with API with a duration of 7 days.
1. [Assign a unique ID to each user](identifying-users).
2. Use the API to [grant premium access](server-side-api-specs#grant-access-level) for 7 days.

After 7 days users who won't subscribe will be downgraded to the free tier.
After the 7 days, users who don’t subscribe will be downgraded to the free tier.

## Case 3: Syncing users' attributes and custom properties
## Case 4: Syncing users' attributes and custom properties

You may have custom attributes for your users, other than defaults such as IDFA, device model, etc. For example, in a language learning service, you may want to save the number of words a student has learned. To do that:
If you have custom attributes for your userssuch as the number of words learned in a language learning app—you can sync them as well.

1. Get a unique ID for a user.
2. Update attribute with API or SDK.
1. [Assign a unique ID to each user](identifying-users).
2. [Update the attribute](server-side-api-specs#update-profile) via API or SDK.

With such attributes you can, for example, create a segment and run an A/B test.
These custom attributes can be used to create segments and run A/B tests.

To learn more about S2S API go to [API Specs](server-side-api-specs).
For more details, visit the [API Specs](server-side-api-specs).
Binary file modified versioned_docs/version-3.0/img/Adapty-Communication-Scheme.webp
Binary file not shown.
Binary file added versioned_docs/version-3.0/img/server.webp
Binary file not shown.
2 changes: 2 additions & 0 deletions versioned_docs/version-3.0/initial-custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Adapty doesn’t validate data with other app stores and does not process purcha
/>
</Zoom>

<p> </p>

:::important

Make sure your backend processes the purchase and sends the transaction to Adapty using the [Adapty server-side API](getting-started-with-server-side-api). Adapty will only provide access, trigger a transaction event, send it to integrations, and reflect it in analytics after the transaction is received.
Expand Down

0 comments on commit 6017d9a

Please sign in to comment.