chargebee 2.26.0 → 2.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/lib/chargebee.js +1 -1
  3. package/package.json +1 -1
  4. package/types/core.d.ts +1 -0
  5. package/types/resources/Address.d.ts +245 -5
  6. package/types/resources/AdvanceInvoiceSchedule.d.ts +78 -2
  7. package/types/resources/AttachedItem.d.ts +305 -13
  8. package/types/resources/Card.d.ts +485 -13
  9. package/types/resources/Comment.d.ts +177 -11
  10. package/types/resources/Contact.d.ts +54 -0
  11. package/types/resources/ContractTerm.d.ts +83 -0
  12. package/types/resources/Coupon.d.ts +665 -20
  13. package/types/resources/CouponCode.d.ts +56 -5
  14. package/types/resources/CouponSet.d.ts +224 -17
  15. package/types/resources/CreditNote.d.ts +1202 -44
  16. package/types/resources/CreditNoteEstimate.d.ts +75 -6
  17. package/types/resources/Customer.d.ts +2132 -73
  18. package/types/resources/DifferentialPrice.d.ts +266 -15
  19. package/types/resources/Discount.d.ts +107 -0
  20. package/types/resources/Download.d.ts +18 -0
  21. package/types/resources/EntitlementOverride.d.ts +101 -7
  22. package/types/resources/Estimate.d.ts +1181 -27
  23. package/types/resources/Event.d.ts +145 -8
  24. package/types/resources/Export.d.ts +703 -32
  25. package/types/resources/Feature.d.ts +356 -22
  26. package/types/resources/Gift.d.ts +351 -24
  27. package/types/resources/Hierarchy.d.ts +30 -0
  28. package/types/resources/HostedPage.d.ts +1212 -37
  29. package/types/resources/ImpactedItem.d.ts +41 -1
  30. package/types/resources/ImpactedSubscription.d.ts +36 -1
  31. package/types/resources/InAppSubscription.d.ts +636 -9
  32. package/types/resources/Invoice.d.ts +2293 -93
  33. package/types/resources/InvoiceEstimate.d.ts +75 -6
  34. package/types/resources/Item.d.ts +542 -16
  35. package/types/resources/ItemEntitlement.d.ts +172 -13
  36. package/types/resources/ItemFamily.d.ts +173 -15
  37. package/types/resources/ItemPrice.d.ts +971 -26
  38. package/types/resources/Media.d.ts +24 -0
  39. package/types/resources/NonSubscription.d.ts +51 -3
  40. package/types/resources/Order.d.ts +1224 -32
  41. package/types/resources/PaymentIntent.d.ts +318 -8
  42. package/types/resources/PaymentReferenceNumber.d.ts +24 -0
  43. package/types/resources/PaymentSource.d.ts +1259 -55
  44. package/types/resources/PaymentVoucher.d.ts +262 -14
  45. package/types/resources/PortalSession.d.ts +187 -10
  46. package/types/resources/PromotionalCredit.d.ts +351 -16
  47. package/types/resources/Purchase.d.ts +274 -5
  48. package/types/resources/Quote.d.ts +1595 -62
  49. package/types/resources/QuoteLineGroup.d.ts +134 -5
  50. package/types/resources/QuotedCharge.d.ts +63 -5
  51. package/types/resources/QuotedSubscription.d.ts +192 -5
  52. package/types/resources/ResourceMigration.d.ts +73 -3
  53. package/types/resources/SiteMigrationDetail.d.ts +98 -5
  54. package/types/resources/Subscription.d.ts +3462 -137
  55. package/types/resources/SubscriptionEntitlement.d.ts +116 -8
  56. package/types/resources/SubscriptionEstimate.d.ts +36 -2
  57. package/types/resources/TaxWithheld.d.ts +32 -0
  58. package/types/resources/ThirdPartyPaymentMethod.d.ts +24 -0
  59. package/types/resources/TimeMachine.d.ts +99 -7
  60. package/types/resources/Token.d.ts +179 -7
  61. package/types/resources/Transaction.d.ts +597 -25
  62. package/types/resources/UnbilledCharge.d.ts +355 -14
  63. package/types/resources/Usage.d.ts +259 -13
  64. package/types/resources/VirtualBankAccount.d.ts +255 -17
@@ -1,46 +1,673 @@
1
1
  ///<reference path='./../core.d.ts'/>
