POST /in_app_subscriptions/{in-app-subscription-app-id}/import_subscription

The Import Subscriptions endpoint is a Chargebee API that allows you to import historic In-App Subscriptions without using a valid Apple App Store receipt. This endpoint is useful if you do not have access to the receipt data which is required for the Import Receipt API.

With this API, you can import subscriptions and corresponding invoices for historic In-App purchases. The API returns the in-app-subscriptions object once the historic subscription is successfully imported into Chargebee.
Note :

Apple App Store

This section provides details of the Import Subscription operation when performed for the Apple App Store. This API creates a historic subscription if the incoming subscription is unknown. For a known subscription, it creates an invoice for the mentioned period.
Important

Chargebee validates the application ID with Apple App Store and does the following once validation succeeds:

Subscription

  1. Import the subscription from the latest_receipt_info array from Apple and a new subscription is imported for the item-price.
    Note: The subscription is not imported if it already exists in Chargebee but we will import the associated invoice using the subscription[transaction_id] in the payload.

  2. Each subscription imported has the following attribute set:

    • id set to subscription[id] . This subscription[id] is original_transaction_id in the receipts.

    • start_date set to subscription[start_date]. You need to provide this information from the oldest Latest_receipt_info.purchase_date_ms.

    • term_start set to subscription[term_start]. You need to provide this information from the oldest Latest_receipt_info.purchase_date_ms).

    • term_end set to subscription[term_end]. You need to provide this information from the oldest Latest_receipt_info.expires_date_ms.

    • item_price_id set to subscription[product_id] + subscription[currency_code]. You need to provide this information from the Latest_receipt_info.product_id.

    • Chargebee records the subscription in a Trial state if the is_trial_period is true.

    • Chargebee records the subscription in a Canceled state if the term_end is less than the System.currentTime().

Invoice for the subscription

  1. The payment is recorded against the subscription invoice.

    • Imported invoice has the subscription_id set to original_transaction_id.

Transactions for the invoice

  1. The associated transaction is updated with the following details:

    • The transaction.reference_number is set to the transaction_id of the payment.

    • The transaction.payment_method is set to apple_store.

Path Parameter

in_app_subscription_app_id
required, string

The handle created by Chargebee for your App Store app. It can be obtained from within the Chargebee web app.

To obtain the value of in_app_subscription_app_idfor the Apple App Store, click View Keys within the Sync Overview page of the web app, and use the value of generated App ID for this parameter. See detailed steps here.

Servers

Path parameters

Name Type Required Description
in-app-subscription-app-id String Yes

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 No

The unique id in Chargebee for the customer who made this purchase. If not provided, the value is considered to be original_transaction_id (the transaction identifier at Apple, of the original purchase.). If the customer record is not found in Chargebee, it is created.

customer.email String No

The email ID of the customer who made this purchase.

subscription Object No

Parameters for subscription

subscription.id String Yes

This parameter is known as original_transaction_id in Apple App Store. You can get the value of original_transaction_id from the latest_receipt_info. The latest_receipt_info is an array that contains all in-app purchase transactions.

subscription.currency_code String Yes

The currency code (ISO 4217 format) for the product.

subscription.is_trial Boolean No

Indicates if the subscription is in trial for the term start and term end. The default value is false.

Default value: false

subscription.product_id String Yes

The unique identifier of the product as configured in App Store Connect.

subscription.transaction_id String Yes

Transaction ID value as mentioned in the latest_receipt_info. This must be unique across subscriptions.

subscription.started_at Integer Yes

The time at which the subscription has started or going to be started. You can find this value from the oldest purchase_date_ms.

subscription.term_start Integer Yes

Start date of the billing period for the subscription. You can find it from the purchase_date_ms field in receipt payload.

subscription.term_end Integer Yes

End date of the billing period for the subscription. You can find it from the expires_date_ms field in receipt payload.

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.