chargebee 2.41.0 → 3.0.0-beta.2

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 (118) hide show
  1. package/CHANGELOG.md +11 -15
  2. package/LICENSE +1 -1
  3. package/README.md +90 -170
  4. package/cjs/RequestWrapper.js +84 -0
  5. package/cjs/asyncApiSupport.js +39 -0
  6. package/cjs/chargebee.cjs.js +13 -0
  7. package/cjs/chargebee.cjs.worker.js +9 -0
  8. package/cjs/chargebeeError.js +17 -0
  9. package/cjs/coreCommon.js +72 -0
  10. package/cjs/createChargebee.js +92 -0
  11. package/cjs/environment.js +18 -0
  12. package/cjs/filter.js +1 -0
  13. package/cjs/net/ClientInterface.js +40 -0
  14. package/cjs/net/FetchClient.js +86 -0
  15. package/cjs/net/NodeClient.js +61 -0
  16. package/cjs/package.json +1 -0
  17. package/cjs/resources/api_endpoints.js +1086 -0
  18. package/cjs/util.js +218 -0
  19. package/esm/RequestWrapper.js +80 -0
  20. package/esm/asyncApiSupport.js +35 -0
  21. package/esm/chargebee.esm.js +9 -0
  22. package/esm/chargebee.esm.worker.js +5 -0
  23. package/esm/chargebeeError.js +13 -0
  24. package/esm/coreCommon.js +67 -0
  25. package/esm/createChargebee.js +88 -0
  26. package/esm/environment.js +15 -0
  27. package/esm/filter.js +1 -0
  28. package/esm/net/ClientInterface.js +35 -0
  29. package/esm/net/FetchClient.js +81 -0
  30. package/esm/net/NodeClient.js +56 -0
  31. package/esm/package.json +1 -0
  32. package/esm/resources/api_endpoints.js +1083 -0
  33. package/esm/util.js +202 -0
  34. package/package.json +69 -38
  35. package/types/core.d.ts +558 -89
  36. package/types/index.d.ts +90 -55
  37. package/types/resources/Address.d.ts +57 -272
  38. package/types/resources/AdvanceInvoiceSchedule.d.ts +21 -94
  39. package/types/resources/AttachedItem.d.ts +91 -329
  40. package/types/resources/Attribute.d.ts +5 -5
  41. package/types/resources/BusinessEntity.d.ts +49 -69
  42. package/types/resources/BusinessEntityTransfer.d.ts +11 -17
  43. package/types/resources/Card.d.ts +146 -424
  44. package/types/resources/Comment.d.ts +72 -189
  45. package/types/resources/Contact.d.ts +12 -64
  46. package/types/resources/ContractTerm.d.ts +15 -96
  47. package/types/resources/Coupon.d.ts +282 -758
  48. package/types/resources/CouponCode.d.ts +56 -52
  49. package/types/resources/CouponSet.d.ts +92 -234
  50. package/types/resources/CreditNote.d.ts +588 -1758
  51. package/types/resources/CreditNoteEstimate.d.ts +131 -157
  52. package/types/resources/Currency.d.ts +75 -62
  53. package/types/resources/Customer.d.ts +892 -835
  54. package/types/resources/CustomerEntitlement.d.ts +24 -35
  55. package/types/resources/DifferentialPrice.d.ts +116 -314
  56. package/types/resources/Discount.d.ts +20 -125
  57. package/types/resources/Download.d.ts +6 -22
  58. package/types/resources/Entitlement.d.ts +51 -160
  59. package/types/resources/EntitlementOverride.d.ts +58 -139
  60. package/types/resources/Estimate.d.ts +1178 -527
  61. package/types/resources/Event.d.ts +67 -178
  62. package/types/resources/Export.d.ts +563 -723
  63. package/types/resources/Feature.d.ts +117 -433
  64. package/types/resources/GatewayErrorDetail.d.ts +16 -72
  65. package/types/resources/Gift.d.ts +265 -432
  66. package/types/resources/Hierarchy.d.ts +8 -36
  67. package/types/resources/HostedPage.d.ts +1017 -1153
  68. package/types/resources/ImpactedItem.d.ts +13 -50
  69. package/types/resources/ImpactedItemPrice.d.ts +13 -15
  70. package/types/resources/ImpactedSubscription.d.ts +13 -45
  71. package/types/resources/InAppSubscription.d.ts +93 -389
  72. package/types/resources/Installment.d.ts +35 -110
  73. package/types/resources/InstallmentConfig.d.ts +54 -155
  74. package/types/resources/InstallmentDetail.d.ts +19 -27
  75. package/types/resources/Invoice.d.ts +1574 -3157
  76. package/types/resources/InvoiceEstimate.d.ts +131 -161
  77. package/types/resources/Item.d.ts +133 -611
  78. package/types/resources/ItemEntitlement.d.ts +78 -215
  79. package/types/resources/ItemFamily.d.ts +69 -178
  80. package/types/resources/ItemPrice.d.ts +291 -1203
  81. package/types/resources/Metadata.d.ts +3 -5
  82. package/types/resources/Order.d.ts +538 -1471
  83. package/types/resources/PaymentIntent.d.ts +163 -347
  84. package/types/resources/PaymentReferenceNumber.d.ts +7 -29
  85. package/types/resources/PaymentSource.d.ts +476 -1272
  86. package/types/resources/PaymentVoucher.d.ts +87 -306
  87. package/types/resources/PortalSession.d.ts +71 -207
  88. package/types/resources/PriceVariant.d.ts +91 -279
  89. package/types/resources/PricingPageSession.d.ts +92 -41
  90. package/types/resources/PromotionalCredit.d.ts +90 -346
  91. package/types/resources/Purchase.d.ts +185 -315
  92. package/types/resources/Quote.d.ts +1406 -887
  93. package/types/resources/QuoteLineGroup.d.ts +125 -452
  94. package/types/resources/QuotedCharge.d.ts +45 -274
  95. package/types/resources/QuotedSubscription.d.ts +100 -488
  96. package/types/resources/Ramp.d.ts +230 -747
  97. package/types/resources/ResourceMigration.d.ts +25 -80
  98. package/types/resources/SiteMigrationDetail.d.ts +34 -112
  99. package/types/resources/Subscription.d.ts +2390 -4336
  100. package/types/resources/SubscriptionEntitlement.d.ts +59 -160
  101. package/types/resources/SubscriptionEstimate.d.ts +51 -75
  102. package/types/resources/TaxWithheld.d.ts +15 -40
  103. package/types/resources/ThirdPartyPaymentMethod.d.ts +7 -29
  104. package/types/resources/TimeMachine.d.ts +43 -97
  105. package/types/resources/Token.d.ts +15 -85
  106. package/types/resources/Transaction.d.ts +276 -911
  107. package/types/resources/UnbilledCharge.d.ts +189 -164
  108. package/types/resources/Usage.d.ts +89 -279
  109. package/types/resources/VirtualBankAccount.d.ts +103 -255
  110. package/types/resources/filter.d.ts +52 -0
  111. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -81
  112. package/.github/ISSUE_TEMPLATE/config.yml +0 -6
  113. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -34
  114. package/.github/PULL_REQUEST_TEMPLATE.md +0 -8
  115. package/lib/chargebee.js +0 -512
  116. package/lib/resources/api_endpoints.js +0 -2935
  117. package/types/resources/NonSubscription.d.ts +0 -30
  118. package/types/resources/Session.d.ts +0 -41
