--- title: "Associating a Purchase with a Customer" slug: "associating-a-purchase-with-a-customer" updated: 2026-07-09T05:16:31Z published: 2026-07-09T05:16:31Z canonical: "help.frisbii.com/associating-a-purchase-with-a-customer" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.frisbii.com/llms.txt > Use this file to discover all available pages before exploring further. # Associating a Purchase with a Customer After the platform store purchase has been validated and an `inAppToken` returned, the purchase exists in Frisbii Media as an anonymous record. It must be linked to a customer account before it appears in the customer's subscription history and becomes valid on other platforms. --- ## When to associate Associate as soon as the user is identified — either immediately after purchase (if already logged in) or after the user completes login or registration. If the user is not yet logged in at the time of purchase: 1. Store the `inAppToken` on the device (or in your session) 2. Start a Frisbii Media login or registration flow (see [SSO: Login & Registration](/frisbii-media/docs/sso-login-registration)) 3. Once the `LoginSuccess` event fires and you have a `customerSession`, call associate --- ## The associate endpoint ```php /** * @Route("/inapp/associate", name="InAppAssociate", methods={"POST"}) */ public function associateInAppPurchase(Request $request): Response {    $content = json_decode($request->getContent(), true);    // customerSession comes from the plenigo.LoginSuccess event on the frontend    // inAppToken was returned when the purchase was added (steps 3–5 in the process flow)    // @see https://api.frisbii-media.com/#tag/App-Stores/operation/associateAppStorePurchase    $response = json_decode($client->request('POST', '/appstores/purchases/associate', [        'headers' => ['X-plenigo-token' => eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9],        'json'    => [            'customerSession' => $content['customerSession'],            'inAppToken'      => $content['inAppToken'],        ],    ])->getBody()->getContents(), true);    return new JsonResponse($response); } ``` After a successful associate call: - The purchase is linked to the customer's Frisbii Media account - The subscription and access rights are visible in the customer's self-service portal - The customer can use their subscription on all platforms (web, other apps) using their Frisbii Media login --- ## Full login + associate flow (example) This example shows how to tie the login and associate steps together in a single page: ```xml
``` --- ## What if the user already has an account? If the user is already logged in when they make the in-app purchase, skip the login step entirely and call associate directly with the existing `customerSession`: ```php $response = json_decode($client->request('POST', '/appstores/purchases/associate', [    'headers' => ['X-plenigo-token' => eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9],    'json'    => [        'customerSession' => $existingSession,        'inAppToken'      => $inAppToken,    ], ])->getBody()->getContents(), true); ``` --- ## What if the user never logs in? If the user never logs in, the purchase remains anonymous in Frisbii Media. The `inAppToken` can still be used to check access on that specific device via the Frisbii Media API. However, the purchase will not appear in any customer account, and the user will lose access if they reinstall the app or switch devices. Encourage users to create an account to protect their purchase. --- ## API reference - [associateAppStorePurchase](https://api.plenigo.com/#tag/App-Stores/operation/associateAppStorePurchase) ---