# Record a purchase

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

Records an in-app purchase from Apple App Store or Google Play Store in Chargebee. The API starts an asynchronous verification job and returns a `recorded_purchase` resource. Track progress with `status`: `in_process`, `completed`, `failed`, or `ignored`.

Handle the **synchronous** API response first. The request can fail immediately (for example, an incorrect `app_id`, a malformed URL or request body, or a customer conflict on an already-recorded purchase) before any job is created—treat these as standard API errors (`4xx`). Only after the call is accepted and returns a `recorded_purchase` should you track the **asynchronous** job via `status` (`in_process` → `completed`, `failed`, or `ignored`). Omnichannel subscription or one-time order creation still happens asynchronously after a successful sync acceptance.

### Prerequisites[](#prerequisites)

-   Configure the omnichannel app (`app_id`) for Apple or Google in Chargebee.
-   Provide exactly one store payload: `apple_app_store[...]` **or** `google_play_store[...]`.
-   Associate the purchase with a Chargebee `customer[id]` (created automatically if missing when customer details are supplied).

### Synchronous customer conflicts (existing purchase)[](#synchronous-customer-conflicts-existing-purchase)

If the store purchase is already recorded in Chargebee under a **different** customer, Record a Purchase returns a synchronous `4xx` (`customer_id_conflict_use_move_api` / `customer_id_mismatch`) and does **not** create a `recorded_purchase` job. To reassign ownership, use [Move an omnichannel subscription](/docs/api/omnichannel_subscriptions/move-an-omnichannel-subscription). Re-recording the same purchase for the **same** customer typically completes asynchronously with `status` `ignored` when the subscription or one-time order already exists.

### Apple App Store input (mutually exclusive paths)[](#apple-app-store-input-mutually-exclusive-paths)

-   Prefer `apple_app_store[transaction_id]` for subscriptions and one-time products when you have the StoreKit transaction ID.
-   Or pass `apple_app_store[receipt]` **and** `apple_app_store[product_id]`.

### Google Play Store input (mutually exclusive paths)[](#google-play-store-input-mutually-exclusive-paths)

-   Prefer `google_play_store[order_id]` for subscriptions and one-time orders.
-   Or pass `google_play_store[purchase_token]` for subscriptions; for one-time orders also pass `google_play_store[product_id]`.

### Impacts (when `status` becomes `completed`)[](#impacts-when-status-becomes-completed)

-   **Subscription purchase**: Creates/links `linked_omnichannel_subscriptions`, sets `omnichannel_transaction_id`, and emits [`omnichannel_subscription_created`](/docs/api/events/webhook/omnichannel_subscription_created) (or [`omnichannel_subscription_imported`](/docs/api/events/webhook/omnichannel_subscription_imported) when historical transactions are present). Chargebee may also emit [`omnichannel_transaction_created`](/docs/api/events/webhook/omnichannel_transaction_created).
-   **One-time order purchase**: Creates/links `linked_omnichannel_one_time_orders`, sets `omnichannel_transaction_id`, and emits [`omnichannel_one_time_order_created`](/docs/api/events/webhook/omnichannel_one_time_order_created).

### Impacts (when `status` is `failed`)[](#impacts-when-status-is-failed)