2
2
  declare module 'chargebee' {
3
3
  export interface InAppSubscription {
4
+
5
+ /**
6
+ * @description The &#x60;id&#x60; of the [subscription](subscriptions#subscription_id) for which the receipt was sent.
7
+
8
+ */
9
+
4
10
  subscription_id:string;
11
+
12
+ /**
13
+ * @description The &#x60;id&#x60; of the [customer](customers#customer_id) object to which the subscription belongs.
14
+
15
+ */
16
+
5
17
  customer_id?:string;
18
+
19
+ /**
20
+ * @description The &#x60;id&#x60; of the plan-item price of the subscription.
21
+
22
+ */
23
+
6
24
  plan_id?:string;
25
+
26
+ /**
27
+ * @description The status of the subscription for the store \* paused - When the subscription is paused. \* in_trial - When the subscription is in trial. \* active - When the subscription is active. \* cancelled - When the subscription is cancelled.
28
+
29
+ */
30
+
7
31
  store_status?:'in_trial' | 'paused' | 'active' | 'cancelled';
32
+
33
+ /**
34
+ * @description The &#x60;id&#x60; of the invoice generated in Chargebee
35
+
36
+ */
37
+
8
38
  invoice_id?:string;
9
39
  }
10
40
  export namespace InAppSubscription {
11
- export class InAppSubscriptionResource {
41
+ export class InAppSubscriptionResource {
42
+ /**
43
+ * @description This API verifies the application id &#x60;{in_app_subscription_app_id}&#x60; and &#x60;receipt&#x60; then returns the subscription details associated with the purchase.
44
+
45
+ #### Path Parameter
46
+
47
+ in_app_subscription_app_id
48
+ required, string
49
+
50
+ The handle is created by Chargebee for your Apple App Store or Google Play Store app. It can be obtained from the Chargebee web app.
51
+
52
+ The following are instructions to obtain the value of the path parameter for the Apple App Store and Google Play Store.
53
+
54
+ * **Apple App Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, 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](https://www.chargebee.com/docs/1.0/mobile-app-store-product-iap.html#resource-id).
55
+ * **Google Play Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, click **Set up notifications** within the **Sync Overview** page of the web app and use the value of generated **App ID** for this parameter. See detailed steps [here](https://www.chargebee.com/docs/1.0/mobile-playstore-notifications.html#app-id).
56
+
57
+ */
58
+
12
59
  retrieve_store_subs(in_app_subscription_app_id:string, input:RetrieveStoreSubsInputParam):ChargebeeRequest<RetrieveStoreSubsResponse>;
60
+
61
+ /**
62
+ * @description Verifies an Apple App Store or Google Play Store in-app purchase [receipt](https://developer.apple.com/documentation/storekit/original_api_for_in-app_purchase/validating_receipts_with_the_app_store?language&#x3D;objc#overview) and imports [subscriptions](/docs/api/subscriptions) for all historical purchases made by the customer.
63
+ **Tip**
64
+ An &#x60;in_app_subscription&#x60; is created for every unique &#x60;original_transaction_id&#x60;. Apple creates &#x60;original_transaction_id&#x60; for every create, upgrade, or downgrade of the subscription. A receipt hardly contains more than 100 &#x60;original_transaction_id&#x60;s. If a receipt contains more than 100 &#x60;original_transaction_id&#x60;s, Chargebee creates all subscription records but this endpoint returns the first 100 records in the response.
65
+
66
+ CSV upload has a file size [limitation](https://www.chargebee.com/docs/mobile-app-store-product-iap.html#upload-in-app-receipts) that increases the processing time and the number of receipts. This API removes such limitations and allows you to import historical in-app subscription receipts.
67
+
68
+ Apple App Store {#app_store}
69
+ ----------------------------
70
+
71
+ This section provides details of the Import Receipt operation performed for the Apple App Store. This API processes only the historical in-app transaction receipts.
72
+ **Important**
73
+
74
+ * [Integrate Chargebee](https://www.chargebee.com/docs/mobile-app-store-connect.html#connnect-with-your-chargebee-site) with your Apple App Store account using your shared secret from Apple.
75
+ * It is strongly recommended to use this endpoint to import historical in-app subscriptions only.
76
+ * You must [import Apple App Store products](https://www.chargebee.com/docs/2.0/mobile-app-store-product-iap.html#import-products) using Chargebee&#x27;s user interface before importing receipts using this API.
77
+
78
+ Chargebee validates the &#x60;receipt&#x60; with Apple App Store and does the following once validation succeeds:
79
+
80
+ #### Subscriptions {#ir_apple_app_store_pcv2}
81
+
82
+ [Subscriptions](/docs/api/subscriptions) are imported as follows:
83
+
84
+ 1. A subscription is imported for every unique value of the [original_transaction_id](https://developer.apple.com/documentation/appstorereceipts/original_transaction_id?language&#x3D;objc) in the Apple receipt.
85
+ **Note** : This is not done for &#x60;original_transaction_id&#x60;s for which a subscription already exists in Chargebee.
86
+ 2. Each subscription imported has the following attributes set:
87
+ * &#x60;id&#x60; set to &#x60;original_transaction_id&#x60;.
88
+ * &#x60;start_date&#x60; set to the earliest [purchase_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc).
89
+ * &#x60;current_term_start&#x60; set to latest [purchase_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc).
90
+ * &#x60;current_term_end&#x60; set to [expires_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc) of the same &#x60;Latest_receipt_info&#x60; element with the latest &#x60;purchase_date_ms&#x60;.
91
+ * &#x60;item_price_id&#x60; set to &#x60;product_id&#x60;.
92
+ * &#x60;status&#x60; set to &#x60;in_trial&#x60; if there is only one element of [Latest_receipt_info](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc) with the &#x60;original_transaction_id&#x60; and the field &#x60;is_trial_period&#x60; is &#x60;true&#x60;, then consider the subscription is currently in trial. No invoices are created for this subscription.
93
+
94
+ #### Invoices for the subscription
95
+
96
+ [Invoices](/docs/api/invoices) are imported as follows:
97
+
98
+ 1. An invoice is imported to Chargebee for every element of the array [Latest_receipt_info](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc) which has [is_trial_period](https://developer.apple.com/documentation/appstorereceipts/is_trial_period?language&#x3D;objc) as &#x60;false&#x60;.
99
+ 2. Each imported invoice has the &#x60;subscription_id&#x60; set to &#x60;original_transaction_id&#x60;.
100
+
101
+ #### Transactions for the invoices
102
+
103
+ A [transaction](/docs/api/transactions) is imported for each invoice with the following details:
104
+
105
+ 1. &#x60;reference_number&#x60; set to the &#x60;transaction_id&#x60;.
106
+ 2. &#x60;payment_method&#x60; set to &#x60;apple_store&#x60;.
107
+
108
+
109
+
110
+ Google Play Store {#app_store}
111
+ ------------------------------
112
+
113
+ This section provides details of the Import Receipt operation performed for the Google Play Store. This API is used to process only the historical in-app purchase subscriptions.
114
+ **Important**
115
+
116
+ * [Integrate Chargebee](https://www.chargebee.com/docs/2.0/mobile-playstore-connect.html) with your Google Play Store account using your [service account credentials JSON](https://www.chargebee.com/docs/2.0/mobile-playstore-connect.html#generate-service-account-credentials-json).
117
+ * It is strongly recommended to use this endpoint to import historical in-app subscriptions only.
118
+ * It is recommended to pass only the latest purchase &#x60;token&#x60;. If any other purchase &#x60;token&#x60; is passed instead of the latest one, there is a possibility of returning incorrect transaction details. If an expired purchase &#x60;token&#x60; is passed, then it returns an error.
119
+ * The Google purchase token is [valid for 60 days](https://developer.android.com/google/play/billing/subscriptions#lifecycle) from the subscription purchase date. After the &#x60;token&#x60; expires, an API request to Google Developers API returns an error.
120
+
121
+ Chargebee validates the purchase &#x60;token&#x60; with Google Play Store and does the following once validation succeeds:
122
+
123
+ #### Subscriptions {#ir_google_play_store_pcv2}
124
+
125
+ * A [subscription](/docs/api/subscriptions) is imported for every unique purchase token if it is not linked to an existing purchase &#x60;token&#x60;( &#x60;linkedPurchaseToken&#x60; field in &#x60;SubscriptionsV2.get&#x60; API Response).
126
+
127
+ * Each subscription imported has the following attributes set:
128
+
129
+ * &#x60;id&#x60; set to a unique identifier generated by Chargebee and mapped to the &#x60;token&#x60; and &#x60;latestOrderId&#x60; of the &#x60;SubscriptionPurchaseV2&#x60; object from Google response.
130
+
131
+ * &#x60;start_date&#x60; set to the earliest &#x60;SubscriptionPurchaseV2.startTime&#x60;.
132
+
133
+ * &#x60;current_term_start&#x60; set to latest &#x60;SubscriptionPurchaseV2.startTime&#x60;.
134
+
135
+ * &#x60;current_term_end&#x60; set to &#x60;expiryTime&#x60; of the same &#x60;SubscriptionPurchaseV2&#x60; element with the latest purchase.
136
+
137
+ * &#x60;item_price_id&#x60; set to the concatenation of &#x60;product[id]&#x60; and &#x60;priceCurrencyCode&#x60; from Google.
138
+
139
+ * &#x60;status&#x60; set to &#x60;in_trial&#x60; if the free trial configuration is enabled in Google and the [monetization.subscriptions.basePlans.offers.State](https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions.basePlans.offers#State) is &#x60;Active&#x60; with a [SubscriptionOfferPhase.duration](https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions.basePlans.offers#subscriptionofferphase), then consider the subscription is currently in trial. No invoices are created for this subscription.
140
+
141
+ #### Invoices for the subscription
142
+
143
+ Invoices are imported as follows:
144
+
145
+ * An [invoice](/docs/api/invoices &quot;https://apidocs.chargebee.com/docs/api/invoices?prod_cat_ver&#x3D;2&quot;) is imported to Chargebee for every new subscription and renewal of an existing subscription using &#x60;latestOrderId&#x60;.
146
+
147
+ * Each imported invoice has the &#x60;subscription_id&#x60; set to a unique identifier generated by Chargebee and mapped to the &#x60;token&#x60; and &#x60;latestOrderId&#x60;.
148
+
149
+ #### Transactions for the invoices
150
+
151
+ A [transaction](/docs/api/transactions) is imported for each invoice with the following details:
152
+
153
+ * &#x60;transaction.reference_number&#x60; is set to the &#x60;latestOrderId&#x60;.
154
+
155
+ * &#x60;transaction.payment_method&#x60; is set to &#x60;play_store&#x60;.
156
+
157
+ Path Parameter {#path_param}
158
+ ----------------------------
159
+
160
+ &#x60;{in_app_subscription_app_id}&#x60;: The handle created by Chargebee for your Apple App Store or Google Play Store app. It can be obtained from the Chargebee web app.
161
+
162
+ The following are instructions to obtain the value of the path parameter for the Apple App Store and Google Play Store.
163
+
164
+ * **Apple App Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, 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](https://www.chargebee.com/docs/1.0/mobile-app-store-product-iap.html#connection-keys_app-id).
165
+ * **Google Play Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, click **Set up notifications** within the **Sync Overview** page of the web app and use the value of generated **App ID** for this parameter. See detailed steps [here](https://www.chargebee.com/docs/1.0/mobile-playstore-notifications.html#app-id).
166
+
167
+
168
+
169
+
170
+ */
171
+
13
172
  import_receipt(in_app_subscription_app_id:string, input:ImportReceiptInputParam):ChargebeeRequest<ImportReceiptResponse>;
173
+
174
+ /**
175
+ * @description 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](https://apidocs.chargebee.com/docs/api/in_app_subscriptions#import_receipt) API.
176
+
177
+ With this API, you can import subscriptions and corresponding invoices for historic In-App purchases. The API returns the [in-app-subscriptions object](https://apidocs.chargebee.com/docs/api/in_app_subscriptions#in_app_subscription_attributes) once the historic subscription is successfully imported into Chargebee.
178
+ **Note**: Subscription cannot be imported from Google Play Store without a receipt or token. Therefore; Chargebee does not allow you to use this API for Google Play Store.
179
+
180
+ ### Apple App Store
181
+
182
+ 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.
183
+ **Important**
184
+
185
+ * [Integrate Chargebee](https://www.chargebee.com/docs/mobile-app-store-connect.html#connnect-with-your-chargebee-site) with your Apple App Store account using your shared secret from Apple.
186
+
187
+ * It is strongly recommended to use this endpoint to create a historic In-App subscription only.
188
+
189
+ * You must import App Store products using Chargebee&#x27;s user interface before importing receipts using this API.
190
+
191
+ Chargebee validates the application ID with Apple App Store and does the following once validation succeeds:
192
+
193
+ #### Subscription
194
+
195
+ 1. Import the subscription from the &#x60;latest_receipt_info&#x60; array from Apple and a new subscription is imported for the item-price.
196
+ **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.
197
+
198
+ 2. Each subscription imported has the following attribute set:
199
+
200
+ * &#x60;id&#x60; set to &#x60;subscription[id]&#x60; . This &#x60;subscription[id]&#x60; is &#x60;original_transaction_id&#x60; in the receipts.
201
+
202
+ * &#x60;start_date&#x60; set to &#x60;subscription[start_date]&#x60;. You need to provide this information from the oldest &#x60;Latest_receipt_info.purchase_date_ms&#x60;.
203
+
204
+ * &#x60;term_start&#x60; set to &#x60;subscription[term_start]&#x60;. You need to provide this information from the oldest &#x60;Latest_receipt_info.purchase_date_ms)&#x60;.
205
+
206
+ * &#x60;term_end&#x60; set to &#x60;subscription[term_end]&#x60;. You need to provide this information from the oldest &#x60;Latest_receipt_info.expires_date_ms&#x60;.
207
+
208
+ * &#x60;item_price_id&#x60; set to &#x60;subscription[product_id] + subscription[currency_code].&#x60; You need to provide this information from the &#x60;Latest_receipt_info.product_id&#x60;.
209
+
210
+ * Chargebee records the subscription in a **Trial** state if the &#x60;is_trial_period&#x60; is &#x60;true&#x60;.
211
+
212
+ * Chargebee records the subscription in a **Canceled** state if the &#x60;term_end&#x60; is less than the &#x60;System.currentTime()&#x60;.
213
+
214
+ #### Invoice for the subscription
215
+
216
+ 1. The payment is recorded against the subscription invoice.
217
+
218
+ * Imported invoice has the &#x60;subscription_id&#x60; set to &#x60;original_transaction_id&#x60;.
219
+
220
+ **Transactions for the invoice**
221
+
222
+ 1. The associated transaction is updated with the following details:
223
+
224
+ * The &#x60;transaction.reference_number&#x60; is set to the &#x60;transaction_id&#x60; of the payment.
225
+
226
+ * The &#x60;transaction.payment_method&#x60; is set to &#x60;apple_store&#x60;.
227
+
228
+ #### Path Parameter
229
+
230
+ in_app_subscription_app_id
231
+ required, string
232
+
233
+ The handle created by Chargebee for your App Store app. It can be obtained from within the Chargebee web app.
234
+
235
+ To obtain the value of &#x60;in_app_subscription_app_id &#x60;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](https://www.chargebee.com/docs/mobile-app-store-product-iap.html#connection-keys_app-id).
236
+
237
+ */
238
+
14
239
  import_subscription(in_app_subscription_app_id:string, input?:ImportSubscriptionInputParam):ChargebeeRequest<ImportSubscriptionResponse>;
240
+
241
+ /**
242
+ * @description Verifies an in-app purchase made by your customer and creates a subscription in Chargebee.
243
+ **Tip**
244
+
245
+ The recommended approach is to call this endpoint from the client-side app directly. However, if you are using this API to replace an existing direct integration with Apple or Google, then you may choose to call this API from the server-side.
246
+ **Note:**
247
+
248
+ if App Store or Play Store products have not been imported to Chargebee and this API is invoked, Chargebee will automatically create plans that correspond to the store product IDs. However, if historical subscriptions are to be imported using the [import receipt](https://apidocs.chargebee.com/docs/api/in_app_subscriptions#import_receipt) API, importing products is mandatory. [Learn more](https://www.chargebee.com/docs/mobile_subscriptions.html).
249
+
250
+ Apple App Store {#app_store}
251
+ ----------------------------
252
+
253
+ This section provides details of the Process Purchase Command operation when performed for the Apple App Store. This API processes only the latest in-app transaction on the receipt. Sync historical subscriptions into Chargebee using [bulk import](https://www.chargebee.com/docs/2.0/mobile-app-store-product-iap.html#import-in-app-purchase-receipts) of In-App Purchase receipts.
254
+ **Important**
255
+
256
+ * [Integrate Chargebee](https://www.chargebee.com/docs/mobile-app-store-connect.html#connnect-with-your-chargebee-site) with your Apple App Store account using your shared secret from Apple.
257
+ * It is strongly recommended to use this endpoint to notify Chargebee of **new** purchases only.
258
+ * For updates to existing subscriptions, we recommend that you configure Apple App Store to send server notifications to Chargebee.
259
+
260
+ Chargebee validates the &#x60;receipt&#x60; with Apple App Store and does the following once validation succeeds:
261
+
262
+ 1. Look for [item_family.id](/docs/api/item_families?prod_cat_ver&#x3D;2#item_family_id) that matches the value Apple-App-Store, and create such a product family if not found.
263
+ 2. Look for [item.id](/docs/api/items?prod_cat_ver&#x3D;2#item_id) that matches &#x60;product[id]&#x60; and if not found, create such a plan-item under the item family described in the previous step.
264
+ 3. Look for [item_price.id](/docs/api/item_prices?prod_cat_ver&#x3D;2#item_price_id) that matches the concatenation of &#x60;product[id]&#x60; and &#x60;product[currency_code]&#x60;, and if not found, create such an item price under the item described in the previous step.
265
+ 4. Create/update a subscription:
266
+ * If the receipt is for a new purchase, a new subscription is created for the plan-item price described in the previous step. The subscription has the following details:
267
+ * &#x60;id&#x60; set to [original_transaction_id](https://developer.apple.com/documentation/appstorereceipts/original_transaction_id?language&#x3D;objc)
268
+ * &#x60;start_date&#x60; set to [responseBody.Latest_receipt_info.purchase_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc)
269
+ * &#x60;current_term_end&#x60; set to &#x60;responseBody.Latest_receipt_info.expires_date_ms&#x60;
270
+ * Instead, if the receipt belongs to an existing subscription in Chargebee, it is updated to reflect the current state of the subscription at Apple.
271
+ 5. The payment is recorded against the subscription invoice. The associated transaction is updated with the following details:
272
+ * The [transaction.reference_number](/docs/api/transactions?prod_cat_ver&#x3D;2#transaction_reference_number) is set to the [transaction_id](https://developer.apple.com/documentation/appstorereceipts/transaction_id?language&#x3D;objc) of the payment.
273
+ * The [transaction.payment_method](/docs/api/transactions#transaction_payment_method) is set to &#x60;apple_pay&#x60;.
274
+
275
+ Google Play Store {#app_store}
276
+ ------------------------------
277
+
278
+ This section provides details of the Process Purchase Command operation when performed for the Google Play Store. This API processes only the latest in-app transaction using the purchase token.
279
+ **Important**
280
+
281
+ * [Integrate Chargebee](https://www.chargebee.com/docs/2.0/mobile-playstore-connect.html#chargebee-configuration) with your Google Play Store account using the service account credentials JSON.
282
+ * It is strongly recommended to use this endpoint to notify Chargebee of **new** purchases only.
283
+ * For updates to existing subscriptions, we recommend that you configure Chargebee to receive Google&#x27;s server notifications through pub/sub topic. [Learn more](https://developer.android.com/google/play/billing/getting-ready#setup-pubsub).
284
+
285
+ Chargebee validates the purchase **token** with Google Play Store and does the following once validation succeeds:
286
+
287
+ 1. Look for [item_family.id](/docs/api/item_families?prod_cat_ver&#x3D;2#item_family_id) that matches the value &#x60;Google-Play-Store&#x60;, and create such a product family if not found.
288
+ 2. Look for [item.id](/docs/api/items?prod_cat_ver&#x3D;2#item_id) that matches &#x60;product[id]&#x60; and if not found, create such a [plan-item](/docs/api/items?prod_cat_ver&#x3D;2#item_type) under the item family described in the previous step.
289
+ 3. Look for [item_price.id](/docs/api/item_prices?prod_cat_ver&#x3D;2#item_price_id) that matches the concatenation of &#x60;product[id]&#x60; and [priceCurrencyCode](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions?hl&#x3D;en#SubscriptionPurchase.FIELDS.price_currency_code), and if not found, create such an item price under the item described in the previous step.
290
+ 4. Create/update a subscription:
291
+ * If this token is for a new purchase, a new subscription is created for the plan-item price described in the previous step. The subscription has the following details:
292
+ * &#x60;id&#x60; set to unique identifier generated by Chargebee and mapped to **token** of the [SubscriptionPurchase](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions?hl&#x3D;en) object from Google response.
293
+ * &#x60;start_date&#x60; set to &#x60;SubscriptionPurchase.startTimeMillis&#x60;.
294
+ * &#x60;current_term_end&#x60; set to &#x60;SubscriptionPurchase.expiryTimeMillis&#x60;.
295
+ * Instead, if the token belongs to an existing subscription in Chargebee, it is updated to reflect the current state of the subscription at Google.
296
+ 5. The payment is recorded against the subscription invoice. The associated transaction is updated with the following details:
297
+ * The [transaction.reference_number](/docs/api/transactions?prod_cat_ver&#x3D;2#transaction_reference_number) is set to the [orderId](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions?hl&#x3D;en#SubscriptionPurchase.FIELDS.order_id) of the payment.
298
+ * The [transaction.payment_method](/docs/api/transactions#transaction_payment_method) is set to &#x60;play_store&#x60;.
299
+
300
+ Path Parameter {#path_param_pcv2}
301
+ ---------------------------------
302
+
303
+ &#x60;{in_app_subscription_app_id}&#x60;: The handle created by Chargebee for your Apple App Store or Google Play Store app. It can be obtained from the Chargebee web app.
304
+
305
+ The following are instructions to obtain the value of the path parameter for the Apple App Store and Google Play Store.
306
+
307
+ * **Apple App Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, 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](https://www.chargebee.com/docs/1.0/mobile-app-store-product-iap.html#resource-id).
308
+ * **Google Play Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, click **Set up notifications** within the **Sync Overview** page of the web app and use the value of generated **App ID** for this parameter. See detailed steps [here](https://www.chargebee.com/docs/1.0/mobile-playstore-notifications.html#app-id).
309
+
310
+
311
+
312
+
313
+ */
314
+
15
315
  process_receipt(in_app_subscription_app_id:string, input:ProcessReceiptInputParam):ChargebeeRequest<ProcessReceiptResponse>;
16
316
  }
17
- export interface RetrieveStoreSubsResponse {
18
- in_app_subscriptions:InAppSubscription[];
317
+ export interface RetrieveStoreSubsResponse {
318
+ /**
319
+ * @description This API verifies the application id &#x60;{in_app_subscription_app_id}&#x60; and &#x60;receipt&#x60; then returns the subscription details associated with the purchase.
320
+
321
+ #### Path Parameter
322
+
323
+ in_app_subscription_app_id
324
+ required, string
325
+
326
+ The handle is created by Chargebee for your Apple App Store or Google Play Store app. It can be obtained from the Chargebee web app.
327
+
328
+ The following are instructions to obtain the value of the path parameter for the Apple App Store and Google Play Store.
329
+
330
+ * **Apple App Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, 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](https://www.chargebee.com/docs/1.0/mobile-app-store-product-iap.html#resource-id).
331
+ * **Google Play Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, click **Set up notifications** within the **Sync Overview** page of the web app and use the value of generated **App ID** for this parameter. See detailed steps [here](https://www.chargebee.com/docs/1.0/mobile-playstore-notifications.html#app-id).
332
+
333
+ */
334
+
335
+ in_app_subscriptions:InAppSubscription[];
19
336
  }
20
337
  export interface RetrieveStoreSubsInputParam {
338
+
339
+ /**
340
+ * @description **Apple App Store** : The Base64 encoded [App Store in-app purchase receipt](https://developer.apple.com/documentation/storekit/original_api_for_in-app_purchase/validating_receipts_with_the_app_store?language&#x3D;objc#overview) taken from the Apple device after successful creation of the in-app purchase subscription.
341
+
342
+ **Google Play Store** : The purchase &#x60;token&#x60; taken from the Android device after the successful creation of an in-app purchase subscription.
343
+
344
+ */
345
+
21
346
  receipt:string;
22
347
  }
23
- export interface ImportReceiptResponse {
24
- in_app_subscriptions:InAppSubscription[];
348
+ export interface ImportReceiptResponse {
349
+ /**
350
+ * @description Verifies an Apple App Store or Google Play Store in-app purchase [receipt](https://developer.apple.com/documentation/storekit/original_api_for_in-app_purchase/validating_receipts_with_the_app_store?language&#x3D;objc#overview) and imports [subscriptions](/docs/api/subscriptions) for all historical purchases made by the customer.
351
+ **Tip**
352
+ An &#x60;in_app_subscription&#x60; is created for every unique &#x60;original_transaction_id&#x60;. Apple creates &#x60;original_transaction_id&#x60; for every create, upgrade, or downgrade of the subscription. A receipt hardly contains more than 100 &#x60;original_transaction_id&#x60;s. If a receipt contains more than 100 &#x60;original_transaction_id&#x60;s, Chargebee creates all subscription records but this endpoint returns the first 100 records in the response.
353
+
354
+ CSV upload has a file size [limitation](https://www.chargebee.com/docs/mobile-app-store-product-iap.html#upload-in-app-receipts) that increases the processing time and the number of receipts. This API removes such limitations and allows you to import historical in-app subscription receipts.
355
+
356
+ Apple App Store {#app_store}
357
+ ----------------------------
358
+
359
+ This section provides details of the Import Receipt operation performed for the Apple App Store. This API processes only the historical in-app transaction receipts.
360
+ **Important**
361
+
362
+ * [Integrate Chargebee](https://www.chargebee.com/docs/mobile-app-store-connect.html#connnect-with-your-chargebee-site) with your Apple App Store account using your shared secret from Apple.
363
+ * It is strongly recommended to use this endpoint to import historical in-app subscriptions only.
364
+ * You must [import Apple App Store products](https://www.chargebee.com/docs/2.0/mobile-app-store-product-iap.html#import-products) using Chargebee&#x27;s user interface before importing receipts using this API.
365
+
366
+ Chargebee validates the &#x60;receipt&#x60; with Apple App Store and does the following once validation succeeds:
367
+
368
+ #### Subscriptions {#ir_apple_app_store_pcv2}
369
+
370
+ [Subscriptions](/docs/api/subscriptions) are imported as follows:
371
+
372
+ 1. A subscription is imported for every unique value of the [original_transaction_id](https://developer.apple.com/documentation/appstorereceipts/original_transaction_id?language&#x3D;objc) in the Apple receipt.
373
+ **Note** : This is not done for &#x60;original_transaction_id&#x60;s for which a subscription already exists in Chargebee.
374
+ 2. Each subscription imported has the following attributes set:
375
+ * &#x60;id&#x60; set to &#x60;original_transaction_id&#x60;.
376
+ * &#x60;start_date&#x60; set to the earliest [purchase_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc).
377
+ * &#x60;current_term_start&#x60; set to latest [purchase_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc).
378
+ * &#x60;current_term_end&#x60; set to [expires_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc) of the same &#x60;Latest_receipt_info&#x60; element with the latest &#x60;purchase_date_ms&#x60;.
379
+ * &#x60;item_price_id&#x60; set to &#x60;product_id&#x60;.
380
+ * &#x60;status&#x60; set to &#x60;in_trial&#x60; if there is only one element of [Latest_receipt_info](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc) with the &#x60;original_transaction_id&#x60; and the field &#x60;is_trial_period&#x60; is &#x60;true&#x60;, then consider the subscription is currently in trial. No invoices are created for this subscription.
381
+
382
+ #### Invoices for the subscription
383
+
384
+ [Invoices](/docs/api/invoices) are imported as follows:
385
+
386
+ 1. An invoice is imported to Chargebee for every element of the array [Latest_receipt_info](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc) which has [is_trial_period](https://developer.apple.com/documentation/appstorereceipts/is_trial_period?language&#x3D;objc) as &#x60;false&#x60;.
387
+ 2. Each imported invoice has the &#x60;subscription_id&#x60; set to &#x60;original_transaction_id&#x60;.
388
+
389
+ #### Transactions for the invoices
390
+
391
+ A [transaction](/docs/api/transactions) is imported for each invoice with the following details:
392
+
393
+ 1. &#x60;reference_number&#x60; set to the &#x60;transaction_id&#x60;.
394
+ 2. &#x60;payment_method&#x60; set to &#x60;apple_store&#x60;.
395
+
396
+
397
+
398
+ Google Play Store {#app_store}
399
+ ------------------------------
400
+
401
+ This section provides details of the Import Receipt operation performed for the Google Play Store. This API is used to process only the historical in-app purchase subscriptions.
402
+ **Important**
403
+
404
+ * [Integrate Chargebee](https://www.chargebee.com/docs/2.0/mobile-playstore-connect.html) with your Google Play Store account using your [service account credentials JSON](https://www.chargebee.com/docs/2.0/mobile-playstore-connect.html#generate-service-account-credentials-json).
405
+ * It is strongly recommended to use this endpoint to import historical in-app subscriptions only.
406
+ * It is recommended to pass only the latest purchase &#x60;token&#x60;. If any other purchase &#x60;token&#x60; is passed instead of the latest one, there is a possibility of returning incorrect transaction details. If an expired purchase &#x60;token&#x60; is passed, then it returns an error.
407
+ * The Google purchase token is [valid for 60 days](https://developer.android.com/google/play/billing/subscriptions#lifecycle) from the subscription purchase date. After the &#x60;token&#x60; expires, an API request to Google Developers API returns an error.
408
+
409
+ Chargebee validates the purchase &#x60;token&#x60; with Google Play Store and does the following once validation succeeds:
410
+
411
+ #### Subscriptions {#ir_google_play_store_pcv2}
412
+
413
+ * A [subscription](/docs/api/subscriptions) is imported for every unique purchase token if it is not linked to an existing purchase &#x60;token&#x60;( &#x60;linkedPurchaseToken&#x60; field in &#x60;SubscriptionsV2.get&#x60; API Response).
414
+
415
+ * Each subscription imported has the following attributes set:
416
+
417
+ * &#x60;id&#x60; set to a unique identifier generated by Chargebee and mapped to the &#x60;token&#x60; and &#x60;latestOrderId&#x60; of the &#x60;SubscriptionPurchaseV2&#x60; object from Google response.
418
+
419
+ * &#x60;start_date&#x60; set to the earliest &#x60;SubscriptionPurchaseV2.startTime&#x60;.
420
+
421
+ * &#x60;current_term_start&#x60; set to latest &#x60;SubscriptionPurchaseV2.startTime&#x60;.
422
+
423
+ * &#x60;current_term_end&#x60; set to &#x60;expiryTime&#x60; of the same &#x60;SubscriptionPurchaseV2&#x60; element with the latest purchase.
424
+
425
+ * &#x60;item_price_id&#x60; set to the concatenation of &#x60;product[id]&#x60; and &#x60;priceCurrencyCode&#x60; from Google.
426
+
427
+ * &#x60;status&#x60; set to &#x60;in_trial&#x60; if the free trial configuration is enabled in Google and the [monetization.subscriptions.basePlans.offers.State](https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions.basePlans.offers#State) is &#x60;Active&#x60; with a [SubscriptionOfferPhase.duration](https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions.basePlans.offers#subscriptionofferphase), then consider the subscription is currently in trial. No invoices are created for this subscription.
428
+
429
+ #### Invoices for the subscription
430
+
431
+ Invoices are imported as follows:
432
+
433
+ * An [invoice](/docs/api/invoices &quot;https://apidocs.chargebee.com/docs/api/invoices?prod_cat_ver&#x3D;2&quot;) is imported to Chargebee for every new subscription and renewal of an existing subscription using &#x60;latestOrderId&#x60;.
434
+
435
+ * Each imported invoice has the &#x60;subscription_id&#x60; set to a unique identifier generated by Chargebee and mapped to the &#x60;token&#x60; and &#x60;latestOrderId&#x60;.
436
+
437
+ #### Transactions for the invoices
438
+
439
+ A [transaction](/docs/api/transactions) is imported for each invoice with the following details:
440
+
441
+ * &#x60;transaction.reference_number&#x60; is set to the &#x60;latestOrderId&#x60;.
442
+
443
+ * &#x60;transaction.payment_method&#x60; is set to &#x60;play_store&#x60;.
444
+
445
+ Path Parameter {#path_param}
446
+ ----------------------------
447
+
448
+ &#x60;{in_app_subscription_app_id}&#x60;: The handle created by Chargebee for your Apple App Store or Google Play Store app. It can be obtained from the Chargebee web app.
449
+
450
+ The following are instructions to obtain the value of the path parameter for the Apple App Store and Google Play Store.
451
+
452
+ * **Apple App Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, 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](https://www.chargebee.com/docs/1.0/mobile-app-store-product-iap.html#connection-keys_app-id).
453
+ * **Google Play Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, click **Set up notifications** within the **Sync Overview** page of the web app and use the value of generated **App ID** for this parameter. See detailed steps [here](https://www.chargebee.com/docs/1.0/mobile-playstore-notifications.html#app-id).
454
+
455
+
456
+
457
+
458
+ */
459
+
460
+ in_app_subscriptions:InAppSubscription[];
25
461
  }
26
462
  export interface ImportReceiptInputParam {
463
+
464
+ /**
465
+ * @description **Apple App Store** : The Base64 encoded [App Store in-app purchase receipt](https://developer.apple.com/documentation/storekit/original_api_for_in-app_purchase/validating_receipts_with_the_app_store?language&#x3D;objc#overview) taken from the Apple device after successful creation of the in-app purchase subscription.
466
+
467
+ **Google Play Store** : The purchase &#x60;token&#x60; taken from the Android device after the successful creation of an in-app purchase subscription.
468
+
469
+ */
470
+
27
471
  receipt:string;
472
+
473
+ /**
474
+ * @description Parameters for product
475
+
476
+ */
477
+
28
478
  product?:{currency_code:string};
479
+
480
+ /**
481
+ * @description Parameters for customer
482
+
483
+ */
484
+
29
485
  customer?:{email?:string,id?:string};
30
486
  }
31
- export interface ImportSubscriptionResponse {
32
- in_app_subscription:InAppSubscription;
487
+ export interface ImportSubscriptionResponse {
488
+ /**
489
+ * @description 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](https://apidocs.chargebee.com/docs/api/in_app_subscriptions#import_receipt) API.
490
+
491
+ With this API, you can import subscriptions and corresponding invoices for historic In-App purchases. The API returns the [in-app-subscriptions object](https://apidocs.chargebee.com/docs/api/in_app_subscriptions#in_app_subscription_attributes) once the historic subscription is successfully imported into Chargebee.
492
+ **Note**: Subscription cannot be imported from Google Play Store without a receipt or token. Therefore; Chargebee does not allow you to use this API for Google Play Store.
493
+
494
+ ### Apple App Store
495
+
496
+ 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.
497
+ **Important**
498
+
499
+ * [Integrate Chargebee](https://www.chargebee.com/docs/mobile-app-store-connect.html#connnect-with-your-chargebee-site) with your Apple App Store account using your shared secret from Apple.
500
+
501
+ * It is strongly recommended to use this endpoint to create a historic In-App subscription only.
502
+
503
+ * You must import App Store products using Chargebee&#x27;s user interface before importing receipts using this API.
504
+
505
+ Chargebee validates the application ID with Apple App Store and does the following once validation succeeds:
506
+
507
+ #### Subscription
508
+
509
+ 1. Import the subscription from the &#x60;latest_receipt_info&#x60; array from Apple and a new subscription is imported for the item-price.
510
+ **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.
511
+
512
+ 2. Each subscription imported has the following attribute set:
513
+
514
+ * &#x60;id&#x60; set to &#x60;subscription[id]&#x60; . This &#x60;subscription[id]&#x60; is &#x60;original_transaction_id&#x60; in the receipts.
515
+
516
+ * &#x60;start_date&#x60; set to &#x60;subscription[start_date]&#x60;. You need to provide this information from the oldest &#x60;Latest_receipt_info.purchase_date_ms&#x60;.
517
+
518
+ * &#x60;term_start&#x60; set to &#x60;subscription[term_start]&#x60;. You need to provide this information from the oldest &#x60;Latest_receipt_info.purchase_date_ms)&#x60;.
519
+
520
+ * &#x60;term_end&#x60; set to &#x60;subscription[term_end]&#x60;. You need to provide this information from the oldest &#x60;Latest_receipt_info.expires_date_ms&#x60;.
521
+
522
+ * &#x60;item_price_id&#x60; set to &#x60;subscription[product_id] + subscription[currency_code].&#x60; You need to provide this information from the &#x60;Latest_receipt_info.product_id&#x60;.
523
+
524
+ * Chargebee records the subscription in a **Trial** state if the &#x60;is_trial_period&#x60; is &#x60;true&#x60;.
525
+
526
+ * Chargebee records the subscription in a **Canceled** state if the &#x60;term_end&#x60; is less than the &#x60;System.currentTime()&#x60;.
527
+
528
+ #### Invoice for the subscription
529
+
530
+ 1. The payment is recorded against the subscription invoice.
531
+
532
+ * Imported invoice has the &#x60;subscription_id&#x60; set to &#x60;original_transaction_id&#x60;.
533
+
534
+ **Transactions for the invoice**
535
+
536
+ 1. The associated transaction is updated with the following details:
537
+
538
+ * The &#x60;transaction.reference_number&#x60; is set to the &#x60;transaction_id&#x60; of the payment.
539
+
540
+ * The &#x60;transaction.payment_method&#x60; is set to &#x60;apple_store&#x60;.
541
+
542
+ #### Path Parameter
543
+
544
+ in_app_subscription_app_id
545
+ required, string
546
+
547
+ The handle created by Chargebee for your App Store app. It can be obtained from within the Chargebee web app.
548
+
549
+ To obtain the value of &#x60;in_app_subscription_app_id &#x60;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](https://www.chargebee.com/docs/mobile-app-store-product-iap.html#connection-keys_app-id).
550
+
551
+ */
552
+
553
+ in_app_subscription:InAppSubscription;
33
554
  }
34
555
  export interface ImportSubscriptionInputParam {
556
+
557
+ /**
558
+ * @description Parameters for subscription
559
+
560
+ */
561
+
35
562
  subscription?:{currency_code:string,id:string,is_trial?:boolean,product_id:string,started_at:number,term_end:number,term_start:number,transaction_id:string};
563
+
564
+ /**
565
+ * @description Parameters for customer
566
+
567
+ */
568
+
36
569
  customer?:{email?:string,id?:string};
37
570
  }
38
- export interface ProcessReceiptResponse {
39
- in_app_subscription:InAppSubscription;
571
+ export interface ProcessReceiptResponse {
572
+ /**
573
+ * @description Verifies an in-app purchase made by your customer and creates a subscription in Chargebee.
574
+ **Tip**
575
+
576
+ The recommended approach is to call this endpoint from the client-side app directly. However, if you are using this API to replace an existing direct integration with Apple or Google, then you may choose to call this API from the server-side.
577
+ **Note:**
578
+
579
+ if App Store or Play Store products have not been imported to Chargebee and this API is invoked, Chargebee will automatically create plans that correspond to the store product IDs. However, if historical subscriptions are to be imported using the [import receipt](https://apidocs.chargebee.com/docs/api/in_app_subscriptions#import_receipt) API, importing products is mandatory. [Learn more](https://www.chargebee.com/docs/mobile_subscriptions.html).
580
+
581
+ Apple App Store {#app_store}
582
+ ----------------------------
583
+
584
+ This section provides details of the Process Purchase Command operation when performed for the Apple App Store. This API processes only the latest in-app transaction on the receipt. Sync historical subscriptions into Chargebee using [bulk import](https://www.chargebee.com/docs/2.0/mobile-app-store-product-iap.html#import-in-app-purchase-receipts) of In-App Purchase receipts.
585
+ **Important**
586
+
587
+ * [Integrate Chargebee](https://www.chargebee.com/docs/mobile-app-store-connect.html#connnect-with-your-chargebee-site) with your Apple App Store account using your shared secret from Apple.
588
+ * It is strongly recommended to use this endpoint to notify Chargebee of **new** purchases only.
589
+ * For updates to existing subscriptions, we recommend that you configure Apple App Store to send server notifications to Chargebee.
590
+
591
+ Chargebee validates the &#x60;receipt&#x60; with Apple App Store and does the following once validation succeeds:
592
+
593
+ 1. Look for [item_family.id](/docs/api/item_families?prod_cat_ver&#x3D;2#item_family_id) that matches the value Apple-App-Store, and create such a product family if not found.
594
+ 2. Look for [item.id](/docs/api/items?prod_cat_ver&#x3D;2#item_id) that matches &#x60;product[id]&#x60; and if not found, create such a plan-item under the item family described in the previous step.
595
+ 3. Look for [item_price.id](/docs/api/item_prices?prod_cat_ver&#x3D;2#item_price_id) that matches the concatenation of &#x60;product[id]&#x60; and &#x60;product[currency_code]&#x60;, and if not found, create such an item price under the item described in the previous step.
596
+ 4. Create/update a subscription:
597
+ * If the receipt is for a new purchase, a new subscription is created for the plan-item price described in the previous step. The subscription has the following details:
598
+ * &#x60;id&#x60; set to [original_transaction_id](https://developer.apple.com/documentation/appstorereceipts/original_transaction_id?language&#x3D;objc)
599
+ * &#x60;start_date&#x60; set to [responseBody.Latest_receipt_info.purchase_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc)
600
+ * &#x60;current_term_end&#x60; set to &#x60;responseBody.Latest_receipt_info.expires_date_ms&#x60;
601
+ * Instead, if the receipt belongs to an existing subscription in Chargebee, it is updated to reflect the current state of the subscription at Apple.
602
+ 5. The payment is recorded against the subscription invoice. The associated transaction is updated with the following details:
603
+ * The [transaction.reference_number](/docs/api/transactions?prod_cat_ver&#x3D;2#transaction_reference_number) is set to the [transaction_id](https://developer.apple.com/documentation/appstorereceipts/transaction_id?language&#x3D;objc) of the payment.
604
+ * The [transaction.payment_method](/docs/api/transactions#transaction_payment_method) is set to &#x60;apple_pay&#x60;.
605
+
606
+ Google Play Store {#app_store}
607
+ ------------------------------
608
+
609
+ This section provides details of the Process Purchase Command operation when performed for the Google Play Store. This API processes only the latest in-app transaction using the purchase token.
610
+ **Important**
611
+
612
+ * [Integrate Chargebee](https://www.chargebee.com/docs/2.0/mobile-playstore-connect.html#chargebee-configuration) with your Google Play Store account using the service account credentials JSON.
613
+ * It is strongly recommended to use this endpoint to notify Chargebee of **new** purchases only.
614
+ * For updates to existing subscriptions, we recommend that you configure Chargebee to receive Google&#x27;s server notifications through pub/sub topic. [Learn more](https://developer.android.com/google/play/billing/getting-ready#setup-pubsub).
615
+
616
+ Chargebee validates the purchase **token** with Google Play Store and does the following once validation succeeds:
617
+
618
+ 1. Look for [item_family.id](/docs/api/item_families?prod_cat_ver&#x3D;2#item_family_id) that matches the value &#x60;Google-Play-Store&#x60;, and create such a product family if not found.
619
+ 2. Look for [item.id](/docs/api/items?prod_cat_ver&#x3D;2#item_id) that matches &#x60;product[id]&#x60; and if not found, create such a [plan-item](/docs/api/items?prod_cat_ver&#x3D;2#item_type) under the item family described in the previous step.
620
+ 3. Look for [item_price.id](/docs/api/item_prices?prod_cat_ver&#x3D;2#item_price_id) that matches the concatenation of &#x60;product[id]&#x60; and [priceCurrencyCode](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions?hl&#x3D;en#SubscriptionPurchase.FIELDS.price_currency_code), and if not found, create such an item price under the item described in the previous step.
621
+ 4. Create/update a subscription:
622
+ * If this token is for a new purchase, a new subscription is created for the plan-item price described in the previous step. The subscription has the following details:
623
+ * &#x60;id&#x60; set to unique identifier generated by Chargebee and mapped to **token** of the [SubscriptionPurchase](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions?hl&#x3D;en) object from Google response.
624
+ * &#x60;start_date&#x60; set to &#x60;SubscriptionPurchase.startTimeMillis&#x60;.
625
+ * &#x60;current_term_end&#x60; set to &#x60;SubscriptionPurchase.expiryTimeMillis&#x60;.
626
+ * Instead, if the token belongs to an existing subscription in Chargebee, it is updated to reflect the current state of the subscription at Google.
627
+ 5. The payment is recorded against the subscription invoice. The associated transaction is updated with the following details:
628
+ * The [transaction.reference_number](/docs/api/transactions?prod_cat_ver&#x3D;2#transaction_reference_number) is set to the [orderId](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions?hl&#x3D;en#SubscriptionPurchase.FIELDS.order_id) of the payment.
629
+ * The [transaction.payment_method](/docs/api/transactions#transaction_payment_method) is set to &#x60;play_store&#x60;.
630
+
631
+ Path Parameter {#path_param_pcv2}
632
+ ---------------------------------
633
+
634
+ &#x60;{in_app_subscription_app_id}&#x60;: The handle created by Chargebee for your Apple App Store or Google Play Store app. It can be obtained from the Chargebee web app.
635
+
636
+ The following are instructions to obtain the value of the path parameter for the Apple App Store and Google Play Store.
637
+
638
+ * **Apple App Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, 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](https://www.chargebee.com/docs/1.0/mobile-app-store-product-iap.html#resource-id).
639
+ * **Google Play Store** : To obtain the value for &#x60;{in_app_subscription_app_id}&#x60;, click **Set up notifications** within the **Sync Overview** page of the web app and use the value of generated **App ID** for this parameter. See detailed steps [here](https://www.chargebee.com/docs/1.0/mobile-playstore-notifications.html#app-id).
640
+
641
+
642
+
643
+
644
+ */
645
+
646
+ in_app_subscription:InAppSubscription;
40
647
  }
41
648
  export interface ProcessReceiptInputParam {
649
+
650
+ /**
651
+ * @description **Apple App Store** : The Base64 encoded [App Store in-app purchase receipt](https://developer.apple.com/documentation/storekit/original_api_for_in-app_purchase/validating_receipts_with_the_app_store?language&#x3D;objc#overview) taken from the Apple device after successful creation of the in-app purchase subscription.
652
+
653
+ **Google Play Store** : The purchase &#x60;token&#x60; taken from the Android device after the successful creation of an in-app purchase subscription.
654
+
655
+ */
656
+
42
657
  receipt:string;
658
+
659
+ /**
660
+ * @description Parameters for product
661
+
662
+ */
663
+
43
664
  product?:{currency_code:string,id:string,name?:string,period?:string,period_unit?:string,price:number,price_in_decimal?:string};
665
+
666
+ /**
667
+ * @description Parameters for customer
668
+
669
+ */
670
+
44
671
  customer?:{email?:string,first_name?:string,id?:string,last_name?:string};
45
672
  }
46
673