Important
- Record purchase operations are asynchronous, as they involve validating the purchase with the respective source, like Apple and Google.
- This resource is applicable for Apple App Store and Google Play Store.
The recorded purchase resource represents a background job of syncing in-app purchases made through external storefronts like Apple and Google with Chargebee. The status (in_process, completed, and failed) attribute represents the current status of the background job.
Record Apple and Google In-App Purchases and Retrieve Associated Omni-Subscription and Transaction from Chargebee
You can record in-app subscription purchases made on the Apple App Store in Chargebee using the transaction[id] or using receipt and product[id] received after a successful purchase.
To record the purchase and retrieve subscription details, follow these steps:
-
Use the Record a Purchase API to record a subscription purchase made in in Apple App Store or Google Play Store.
-
Record an Apple App Store purchase using transaction id with the
app_id,customer[id]andtransaction[id]. -
Record an Apple App Store purchase using receipt with the
app_id,customer[id],receiptandproduct[id]. -
Record a Google Play Store one time order or subscription purchase with the
app_id,customer[id]andorder_id(Recommended). -
Record a Google Play Store subscription purchase with the
app_id,customer[id]andpurchase_token. -
Record a Google Play Store one time order purchase with the
app_id,customer[id],purchase_tokenandproduct_id.
-
-
The API response will include a
recorded_purchaseobject containing thestatusof the purchase recording job. -
Once the purchase is successfully recorded, the
statusattribute of therecorded_purchaseobject updates fromin_processtocompleted. At this point, Chargebee creates anomnichannel_subscriptionresource and triggers anomnichannel_subscription_createdwebhook event, which contains theomnichannel_subscriptionandomnichannel_transactionobjects. -
In addition to using Webhooks (push-based), you can retrieve details for a recorded purchase by using the recorded purchase resource's ID, which is returned when you record the purchase.
Sample Recorded purchaseJSON
Recorded purchases attributes
The id
of the customer
object that is associated with this purchase. If the customer_id
is not present in Chargebee when the record_a_purchase
API request is made, the API will return an error. Use create_a_customer
API to create a customer.
App Identifier in Chargebee. This is the handle created by Chargebee for your app. To get the app_id:
- For Apple, follow these steps.
- For Google, follow these steps.
The source where the purchase is originally made and managed.
When source of the application is Apple App Store
When source of the application is Google Play Store
Current status of the recorded purchase operation
When the purchase recording job is in progress. In this state you will not
receive the omnichannel_transaction_id
and linked_omnichannel_subscriptions
object.
When the purchase recording job status is complete. You will receive the omnichannel_transaction_id
and linked_omnichannel_subscriptions
object.
When the purchase recording job is failed. In this state you will not
receive the omnichannel_transaction_id
and linked_omnichannel_subscriptions
object. Check the error_detail
attribute to understand the reason for failure.
When the purchase recording job is initiated for an omnichannel subscription that already exists in Chargebee.
The id
of the omni transaction
object associated with the purchase.
Indicates timestamp when the recorded_purchase
resource is created in Chargebee.
Version number of this resource. The resource_version
is updated with a new timestamp in milliseconds for every change made to the resource.
The list of omni subscriptions created in response for this purchase. Applicable only for subscription purchases.
The list of omnichannel one time orders created in response for this purchase. Applicable only for one time order purchases.