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.
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]
and
transaction[id].
Record an Apple App Store purchase using receipt with the
app_id,
customer[id],
receipt
and product[id].
Record a Google Play Store one time order or subscription purchase with the
app_id,
customer[id]
and
order_id (Recommended).
Record a Google Play Store subscription purchase with the
app_id,
customer[id]
and
purchase_token.
Record a Google Play Store one time order purchase with the
app_id,
customer[id],
purchase_token
and
product_id.
The API response will include a recorded_purchase object containing the
status of the purchase
recording job.
Once the purchase is successfully recorded, the
status attribute of
the recorded_purchase object updates from in_process to completed. At
this point, Chargebee creates an omnichannel_subscription resource and triggers an
omnichannel_subscription_created webhook event, which contains the
omnichannel_subscription and omnichannel_transaction objects.
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.
{
"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"
}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:
failed. It provides more details about the failure.The Record a Purchase API allows you to record in-app purchases made through channels such as the Apple App Store and Google Play Store in Chargebee. When you invoke this API, it initiates a purchase recording job and returns the recorded_purchase resource in the response. As part of the job, the API verifies the provided source specific request payload like transaction_id for Apple App Store or purchase_token for Google Play Store with the source such as apple_app_store or google_play_store respectively. If the verification is successful, the corresponding purchase is recorded in Chargebee. Upon completion, the recorded_purchase resource will include the relevant omnichannel_transaction_id and omnichannel_subscription_id.
Since this operation is asynchronous, you need to check the status attribute of the recorded_purchase resource to track the job status: in_process, completed, or failed.
Note: Upon successful completion of this asynchronous operation, Chargebee triggers the omnichannel_subscription_created event.
If the recorded_purchase status is failed, review the error_detail attribute and take corrective action to re-record the purchase.
You can use this API to record new and older purchases made on Apple App Store or Google Play Store by passing the transaction_id or purchase_token respectively received during the subscription purchase. You can record purchases for subscriptions that are in Active or Expired status.
App Identifier in Chargebee. This is the handle created by Chargebee for your app. To get the app_id:
The Retrieve a Recorded Purchase API retrieves a recorded_purchase object using the recorded_purchase.id returned in the response of the Record a Purchase API. You can use this API to check if the purchase was successfully recorded in Chargebee and to obtain the omnichannel_transaction_id and omnichannel_subscription_id associated with the successfully recorded purchase.