# Creating a new application

## Login to the console

Go to [Purchasely console](https://purchasely.io) with your credentials.

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-Mb6UKXbLTQ5oQVw7A0o%2F-Mb6YBUi7NjaJXHHj2Uc%2Fimage.png?alt=media\&token=3357839c-9d40-4ccc-ab9c-a47df39389e9)

These credentials are provided to you by the Purchasely Team. If you want to have your credentials created, just contact us at <hello@purchasely.com>

## Creating a new App

To create a new app, click on the  **`Add new application`** in the drop down menu of the top-left corner

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-Mb6UKXbLTQ5oQVw7A0o%2F-Mb6YQWiIna2-rUQK-DU%2Fimage.png?alt=media\&token=732513fa-8bae-4463-aff9-010f8b48f8a0)

{% hint style="warning" %}
If you have 2 different environments (e.g. : staging & production), you should create 2 different **Applications** in the Purchasely Console and use 2 different **API keys**
{% endhint %}

{% hint style="info" %}
&#x20;We advise you to start creating a staging application first (i.e. a mobile application plugged to a staging environment) to perform your first tests.
{% endhint %}

This new application must be configured with a set of parameters among 3 different stages. All these parameters can be modified after the application has been created.

#### 1. Create a new application

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-Mb6UKXbLTQ5oQVw7A0o%2F-Mb6ZZi1Cz_7PlnVZA--%2Fimage.png?alt=media\&token=b6a40c8c-0222-4585-8b48-3879295007bd)

The mandatory parameters are :

* **Name** \* : the name of the application as it will be display in the Purchasely Console
* **The default langage** **\*** :  this will define which language shall be used when the language on a user device is not supported by the application

#### 2. Plug it with .the stores

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-Mb6UKXbLTQ5oQVw7A0o%2F-Mb6a5uYDLSSfS211Nt8%2Fimage.png?alt=media\&token=7d28ef46-4e29-40bd-9c29-a40ed598e7b3)

You can add up to 4 different stores. Each store step by step configuration is explained below, in dedicated sections.

* [**Apple App Store**](#configuring-the-app-store-parameters)
* [**Google Play Store**](#configuring-the-google-play-store-parameters)
* [**Huawei AppGallery**](#configuring-huawei-appgallery-parameters)
* [**Amazon App Store**](#configuring-amazon-app-store-parameters)

#### 3. Plug it with your backend

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-Mb6UKXbLTQ5oQVw7A0o%2F-Mb6bd6iLPdY4ZIs-BEa%2Fimage.png?alt=media\&token=1c07d582-9e17-4c1e-886b-cc0ef6178c9f)

In this section, you can plug the Purchasely Cloud Platform with your own backend through a server-to-server integration. This will allow to have your backend notified through a *webhook*, when a subscription event is received from the stores.

This allows your app to open accesses to the relevant features & contents when a user purchases a specific product or subscription... ... and to close the accesses when the user subscription is expired or the when the user gets refund. Opening / closing accesses and managing entitlements is the responsibility of your own backend.

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-MHMVKc-kdaK70UC7ThV%2F-MHMjSGSy8P1VIHyxA4J%2Fimage.png?alt=media\&token=3cc04b00-6dc8-4dc1-976b-6c51c10d7b25)

Fill in the `Client webhook URL` with the endpoint URL on your own backend where you want to receive the subscription events.

{% hint style="info" %}
If your `Client Webhook` is not ready when you make your configuration, we advise you to use the following value: <https://httpstat.us/200>

This value will simulate a HTTP 200 response code allowing the Purchasely Cloud Platform to consider that the new subscription has been duly acknowledged by the Client Backend.
{% endhint %}

Every message send by Purchasely in the webhook is signed using a Client shared secret.&#x20;

Refer to [Webhook documentation](https://purchasely.gitbook.io/purchasely/2.8/webhook-1/detailed-specification#authenticating-request-and-verifying-signature-recommended) to know more.

## Configuring the Apple App Store parameters

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-Mb6UKXbLTQ5oQVw7A0o%2F-Mb6fNCVr-pscObjTWGg%2Fimage.png?alt=media\&token=bcf4ecbf-73c4-4fc8-beae-a6378117aa78)

### App bundle id

{% hint style="info" %}
The Bundle ID is used by Purchasely Cloud Platform to validate that receipts are indeed coming from your app
{% endhint %}

Get the value of the `Bundle ID` field in App Store Connect \
\&#xNAN;*App Store Connect > My Apps > \[YOUR APP] > General > App Information*

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-MHMVKc-kdaK70UC7ThV%2F-MHMqDY7YKTCiQVZx3bE%2Fimage.png?alt=media\&token=32ac9bdf-cb50-462d-b79b-f6bfda0f2b65)

The value of the `Bundle ID` should be reported in the field App Package in the Purchasely Console\
\&#xNAN;*Purchasely > Mobile Applications > \[YOUR APPLICATION] > Edit Mobile Application >  iOS configuration*

### Shared App Secret

{% hint style="info" %}
The Shared App Secret is used by Purchasely Cloud Platform and required to validate receipts for this specific app
{% endhint %}

Get the value of the `App-Specific Shared Secret` field in App Store Connect \
\&#xNAN;*App Store Connect > My Apps > \[YOUR APP] > In-App Purchases > Manage > App-Specific Shared Secret*

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-MHMVKc-kdaK70UC7ThV%2F-MHMsblxkwvqs3sisNf8%2Fimage.png?alt=media\&token=c6f74ee3-4b27-4d76-a3cc-7f76aead33ae)