-   Review [`error_detail`](/docs/api/recorded_purchases/recorded_purchase-object#error_detail) and correct the payload. Chargebee emits [`record_purchase_failed`](/docs/api/events/webhook/record_purchase_failed).

### Impacts (when `status` is `ignored`)[](#impacts-when-status-is-ignored)

-   The purchase already has an omnichannel subscription or one-time order in Chargebee. No new linked resource is created for this job—use the existing resource. Linked IDs and `omnichannel_transaction_id` appear when `status` is `completed`, not for `ignored`.

See [omnichannel events](/docs/api/omnichannel_events) for the full recording and notification mapping tables.

## Sample Request

### Default

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/recorded_purchases \
     -u {site_api_key}:\
     -d app_id="__test__aas_sdfwerzx5134" \
     -d "customer[id]"="__test__XpbTXGTSRp3gEsD8" \
     -d "apple_app_store[transaction_id]"="20000006743"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = RecordedPurchase.Create()
		.AppId("__test__aas_sdfwerzx5134")
		.CustomerId("__test__XpbTXGTSRp3gEsD8")
		.AppleAppStoreTransactionId("20000006743")
		.Request();

RecordedPurchase recordedPurchase = result.RecordedPurchase;
Customer customer = result.Customer;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    recordedpurchaseAction "github.com/chargebee/chargebee-go/v3/actions/recordedpurchase"
    "github.com/chargebee/chargebee-go/v3/models/recordedpurchase"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := recordedpurchaseAction.Create(&recordedpurchase.CreateRequestParams{
        AppId : "__test__aas_sdfwerzx5134",
        Customer : &recordedpurchase.CreateCustomerParams{
            Id : "__test__XpbTXGTSRp3gEsD8",
        },
        AppleAppStore : &recordedpurchase.CreateAppleAppStoreParams{
            TransactionId : "20000006743",
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        RecordedPurchase := res.RecordedPurchase
        Customer := res.Customer
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.RecordedPurchaseCreateRequest{
    AppId : "__test__aas_sdfwerzx5134",
    Customer : &chargebee.RecordedPurchaseCreateCustomer{
        Id : "__test__XpbTXGTSRp3gEsD8",
    },
    AppleAppStore : &chargebee.RecordedPurchaseCreateAppleAppStore{
        TransactionId : "20000006743",
    },
}
  res, err := client.RecordedPurchase.Create(req)
      if err != nil {
        fmt.Println(err)
    } else {
        RecordedPurchase := res.RecordedPurchase
        Customer := res.Customer
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = RecordedPurchase.create()
            .appId("__test__aas_sdfwerzx5134")
            .customerId("__test__XpbTXGTSRp3gEsD8")
            .appleAppStoreTransactionId("20000006743")
            .request();

        RecordedPurchase recordedPurchase = result.recordedPurchase();
        Customer customer = result.customer();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.recordedPurchase.RecordedPurchase;
import com.chargebee.v4.models.recordedPurchase.params.RecordedPurchaseCreateParams;
import com.chargebee.v4.models.recordedPurchase.responses.RecordedPurchaseCreateResponse;

public class RecordedPurchaseCreate {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        RecordedPurchaseCreateParams.CustomerParams customerParams =
            RecordedPurchaseCreateParams.CustomerParams.builder()
                .id("__test__XpbTXGTSRp3gEsD8")
                .build();

        RecordedPurchaseCreateParams.AppleAppStoreParams appleAppStoreParams =
            RecordedPurchaseCreateParams.AppleAppStoreParams.builder()
                .transactionId("20000006743")
                .build();

        RecordedPurchaseCreateParams params = RecordedPurchaseCreateParams.builder()
            .appId("__test__aas_sdfwerzx5134")
            .customer(customerParams)
            .appleAppStore(appleAppStoreParams)
            .build();

        RecordedPurchaseCreateResponse response = client.recordedPurchases().create(params);

        RecordedPurchase recordedPurchase = response.getRecordedPurchase();
        Customer customer = response.getCustomer();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.recordedPurchase.create({
        app_id: "__test__aas_sdfwerzx5134",
        customer: {
            id: "__test__XpbTXGTSRp3gEsD8"
        },
        apple_app_store: {
            transaction_id: 20000006743
        }
    });

    console.log(result);
    const recordedPurchase = result.recorded_purchase;
    const customer = result.customer;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->recordedPurchase()->create([
    "app_id" => "__test__aas_sdfwerzx5134",
    "customer" => [
        "id" => "__test__XpbTXGTSRp3gEsD8"
    ],
    "apple_app_store" => [
        "transaction_id" => "20000006743"
    ]
]);
$recordedPurchase = $result->recorded_purchase;
$customer = $result->customer;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.RecordedPurchase.create(
    cb_client.RecordedPurchase.CreateParams(
        app_id="__test__aas_sdfwerzx5134",
        customer=cb_client.RecordedPurchase.CreateCustomerParams(
            id="__test__XpbTXGTSRp3gEsD8"
        ),
        apple_app_store=cb_client.RecordedPurchase.CreateAppleAppStoreParams(
            transaction_id="20000006743"
        )
    )
)
recorded_purchase = response.recorded_purchase
customer = response.customer
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::RecordedPurchase.create({
  :app_id => "__test__aas_sdfwerzx5134",
  :customer => {
    :id => "__test__XpbTXGTSRp3gEsD8"
  },
  :apple_app_store => {
    :transaction_id => "20000006743"
  }
})

recorded_purchase = result.recorded_purchase
customer = result.customer
```

### Record a purchase for Apple app store using the apple_app_store[receipt]

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/recorded_purchases \
     -u {site_api_key}:\
     -d app_id="__test__aas_sdfwerzx5134" \
     -d "customer[id]"="__test__XpbTXGTSRp3gEsD8" \
     -d "apple_app_store[receipt]"="Apple Based64 Encoded Receipt" \
     -d "apple_app_store[product_id]"="gold"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = RecordedPurchase.Create()
		.AppId("__test__aas_sdfwerzx5134")
		.CustomerId("__test__XpbTXGTSRp3gEsD8")
		.AppleAppStoreReceipt("Apple Based64 Encoded Receipt")
		.AppleAppStoreProductId("gold")
		.Request();

RecordedPurchase recordedPurchase = result.RecordedPurchase;
Customer customer = result.Customer;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    recordedpurchaseAction "github.com/chargebee/chargebee-go/v3/actions/recordedpurchase"
    "github.com/chargebee/chargebee-go/v3/models/recordedpurchase"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := recordedpurchaseAction.Create(&recordedpurchase.CreateRequestParams{
        AppId : "__test__aas_sdfwerzx5134",
        Customer : &recordedpurchase.CreateCustomerParams{
            Id : "__test__XpbTXGTSRp3gEsD8",
        },
        AppleAppStore : &recordedpurchase.CreateAppleAppStoreParams{
            Receipt : "Apple Based64 Encoded Receipt",
            ProductId : "gold",
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        RecordedPurchase := res.RecordedPurchase
        Customer := res.Customer
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.RecordedPurchaseCreateRequest{
    AppId : "__test__aas_sdfwerzx5134",
    Customer : &chargebee.RecordedPurchaseCreateCustomer{
        Id : "__test__XpbTXGTSRp3gEsD8",
    },
    AppleAppStore : &chargebee.RecordedPurchaseCreateAppleAppStore{
        Receipt : "Apple Based64 Encoded Receipt",
        ProductId : "gold",
    },
}
  res, err := client.RecordedPurchase.Create(req)
      if err != nil {
        fmt.Println(err)
    } else {
        RecordedPurchase := res.RecordedPurchase
        Customer := res.Customer
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = RecordedPurchase.create()
            .appId("__test__aas_sdfwerzx5134")
            .customerId("__test__XpbTXGTSRp3gEsD8")
            .appleAppStoreReceipt("Apple Based64 Encoded Receipt")
            .appleAppStoreProductId("gold")
            .request();

        RecordedPurchase recordedPurchase = result.recordedPurchase();
        Customer customer = result.customer();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.recordedPurchase.RecordedPurchase;
import com.chargebee.v4.models.recordedPurchase.params.RecordedPurchaseCreateParams;
import com.chargebee.v4.models.recordedPurchase.responses.RecordedPurchaseCreateResponse;

public class RecordedPurchaseCreate {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        RecordedPurchaseCreateParams.CustomerParams customerParams =
            RecordedPurchaseCreateParams.CustomerParams.builder()
                .id("__test__XpbTXGTSRp3gEsD8")
                .build();

        RecordedPurchaseCreateParams.AppleAppStoreParams appleAppStoreParams =
            RecordedPurchaseCreateParams.AppleAppStoreParams.builder()
                .receipt("Apple Based64 Encoded Receipt")
                .productId("gold")
                .build();

        RecordedPurchaseCreateParams params = RecordedPurchaseCreateParams.builder()
            .appId("__test__aas_sdfwerzx5134")
            .customer(customerParams)
            .appleAppStore(appleAppStoreParams)
            .build();

        RecordedPurchaseCreateResponse response = client.recordedPurchases().create(params);

        RecordedPurchase recordedPurchase = response.getRecordedPurchase();
        Customer customer = response.getCustomer();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.recordedPurchase.create({
        app_id: "__test__aas_sdfwerzx5134",
        customer: {
            id: "__test__XpbTXGTSRp3gEsD8"
        },
        apple_app_store: {
            receipt: "Apple Based64 Encoded Receipt",
            product_id: "gold"
        }
    });

    console.log(result);
    const recordedPurchase = result.recorded_purchase;
    const customer = result.customer;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->recordedPurchase()->create([
    "app_id" => "__test__aas_sdfwerzx5134",
    "customer" => [
        "id" => "__test__XpbTXGTSRp3gEsD8"
    ],
    "apple_app_store" => [
        "receipt" => "Apple Based64 Encoded Receipt",
        "product_id" => "gold"
    ]
]);
$recordedPurchase = $result->recorded_purchase;
$customer = $result->customer;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.RecordedPurchase.create(
    cb_client.RecordedPurchase.CreateParams(
        app_id="__test__aas_sdfwerzx5134",
        customer=cb_client.RecordedPurchase.CreateCustomerParams(
            id="__test__XpbTXGTSRp3gEsD8"
        ),
        apple_app_store=cb_client.RecordedPurchase.CreateAppleAppStoreParams(
            receipt="Apple Based64 Encoded Receipt",
            product_id="gold"
        )
    )
)
recorded_purchase = response.recorded_purchase
customer = response.customer
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::RecordedPurchase.create({
  :app_id => "__test__aas_sdfwerzx5134",
  :customer => {
    :id => "__test__XpbTXGTSRp3gEsD8"
  },
  :apple_app_store => {
    :receipt => "Apple Based64 Encoded Receipt",
    :product_id => "gold"
  }
})

recorded_purchase = result.recorded_purchase
customer = result.customer
```

### Record a Google Play Store one-time order using google_play_store[purchase_token] and google_play_store[product_id]

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/recorded_purchases \
     -u {site_api_key}:\
     -d app_id="gp_app_16CbFOUcNBeJWc" \
     -d "customer[id]"="__test__XpbTXGTSRp3gEsD8" \
     -d "google_play_store[purchase_token]"="bhggcokdffngjojmihfobjke" \
     -d "google_play_store[product_id]"="coin"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = RecordedPurchase.Create()
		.AppId("gp_app_16CbFOUcNBeJWc")
		.CustomerId("__test__XpbTXGTSRp3gEsD8")
		.GooglePlayStorePurchaseToken("bhggcokdffngjojmihfobjke")
		.GooglePlayStoreProductId("coin")
		.Request();

RecordedPurchase recordedPurchase = result.RecordedPurchase;
Customer customer = result.Customer;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    recordedpurchaseAction "github.com/chargebee/chargebee-go/v3/actions/recordedpurchase"
    "github.com/chargebee/chargebee-go/v3/models/recordedpurchase"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := recordedpurchaseAction.Create(&recordedpurchase.CreateRequestParams{
        AppId : "gp_app_16CbFOUcNBeJWc",
        Customer : &recordedpurchase.CreateCustomerParams{
            Id : "__test__XpbTXGTSRp3gEsD8",
        },
        GooglePlayStore : &recordedpurchase.CreateGooglePlayStoreParams{
            PurchaseToken : "bhggcokdffngjojmihfobjke",
            ProductId : "coin",
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        RecordedPurchase := res.RecordedPurchase
        Customer := res.Customer
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.RecordedPurchaseCreateRequest{
    AppId : "gp_app_16CbFOUcNBeJWc",
    Customer : &chargebee.RecordedPurchaseCreateCustomer{
        Id : "__test__XpbTXGTSRp3gEsD8",
    },
    GooglePlayStore : &chargebee.RecordedPurchaseCreateGooglePlayStore{
        PurchaseToken : "bhggcokdffngjojmihfobjke",
        ProductId : "coin",
    },
}
  res, err := client.RecordedPurchase.Create(req)
      if err != nil {
        fmt.Println(err)
    } else {
        RecordedPurchase := res.RecordedPurchase
        Customer := res.Customer
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = RecordedPurchase.create()
            .appId("gp_app_16CbFOUcNBeJWc")
            .customerId("__test__XpbTXGTSRp3gEsD8")
            .googlePlayStorePurchaseToken("bhggcokdffngjojmihfobjke")
            .googlePlayStoreProductId("coin")
            .request();

        RecordedPurchase recordedPurchase = result.recordedPurchase();
        Customer customer = result.customer();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.recordedPurchase.RecordedPurchase;
import com.chargebee.v4.models.recordedPurchase.params.RecordedPurchaseCreateParams;
import com.chargebee.v4.models.recordedPurchase.responses.RecordedPurchaseCreateResponse;

public class RecordedPurchaseCreate {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        RecordedPurchaseCreateParams.CustomerParams customerParams =
            RecordedPurchaseCreateParams.CustomerParams.builder()
                .id("__test__XpbTXGTSRp3gEsD8")
                .build();

        RecordedPurchaseCreateParams.GooglePlayStoreParams googlePlayStoreParams =
            RecordedPurchaseCreateParams.GooglePlayStoreParams.builder()
                .purchaseToken("bhggcokdffngjojmihfobjke")
                .productId("coin")
                .build();

        RecordedPurchaseCreateParams params = RecordedPurchaseCreateParams.builder()
            .appId("gp_app_16CbFOUcNBeJWc")
            .customer(customerParams)
            .googlePlayStore(googlePlayStoreParams)
            .build();

        RecordedPurchaseCreateResponse response = client.recordedPurchases().create(params);

        RecordedPurchase recordedPurchase = response.getRecordedPurchase();
        Customer customer = response.getCustomer();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.recordedPurchase.create({
        app_id: "gp_app_16CbFOUcNBeJWc",
        customer: {
            id: "__test__XpbTXGTSRp3gEsD8"
        },
        google_play_store: {
            purchase_token: "bhggcokdffngjojmihfobjke",
            product_id: "coin"
        }
    });

    console.log(result);
    const recordedPurchase = result.recorded_purchase;
    const customer = result.customer;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->recordedPurchase()->create([
    "app_id" => "gp_app_16CbFOUcNBeJWc",
    "customer" => [
        "id" => "__test__XpbTXGTSRp3gEsD8"
    ],
    "google_play_store" => [
        "purchase_token" => "bhggcokdffngjojmihfobjke",
        "product_id" => "coin"
    ]
]);
$recordedPurchase = $result->recorded_purchase;
$customer = $result->customer;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.RecordedPurchase.create(
    cb_client.RecordedPurchase.CreateParams(
        app_id="gp_app_16CbFOUcNBeJWc",
        customer=cb_client.RecordedPurchase.CreateCustomerParams(
            id="__test__XpbTXGTSRp3gEsD8"
        ),
        google_play_store=cb_client.RecordedPurchase.CreateGooglePlayStoreParams(
            purchase_token="bhggcokdffngjojmihfobjke",
            product_id="coin"
        )
    )
)
recorded_purchase = response.recorded_purchase
customer = response.customer
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::RecordedPurchase.create({
  :app_id => "gp_app_16CbFOUcNBeJWc",
  :customer => {
    :id => "__test__XpbTXGTSRp3gEsD8"
  },
  :google_play_store => {
    :purchase_token => "bhggcokdffngjojmihfobjke",
    :product_id => "coin"
  }
})

recorded_purchase = result.recorded_purchase
customer = result.customer
```

### Record a Google Play Store subscription purchase using google_play_store[order_id] (recommended)

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/recorded_purchases \
     -u {site_api_key}:\
     -d app_id="gp_app_16CbFOUcNBeJWc" \
     -d "customer[id]"="__test__XpbTXGTSRp3gEsD8" \
     -d "google_play_store[order_id]"="GPA.3346-4067-5254-30096"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = RecordedPurchase.Create()
		.AppId("gp_app_16CbFOUcNBeJWc")
		.CustomerId("__test__XpbTXGTSRp3gEsD8")
		.GooglePlayStoreOrderId("GPA.3346-4067-5254-30096")
		.Request();

RecordedPurchase recordedPurchase = result.RecordedPurchase;
Customer customer = result.Customer;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    recordedpurchaseAction "github.com/chargebee/chargebee-go/v3/actions/recordedpurchase"
    "github.com/chargebee/chargebee-go/v3/models/recordedpurchase"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := recordedpurchaseAction.Create(&recordedpurchase.CreateRequestParams{
        AppId : "gp_app_16CbFOUcNBeJWc",
        Customer : &recordedpurchase.CreateCustomerParams{
            Id : "__test__XpbTXGTSRp3gEsD8",
        },
        GooglePlayStore : &recordedpurchase.CreateGooglePlayStoreParams{
            OrderId : "GPA.3346-4067-5254-30096",
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        RecordedPurchase := res.RecordedPurchase
        Customer := res.Customer
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.RecordedPurchaseCreateRequest{
    AppId : "gp_app_16CbFOUcNBeJWc",
    Customer : &chargebee.RecordedPurchaseCreateCustomer{
        Id : "__test__XpbTXGTSRp3gEsD8",
    },
    GooglePlayStore : &chargebee.RecordedPurchaseCreateGooglePlayStore{
        OrderId : "GPA.3346-4067-5254-30096",
    },
}
  res, err := client.RecordedPurchase.Create(req)
      if err != nil {
        fmt.Println(err)
    } else {
        RecordedPurchase := res.RecordedPurchase
        Customer := res.Customer
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = RecordedPurchase.create()
            .appId("gp_app_16CbFOUcNBeJWc")
            .customerId("__test__XpbTXGTSRp3gEsD8")
            .googlePlayStoreOrderId("GPA.3346-4067-5254-30096")
            .request();

        RecordedPurchase recordedPurchase = result.recordedPurchase();
        Customer customer = result.customer();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.recordedPurchase.RecordedPurchase;
import com.chargebee.v4.models.recordedPurchase.params.RecordedPurchaseCreateParams;
import com.chargebee.v4.models.recordedPurchase.responses.RecordedPurchaseCreateResponse;

public class RecordedPurchaseCreate {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        RecordedPurchaseCreateParams.CustomerParams customerParams =
            RecordedPurchaseCreateParams.CustomerParams.builder()
                .id("__test__XpbTXGTSRp3gEsD8")
                .build();

        RecordedPurchaseCreateParams.GooglePlayStoreParams googlePlayStoreParams =
            RecordedPurchaseCreateParams.GooglePlayStoreParams.builder()
                .orderId("GPA.3346-4067-5254-30096")
                .build();

        RecordedPurchaseCreateParams params = RecordedPurchaseCreateParams.builder()
            .appId("gp_app_16CbFOUcNBeJWc")
            .customer(customerParams)
            .googlePlayStore(googlePlayStoreParams)
            .build();

        RecordedPurchaseCreateResponse response = client.recordedPurchases().create(params);

        RecordedPurchase recordedPurchase = response.getRecordedPurchase();
        Customer customer = response.getCustomer();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.recordedPurchase.create({
        app_id: "gp_app_16CbFOUcNBeJWc",
        customer: {
            id: "__test__XpbTXGTSRp3gEsD8"
        },
        google_play_store: {
            order_id: "GPA.3346-4067-5254-30096"
        }
    });

    console.log(result);
    const recordedPurchase = result.recorded_purchase;
    const customer = result.customer;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->recordedPurchase()->create([
    "app_id" => "gp_app_16CbFOUcNBeJWc",
    "customer" => [
        "id" => "__test__XpbTXGTSRp3gEsD8"
    ],
    "google_play_store" => [
        "order_id" => "GPA.3346-4067-5254-30096"
    ]
]);
$recordedPurchase = $result->recorded_purchase;
$customer = $result->customer;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.RecordedPurchase.create(
    cb_client.RecordedPurchase.CreateParams(
        app_id="gp_app_16CbFOUcNBeJWc",
        customer=cb_client.RecordedPurchase.CreateCustomerParams(
            id="__test__XpbTXGTSRp3gEsD8"
        ),
        google_play_store=cb_client.RecordedPurchase.CreateGooglePlayStoreParams(
            order_id="GPA.3346-4067-5254-30096"
        )
    )
)
recorded_purchase = response.recorded_purchase
customer = response.customer
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::RecordedPurchase.create({
  :app_id => "gp_app_16CbFOUcNBeJWc",
  :customer => {
    :id => "__test__XpbTXGTSRp3gEsD8"
  },
  :google_play_store => {
    :order_id => "GPA.3346-4067-5254-30096"
  }
})

recorded_purchase = result.recorded_purchase
customer = result.customer
```

## Sample Response

```json
{
  "recorded_purchase": {
    "id": "__test__rp_ASDsdfs123ld1",
    "app_id": "__test__aas_sdfwerzx5134",
    "customer_id": "__test__XpbTXGTSRp3gEsD8",
    "source": "apple_app_store",
    "status": "completed",
    "omnichannel_transaction_id": "__test__ot_LKedfs123ld1",
    "linked_omnichannel_subscriptions": [
      {
        "omnichannel_subscription_id": "__test__os_AHsdfs123ld1"
      },
      {..}
    ],
    "created_at": 1517487053,
    "object": "recorded_purchase"
  },
  "customer": {
    "id": "__test__XpbTXGTSRp3gEsD8",
    "first_name": "John",
    "last_name": "Doe",
    "email": "johndoe@example.com",
    "created_at": 1612890916,
    "updated_at": 1612890916,
    "object": "customer"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/recorded_purchases

## Input Parameters

- `app_id` (required, string, max chars=100)
  App Identifier in Chargebee. This is the handle created by Chargebee for your app. To get the `app_id`:
  
  -   For **Apple**, follow [these steps](https://www.chargebee.com/docs/billing/2.0/mobile-subscriptions/omnichannel-app-store#create-an-omnichannel-subscription-for-in-app-purchases).
  -   For **Google**, follow [these steps](https://www.chargebee.com/docs/billing/2.0/mobile-subscriptions/omnichannel-play-store#connect-google-app-to-chargebee-to-generate-unique-app-id-and-notifications-url).

- `customer` (optional, string)
  Customer parameters for associating (or creating) the Chargebee customer for this purchase.
  - `id` (required, string, max chars=50)
    The `id` of the [customer](/docs/api/customers/customer-object#id) object associated with this purchase. The customer is created if one does not already exist.
  - `email` (optional, string, max chars=70)
    Email of the customer. Used only when the customer is being created.
  - `first_name` (optional, string, max chars=150)
    First name of the customer. Used only when the customer is being created.
  - `last_name` (optional, string, max chars=150)
    Last name of the customer. Used only when the customer is being created.

- `apple_app_store` (optional, string)
  Apple App Store–specific payload used to record the purchase. Provide parameters as `apple_app_store[...]`.
  
  **Google Play Store**: Not applicable. Do not send this object for Google purchases.
  - `transaction_id` (required if the source is apple_app_store and apple_app_store[receipt] is not provided, string, max chars=100)
    **Apple App Store**: The StoreKit transaction identifier for the purchase to record (new subscription, expired re-purchase, or one-time product). Prefer this over `apple_app_store[receipt]` when you already have a transaction ID. Mutually exclusive with the receipt + product\_id pair.
    
    **Google Play Store**: Not applicable.
  - `receipt` (required if the source is apple_app_store and apple_app_store[transaction_id] is not provided, string, max chars=65k)
    **Apple App Store**: The Base64-encoded App Store receipt used to locate and record the purchase. Use together with `apple_app_store[product_id]`. Mutually exclusive with `apple_app_store[transaction_id]` — prefer `transaction_id` when you already have it.
    
    **Google Play Store**: Not applicable.
  - `product_id` (required if the source is apple_app_store and apple_app_store[receipt] is provided, string, max chars=255)
    **Apple App Store**: The App Store Connect `product_id` for the purchase. Required when recording via `apple_app_store[receipt]` (use together with `receipt`). Not required when using `apple_app_store[transaction_id]`.
    
    **Google Play Store**: Not applicable.

- `google_play_store` (optional, string)
  Google Play Store–specific payload used to record the purchase. Provide parameters as `google_play_store[...]`.
  
  **Apple App Store**: Not applicable. Do not send this object for Apple purchases.
  - `purchase_token` (required if the source is google_play_store and google_play_store[order_id] is not provided, string, max chars=500)
    **Google Play Store**: Purchase token from the Android billing client. For subscriptions, you can record tokens when the subscription state in Google is [`SUBSCRIPTION_STATE_ACTIVE`](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2#subscriptionstate) (or other supported states for your flow). For one-time orders, also pass `google_play_store[product_id]`. Prefer `order_id` when you have it. Mutually exclusive with `google_play_store[order_id]`.
    
    **Apple App Store**: Not applicable.
  - `product_id` (required if the source is google_play_store, and if its a one-time order and google_play_store[order_id] is not provided, string, max chars=255)
    **Google Play Store**: In-app `product_id` on Google Play for which the purchase must be recorded. Required when recording a one-time order via `google_play_store[purchase_token]`. Not required when using `google_play_store[order_id]`.
    
    **Apple App Store**: Not applicable.
  - `order_id` (required if the source is google_play_store and google_play_store[purchase_token] is not provided, string, max chars=100)
    **Google Play Store**: Google Play `orderId`. Recommended for both subscriptions and one-time orders. Prefer this over `purchase_token` when available. Mutually exclusive with `google_play_store[purchase_token]` (+ optional `product_id` for OTO).
    
    **Apple App Store**: Not applicable.

- `omnichannel_subscription` (optional, string)
  Optional parameters for the omnichannel subscription created from this purchase.
  - `id` (optional, string, max chars=50)
    Specifies the `id` to assign as the omnichannel subscription identifier for this purchase. If not provided, Chargebee automatically generates an ID. Applicable to subscription purchases.

## Returns

- `recorded_purchase` (Recorded purchase object)
  The `recorded_purchase` job object returned when the request is accepted synchronously. Includes `status` and linked resources when the async job completes. Synchronous API errors (for example, invalid `app_id` or a malformed request) occur before this object is returned.

- `customer` (Customer object)
  Customer associated with the recorded purchase (created or existing).
