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.
- Subscriptions cannot be imported from the Google Play Store without a receipt or token. Therefore; Chargebee does not allow you to use this API for the Google Play Store.
- Enable V1 notifications in the Apple App Store for subscriptions created without receipts. Chargebee depends on receipt data to update subscription statuses. Apple’s V2 notifications do not have receipt information; therefore, Chargebee cannot process V2 notifications for subscriptions imported without receipts. Learn more about app store notifications and notification URL configuration.
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
-
Integrate Chargebee with your Apple App Store account using your shared secret from Apple.
-
It is strongly recommended to use this endpoint to create a historic In-App subscription only.
-
You must import App Store products using Chargebee’s user interface before importing receipts using this API.
Chargebee validates the application ID with Apple App Store and does the following once validation succeeds:
<!--- PC 2.0--->Subscription
-
Import the subscription from the
latest_receipt_infoarray 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. -
Each subscription imported has the following attribute set:
-
idset tosubscription[id]. Thissubscription[id]isoriginal_transaction_idin the receipts. -
start_dateset tosubscription[start_date]. You need to provide this information from the oldestLatest_receipt_info.purchase_date_ms. -
term_startset tosubscription[term_start]. You need to provide this information from the oldestLatest_receipt_info.purchase_date_ms). -
term_endset tosubscription[term_end]. You need to provide this information from the oldestLatest_receipt_info.expires_date_ms. -
item_price_idset tosubscription[product_id] + subscription[currency_code].You need to provide this information from theLatest_receipt_info.product_id. -
Chargebee records the subscription in a Trial state if the
is_trial_periodistrue. -
Chargebee records the subscription in a Canceled state if the
term_endis less than theSystem.currentTime().
-
Invoice for the subscription
-
The payment is recorded against the subscription invoice.
-
Imported invoice has the
subscription_idset tooriginal_transaction_id.
-
Transactions for the invoice
-
The associated transaction is updated with the following details:
-
The
transaction.reference_numberis set to thetransaction_idof the payment. -
The
transaction.payment_methodis set toapple_store.
-
Path Parameter
To obtain the value of in_app_subscription_app_id for 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
- {protocol}://{site}.{environment}:{port}/api/v2
- {protocol}://{site}-test.{environment}:{port}/api/v2
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 Valid values:
|
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 Valid values:
|
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 Valid values:
|
Request body fields
| Name | Type | Required | Description |
|---|---|---|---|
customer |
Object | No |
Parameters for customer |
customer.id |
String | No |
The unique |
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 |
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 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 |
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 |
subscription.term_start |
Integer | Yes |
Start date of the billing period for the subscription. You can find it from the |
subscription.term_end |
Integer | Yes |
End date of the billing period for the subscription. You can find it from the |
How to start integrating
- Add HTTP Task to your workflow definition.
- 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.
- Click Test request to test run your request to the API and see the API's response.