The value of the `App-Specific Shared Secret` should be reported in the field `Shared App Secret` in your Purchasely console <br>

The last field Server-to-server endpoint is not mandatory. It is used to activate the real-time server-to-server notifications coming from the App Store.&#x20;

Refer to [Server-to-server notifications documentation](https://purchasely.gitbook.io/purchasely/2.8/stores-configuration/app-store) for more information.

## Configuring the Google Play Store parameters

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-Mb6gtFNwQ8DdsvaguQS%2F-Mb6hJYIUVGq66CFZYsX%2Fimage.png?alt=media\&token=0fa164db-9efd-4596-99a8-c61abf605c19)

### Android App Bundle ID

{% hint style="info" %}
The Bundle ID is used by Purchasely Backend to validate that receipts are indeed coming from your app
{% endhint %}

Get the value of the Package ID of your App in Googe Play \
\&#xNAN;*Google Play Console > \[YOUR APP] > (i)*

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-MHNQMX97_N-NJcdgaHc%2F-MHNTSEkjozYJk41s9Z2%2Fimage.png?alt=media\&token=86814579-323c-4b3d-a4af-ba5938445770)

The value of the Package ID should be reported in the field `App bundle id` in your Purchasely console&#x20;

### Acces Key (JSON)

{% hint style="info" %}
This access key is mandatory to allow Purchasely Cloud Platform to decode Play Store receipts / token
{% endhint %}

#### Create a new Service Account

Create a dedicated Service Account under [Google Cloud Platform Console](https://console.cloud.google.com/) [https://console.cloud.google.com](https://console.cloud.google.com/) \
*Google Cloud Platform > IAM & admin > Service Account > Create a new Service Account*

{% hint style="danger" %}
Before creating the service account, make sure that the relevant Organisation is selected. The drop down menu in the upper left corner of the screen shall match the Organisation in your Google Play Console
{% endhint %}

* Name your account `Purchasely` to be able to easily identify it later
* Give it the ID `purchasely`
* On the following screen, set the role to "Owner"
* On the following screen, create a key by clicking on the `+ Create a key` button
* Choose JSON format
* Save the file on your computer, you will need to upload it later in your Purchasely Console

#### Grant API Access to the new Service Account

Grant the access to the Service Account under the Google Play Console\
\&#xNAN;*Google Play Console > Developer Account > API Access > \[PURCHASELY SERVICE ACCOUNT] > Grant authorisation*

{% hint style="danger" %}
The Organisation should match the one you chose under the Google Cloud Platform console
{% endhint %}

* Set "no expiration date"
* **App permissions -** Select the application corresponding to the app bundle id
* **Account permissions -** Ensure the following permissions are selected :
  * [x] Display applications information
  * [x] Display financial data
  * [x] Handle orders
  * [x] Modify sheets, fares and distribution parameters

#### Upload the JSON content

Upload the JSON key under your Purchasely console in the field `Access key (JSON)`

## Configuring Huawei AppGallery parameters

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-Mb6gtFNwQ8DdsvaguQS%2F-Mb6ia0ivDo7ukALSQYO%2Fimage.png?alt=media\&token=dfec8efc-daed-4fdd-9021-8f75141c4bf3)