@@ -1,412 +1,116 @@
1
1
  ///<reference path='./../core.d.ts'/>
2
+ ///<reference path='./../index.d.ts'/>
3
+
2
4
  declare module 'chargebee' {
3
5
  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
-
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
-
17
- customer_id?:string;
18
-
19
- /**
20
- * @description The &#x60;id&#x60; of the plan-item price of the subscription.
21
-
22
- */
23
-
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
-
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
-
38
- invoice_id?:string;
6
+ app_id: string;
7
+ subscription_id: string;
8
+ customer_id?: string;
9
+ plan_id?: string;
10
+ store_status?: 'in_trial' | 'active' | 'cancelled' | 'paused';
11
+ invoice_id?: string;
39
12
  }
40
- export namespace InAppSubscription {
41
- export class InAppSubscriptionResource {
42
- /**
43
- * @description Verifies an in-app purchase made by your customer and creates a subscription in Chargebee.
44
- **Tip**
45
-
46
- 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.
47
- **Note:**
48
-
49
- 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).
50
-
51
- Apple App Store {#app_store}
52
- ----------------------------
53
-
54
- 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.
55
- **Important**
56
-
57
- * [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.
58
- * It is strongly recommended to use this endpoint to notify Chargebee of **new** purchases only.
59
- * For updates to existing subscriptions, we recommend that you configure Apple App Store to send server notifications to Chargebee.
60
-
61
- Chargebee validates the &#x60;receipt&#x60; with Apple App Store and does the following once validation succeeds:
62
-
63
- 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.
64
- 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.
65
- 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.
66
- 4. Create/update a subscription:
67
- * 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:
68
- * &#x60;id&#x60; set to [original_transaction_id](https://developer.apple.com/documentation/appstorereceipts/original_transaction_id?language&#x3D;objc)
69
- * &#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)
70
- * &#x60;current_term_end&#x60; set to &#x60;responseBody.Latest_receipt_info.expires_date_ms&#x60;
71
- * Instead, if the receipt belongs to an existing subscription in Chargebee, it is updated to reflect the current state of the subscription at Apple.
72
- 5. The payment is recorded against the subscription invoice. The associated transaction is updated with the following details:
73
- * 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.
74
- * The [transaction.payment_method](/docs/api/transactions#transaction_payment_method) is set to &#x60;apple_pay&#x60;.
75
-
76
- Google Play Store {#app_store}
77
- ------------------------------
78
-
79
- 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.
80
- **Important**
81
-
82
- * [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.
83
- * It is strongly recommended to use this endpoint to notify Chargebee of **new** purchases only.
84
- * 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).
85
-
86
- Chargebee validates the purchase **token** with Google Play Store and does the following once validation succeeds:
87
-
88
- 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.
89
- 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.
90
- 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.
91
- 4. Create/update a subscription:
92
- * 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:
93
- * &#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.
94
- * &#x60;start_date&#x60; set to &#x60;SubscriptionPurchase.startTimeMillis&#x60;.
95
- * &#x60;current_term_end&#x60; set to &#x60;SubscriptionPurchase.expiryTimeMillis&#x60;.
96
- * Instead, if the token belongs to an existing subscription in Chargebee, it is updated to reflect the current state of the subscription at Google.
97
- 5. The payment is recorded against the subscription invoice. The associated transaction is updated with the following details:
98
- * 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.
99
- * The [transaction.payment_method](/docs/api/transactions#transaction_payment_method) is set to &#x60;play_store&#x60;.
100
-
101
- Path Parameter {#path_param_pcv2}
102
- ---------------------------------
103
-
104
- &#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.
105
-
106
- The following are instructions to obtain the value of the path parameter for the Apple App Store and Google Play Store.
107
-
108
- * **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).
109
- * **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).
110
-
111
-
112
-
113
-
114
- */
115
-
116
- process_receipt(in_app_subscription_app_id:string, input:ProcessReceiptInputParam):ChargebeeRequest<ProcessReceiptResponse>;
117
-
118
- /**
119
- * @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.
120
- **Tip**
121
- 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.
122
-
123
- 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.
124
- **Note** : This API verifies receipt or token through Apple or Google and then processes them via Chargebee. For bulk imports, limit API calls to **6** per minute (**10** seconds apart) to ensure successful subscription imports.
125
-
126
- Apple App Store {#app_store}
127
- ----------------------------
128
-
129
- 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.
130
- **Important**
131
-
132
- * [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.
133
- * It is strongly recommended to use this endpoint to import historical in-app subscriptions only.
134
- * 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.
135
-
136
- Chargebee validates the &#x60;receipt&#x60; with Apple App Store and does the following once validation succeeds:
137
-
138
- #### Subscriptions {#ir_apple_app_store_pcv2}
139
-
140
- [Subscriptions](/docs/api/subscriptions) are imported as follows:
141
-
142
- 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.
143
- **Note** : This is not done for &#x60;original_transaction_id&#x60;s for which a subscription already exists in Chargebee.
144
- 2. Each subscription imported has the following attributes set:
145
- * &#x60;id&#x60; set to &#x60;original_transaction_id&#x60;.
146
- * &#x60;start_date&#x60; set to the earliest [purchase_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc).
147
- * &#x60;current_term_start&#x60; set to latest [purchase_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language&#x3D;objc).
148
- * &#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;.
149
- * &#x60;item_price_id&#x60; set to &#x60;product_id&#x60;.
150
- * &#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.
151
-
152
- #### Invoices for the subscription
153
-
154
- [Invoices](/docs/api/invoices) are imported as follows:
155
-
156
- 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;.
157
- 2. Each imported invoice has the &#x60;subscription_id&#x60; set to &#x60;original_transaction_id&#x60;.
158
-
159
- #### Transactions for the invoices
160
-
161
- A [transaction](/docs/api/transactions) is imported for each invoice with the following details:
162
-
163
- 1. &#x60;reference_number&#x60; set to the &#x60;transaction_id&#x60;.
164
- 2. &#x60;payment_method&#x60; set to &#x60;apple_store&#x60;.
165
-
166
-
167
-
168
- Google Play Store {#app_store}
169
- ------------------------------
170
-
171
- 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.
172
- **Important**
173
-
174
- * [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).
175
- * It is strongly recommended to use this endpoint to import historical in-app subscriptions only.
176
- * 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.
177
- * 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.
178
-
179
- Chargebee validates the purchase &#x60;token&#x60; with Google Play Store and does the following once validation succeeds:
180
-
181
- #### Subscriptions {#ir_google_play_store_pcv2}
182
-
183
- * 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).
184
-
185
- * Each subscription imported has the following attributes set:
186
-
187
- * &#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.
188
-
189
- * &#x60;start_date&#x60; set to the earliest &#x60;SubscriptionPurchaseV2.startTime&#x60;.
190
-
191
- * &#x60;current_term_start&#x60; set to latest &#x60;SubscriptionPurchaseV2.startTime&#x60;.
192
-
193
- * &#x60;current_term_end&#x60; set to &#x60;expiryTime&#x60; of the same &#x60;SubscriptionPurchaseV2&#x60; element with the latest purchase.
194
-
195
- * &#x60;item_price_id&#x60; set to the concatenation of &#x60;product[id]&#x60; and &#x60;priceCurrencyCode&#x60; from Google.
196
-
197
- * &#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.
198
-
199
- #### Invoices for the subscription
200
-
201
- Invoices are imported as follows:
202
-
203
- * 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;.
204
-
205
- * 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;.
206
-
207
- #### Transactions for the invoices
208
-
209
- A [transaction](/docs/api/transactions) is imported for each invoice with the following details:
210
-
211
- * &#x60;transaction.reference_number&#x60; is set to the &#x60;latestOrderId&#x60;.
212
13
 
213
- * &#x60;transaction.payment_method&#x60; is set to &#x60;play_store&#x60;.
214
-
215
- Path Parameter {#path_param}
216
- ----------------------------
217
-
218
- &#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.
219
-
220
- The following are instructions to obtain the value of the path parameter for the Apple App Store and Google Play Store.
221
-
222
- * **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).
223
- * **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).
224
-
225
-
226
-
227
-
228
- */
229
-
230
- import_receipt(in_app_subscription_app_id:string, input:ImportReceiptInputParam):ChargebeeRequest<ImportReceiptResponse>;
231
-
232
- /**
233
- * @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.
234
-
235
- 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.
236
- **Note** :
237
-
238
- * 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.
239
- * Enable V1 notifications in the Apple App Store for subscriptions created without receipts. Chargebee depends on receipt data to update subscription statuses. Apple&#x27;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++](https://apidocs.chargebee.com/docs/api/in_app_purchase_events?prod_cat_ver&#x3D;2#app_store_notifications) and [++notification URL configuration++](https://www.chargebee.com/docs/mobile-app-store-product-iap.html#connection-keys_notification-url).
240
-
241
- ### Apple App Store
242
-
243
- 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.
244
- **Important**
245
-
246
- * [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.
247
-
248
- * It is strongly recommended to use this endpoint to create a historic In-App subscription only.
249
-
250
- * You must import App Store products using Chargebee&#x27;s user interface before importing receipts using this API.
251
-
252
- Chargebee validates the application ID with Apple App Store and does the following once validation succeeds:
253
-
254
- #### Subscription
255
-
256
- 1. Import the subscription from the &#x60;latest_receipt_info&#x60; array from Apple and a new subscription is imported for the item-price.
257
- **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.
258
-
259
- 2. Each subscription imported has the following attribute set:
260
-
261
- * &#x60;id&#x60; set to &#x60;subscription[id]&#x60; . This &#x60;subscription[id]&#x60; is &#x60;original_transaction_id&#x60; in the receipts.
262
-
263
- * &#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;.
264
-
265
- * &#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;.
266
-
267
- * &#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;.
268
-
269
- * &#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;.
270
-
271
- * Chargebee records the subscription in a **Trial** state if the &#x60;is_trial_period&#x60; is &#x60;true&#x60;.
272
-
273
- * Chargebee records the subscription in a **Canceled** state if the &#x60;term_end&#x60; is less than the &#x60;System.currentTime()&#x60;.
274
-
275
- #### Invoice for the subscription
276
-
277
- 1. The payment is recorded against the subscription invoice.
278
-
279
- * Imported invoice has the &#x60;subscription_id&#x60; set to &#x60;original_transaction_id&#x60;.
280
-
281
- **Transactions for the invoice**
282
-
283
- 1. The associated transaction is updated with the following details:
284
-
285
- * The &#x60;transaction.reference_number&#x60; is set to the &#x60;transaction_id&#x60; of the payment.
286
-
287
- * The &#x60;transaction.payment_method&#x60; is set to &#x60;apple_store&#x60;.
288
-
289
- #### Path Parameter
290
-
291
- in_app_subscription_app_id
292
- required, string
293
-
294
- The handle created by Chargebee for your App Store app. It can be obtained from within the Chargebee web app.
295
-
296
- 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).
297
-
298
- */
299
-
300
- import_subscription(in_app_subscription_app_id:string, input?:ImportSubscriptionInputParam):ChargebeeRequest<ImportSubscriptionResponse>;
301
-
302
- /**
303
- * @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.
14
+ export namespace InAppSubscription {
15
+ export class InAppSubscriptionResource {
16
+ processReceipt(
17
+ in_app_subscription_app_id: string,
18
+ input: ProcessReceiptInputParam,
19
+ headers?: ChargebeeRequestHeader,
20
+ ): Promise<ChargebeeResponse<ProcessReceiptResponse>>;
21
+
22
+ importReceipt(
23
+ in_app_subscription_app_id: string,
24
+ input: ImportReceiptInputParam,
25
+ headers?: ChargebeeRequestHeader,
26
+ ): Promise<ChargebeeResponse<ImportReceiptResponse>>;
27
+
28
+ importSubscription(
29
+ in_app_subscription_app_id: string,
30
+ input: ImportSubscriptionInputParam,
31
+ headers?: ChargebeeRequestHeader,
32
+ ): Promise<ChargebeeResponse<ImportSubscriptionResponse>>;
33
+
34
+ retrieveStoreSubs(
35
+ in_app_subscription_app_id: string,
36
+ input: RetrieveStoreSubsInputParam,
37
+ headers?: ChargebeeRequestHeader,
38
+ ): Promise<ChargebeeResponse<RetrieveStoreSubsResponse>>;
39
+ }
304
40
 
305
- #### Path Parameter
41
+ export interface ProcessReceiptResponse {
42
+ in_app_subscription: InAppSubscription;
43
+ }
306
44
 
307
- in_app_subscription_app_id
308
- required, string
45
+ export interface ImportReceiptResponse {
46
+ in_app_subscriptions: InAppSubscription[];
47
+ }
309
48
 
310
- 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.
49
+ export interface ImportSubscriptionResponse {
50
+ in_app_subscription: InAppSubscription;
51
+ }
311
52
 
312
- The following are instructions to obtain the value of the path parameter for the Apple App Store and Google Play Store.
53
+ export interface RetrieveStoreSubsResponse {
54
+ in_app_subscriptions: InAppSubscription[];
55
+ }
313
56
 
314
- * **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).
315
- * **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).
57
+ // REQUEST PARAMS
58
+ //---------------
316
59
 
317
- */
318
-
319
- retrieve_store_subs(in_app_subscription_app_id:string, input:RetrieveStoreSubsInputParam):ChargebeeRequest<RetrieveStoreSubsResponse>;
60
+ export interface ProcessReceiptInputParam {
61
+ receipt: string;
62
+ product?: ProductProcessReceiptInputParam;
63
+ customer?: CustomerProcessReceiptInputParam;
320
64
  }
321
- export interface ProcessReceiptResponse {
322
- in_app_subscription:InAppSubscription;
65
+ export interface ImportReceiptInputParam {
66
+ receipt: string;
67
+ product?: ProductImportReceiptInputParam;
68
+ customer?: CustomerImportReceiptInputParam;
323
69
  }
324
- export interface ProcessReceiptInputParam {
325
-
326
- /**
327
- * @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.
328
-
329
- **Google Play Store** : The purchase &#x60;token&#x60; taken from the Android device after the successful creation of an in-app purchase subscription.
330
-
331
- */
332
-
333
- receipt:string;
334
-
335
- /**
336
- * @description Parameters for product
337
-
338
- */
339
-
340
- product?:{currency_code:string,id:string,name?:string,period?:string,period_unit?:string,price:number,price_in_decimal?:string};
341
-
342
- /**
343
- * @description Parameters for customer
344
-
345
- */
346
-
347
- customer?:{email?:string,first_name?:string,id?:string,last_name?:string};
70
+ export interface ImportSubscriptionInputParam {
71
+ subscription?: SubscriptionImportSubscriptionInputParam;
72
+ customer?: CustomerImportSubscriptionInputParam;
348
73
  }
349
- export interface ImportReceiptResponse {
350
- in_app_subscriptions:InAppSubscription[];
74
+ export interface RetrieveStoreSubsInputParam {
75
+ receipt: string;
351
76
  }
352
- export interface ImportReceiptInputParam {
353
-
354
- /**
355
- * @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.
356
-
357
- **Google Play Store** : The purchase &#x60;token&#x60; taken from the Android device after the successful creation of an in-app purchase subscription.
358
-
359
- */
360
-
361
- receipt:string;
362
-
363
- /**
364
- * @description Parameters for product
365
-
366
- */
367
-
368
- product?:{currency_code:string};
369
-
370
- /**
371
- * @description Parameters for customer
372
-
373
- */
374
-
375
- customer?:{email?:string,id?:string};
77
+ export interface CustomerProcessReceiptInputParam {
78
+ id?: string;
79
+ email?: string;
80
+ first_name?: string;
81
+ last_name?: string;
376
82
  }
377
- export interface ImportSubscriptionResponse {
378
- in_app_subscription:InAppSubscription;
83
+ export interface ProductProcessReceiptInputParam {
84
+ id: string;
85
+ currency_code: string;
86
+ price: number;
87
+ name?: string;
88
+ price_in_decimal?: string;
89
+ period?: string;
90
+ period_unit?: string;
379
91
  }
380
- export interface ImportSubscriptionInputParam {
381
-
382
- /**
383
- * @description Parameters for subscription
384
-
385
- */
386
-
387
- subscription?:{currency_code:string,id:string,is_trial?:boolean,product_id:string,started_at:number,term_end:number,term_start:number,transaction_id:string};
388
-
389
- /**
390
- * @description Parameters for customer
391
92
 
392
- */
393
-
394
- customer?:{email?:string,id?:string};
93
+ export interface CustomerImportReceiptInputParam {
94
+ id?: string;
95
+ email?: string;
395
96
  }
396
- export interface RetrieveStoreSubsResponse {
397
- in_app_subscriptions:InAppSubscription[];
97
+ export interface ProductImportReceiptInputParam {
98
+ currency_code: string;
398
99
  }
399
- export interface RetrieveStoreSubsInputParam {
400
-
401
- /**
402
- * @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.
403
-
404
- **Google Play Store** : The purchase &#x60;token&#x60; taken from the Android device after the successful creation of an in-app purchase subscription.
405
100
 
406
- */
407
-
408
- receipt:string;
101
+ export interface CustomerImportSubscriptionInputParam {
102
+ id?: string;
103
+ email?: string;
104
+ }
105
+ export interface SubscriptionImportSubscriptionInputParam {
106
+ id: string;
107
+ started_at: number;
108
+ term_start: number;
109
+ term_end: number;
110
+ product_id: string;
111
+ currency_code: string;
112
+ transaction_id: string;
113
+ is_trial?: boolean;
409
114
  }
410
-
411
115
  }
412
- }
116
+ }