POST /recorded_purchases

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.

Servers

Request headers

Name Type Required Description
chargebee-request-origin-device String No

The device from which the customer has made the request

Content-Type String Yes The media type of the request body.

Default value: "application/x-www-form-urlencoded"

chargebee-event-webhook String No

skip only webhooks

Possible values:

  • "all-disabled"
chargebee-business-entity-id String No

If the site has multiple business entities, you can use this custom HTTP header to specify the business entity for which Chargebee should perform the operation.

chargebee-event-actions String No

skip all actions to be done on the events

Possible values:

  • "all-disabled"
chargebee-request-origin-user String No

The email address of your customer/user. Use this when the email address has only ASCII characters.

chargebee-request-origin-ip String No

The IP address of the customer where the request originated

chargebee-request-origin-user-encoded String No

The Base64-encoded email address of your customer/user. Use this if the email address has UTF-8 characters. When this header is provided, the header chargebee-request-origin-user is ignored.

chargebee-event-email String No

skip only emails

Possible values:

  • "all-disabled"

Request body fields

Name Type Required Description
customer Object No

Parameters for customer

customer.id String Yes

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.

omnichannel_subscription Object No

Parameters for `omnichannel_subscriptions`

omnichannel_subscription.id String No

Specifies the id to assign as the omnichannel subscription identifier for this purchase. If not provided, Chargebee automatically generates an ID.

app_id String Yes

App Identifier in Chargebee. This is the handle created by Chargebee for your app. To get this app_id follow these steps.

google_play_store Object No

Parameters for `google_play_store`

google_play_store.purchase_token String No

The purchase_token received from the Google Play Store either from the Android device during a new subscription purchase or from the Google Play Console. You can record purchase tokens using this API if the subscription state in Google is SUBSCRIPTION_STATE_ACTIVE.

apple_app_store Object No

The source specific request payload that will be used to record the purchase. Provide parameters as `apple_app_store[``]`

apple_app_store.product_id String No

The product_id for which the purchase has to be recorded

apple_app_store.transaction_id String No

The transaction_id received from Apple App Store during a new subscription purchase or the re-purchase of an expired subscription.

apple_app_store.receipt String No

The receipt from which transaction_id is fetched and recorded

How to start integrating

  1. Add HTTP Task to your workflow definition.
  2. Search for the API you want to integrate with and click on the name.
    • This loads the API reference documentation and prepares the Http request settings.
  3. Click Test request to test run your request to the API and see the API's response.