### Huawei App Package ID

{% hint style="info" %}
The Package name is used by Purchasely Cloud Platform to validate the authenticity of the receipts.&#x20;
{% endhint %}

1. Open your [AppGallery Console](https://developer.huawei.com/consumer/en/console#/serviceCards/)
2. Go to: [*AppGallery Connect*](https://developer.huawei.com/consumer/en/service/josp/agc/index.html) *>* [*My Apps*](https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myApp) *> \[YOUR APPLICATION]*
3. Get the value of the `Package name`

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-MQH3u0Fop3zqK9yJ66P%2F-MQH8oIM5MXsWSUsRAp3%2FScreenshot%202021-01-05%20at%2011.40.26%20copy.png?alt=media\&token=d3e4696f-2dc3-42b3-a814-2f3f025c6889)

The value of the Package name should be reported in the field Huawei `App package id` in your Purchasely console&#x20;

### App ID

{% hint style="info" %}
The App ID is used by Purchasely Cloud Platform to validate the authenticity of the receipts.&#x20;
{% endhint %}

Same procedure as "App Package Id", with the `App ID` property which must be put under `App id` in the Purchasely Console (*Purchasely > Mobile Applications > \[YOUR APPLICATION] > Huawei configuration*)

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-MQH3u0Fop3zqK9yJ66P%2F-MQH9eY3AmaQtQBojpEB%2FScreenshot%202021-01-05%20at%2011.40.26%20copy.png?alt=media\&token=01ca243a-8d75-4338-adde-927ca648d9a9)

### App secret

{% hint style="info" %}
The App secret is used by Purchasely Cloud Platform to validate the authenticity of the receipts.
{% endhint %}

Same procedure as "App Package Id", with the `App secret` property which must be put under `App secret` in the Purchasely Console (*Purchasely > Mobile Applications > \[YOUR APPLICATION] > Huawei configuration*)

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-MQH3u0Fop3zqK9yJ66P%2F-MQHApK-VcP3E4jOG0PF%2FScreenshot%202021-01-05%20at%2011.40.26%20copy.png?alt=media\&token=4f31ac47-8ee5-4aa8-9dec-712432816b0f)

### Public key

{% hint style="info" %}
The public key is used by Purchasely Cloud Platform to validate the authenticity of the receipts.
{% endhint %}

1. Open your [AppGallery Console](https://developer.huawei.com/consumer/en/console#/serviceCards/)
2. Go to: [*AppGallery Connect*](https://developer.huawei.com/consumer/en/service/josp/agc/index.html) *>* [*My Apps*](https://developer.huawei.com/consumer/en/service/josp/agc/index.html#/myApp) *> \[YOUR APPLICATION]*
3. In the "All services" menu on top, search for "In-App Purchases" and click on it
4. Get the `Public key` property

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-MQH3u0Fop3zqK9yJ66P%2F-MQHCzmUjZXr46XekYLD%2FScreenshot%202021-01-05%20at%2011.56.26%20copy.png?alt=media\&token=db25b3f8-49fc-4a02-aaea-0ef4d683d80b)

1. Fill in this value under `"In-App Purchases" public key` in the Purchasely Console (*Purchasely > Mobile Applications > \[YOUR APPLICATION] > Huawei configuration*)

## Configuring Amazon App Store parameters

### App SKU&#x20;

{% hint style="info" %}
The Package name is used by Purchasely Cloud Platform to validate the authenticity of the receipts.&#x20;
{% endhint %}

1. Open the [Amazon App Store dashboard](https://developer.amazon.com/dashboard)
2. Select App List
3. Select your app
4. Get the value of the `App SKU`

![](https://3348776246-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHAzdlUVqKyZvwTnNIE%2F-MZxLmHh5hKsuOqYY1_B%2F-MZxLwdUCqnrA5IQ2uOk%2FCapture%20d%E2%80%99e%CC%81cran%202021-05-05%20a%CC%80%2018.24.14.png?alt=media\&token=8ddd7d51-0dec-445b-ace6-47565ecc5e26)

The value of the `App SKU` should be reported in the field `Amazon App SKU` in your Purchasely console.

### Shared Key

You need to give us your Amazon App Store shared Key. You can find it [here](https://developer.amazon.com/settings/console/sdk/shared-key).
