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.
- package/CHANGELOG.md +11 -15
- package/LICENSE +1 -1
- package/README.md +90 -170
- package/cjs/RequestWrapper.js +84 -0
- package/cjs/asyncApiSupport.js +39 -0
- package/cjs/chargebee.cjs.js +13 -0
- package/cjs/chargebee.cjs.worker.js +9 -0
- package/cjs/chargebeeError.js +17 -0
- package/cjs/coreCommon.js +72 -0
- package/cjs/createChargebee.js +92 -0
- package/cjs/environment.js +18 -0
- package/cjs/filter.js +1 -0
- package/cjs/net/ClientInterface.js +40 -0
- package/cjs/net/FetchClient.js +86 -0
- package/cjs/net/NodeClient.js +61 -0
- package/cjs/package.json +1 -0
- package/cjs/resources/api_endpoints.js +1086 -0
- package/cjs/util.js +218 -0
- package/esm/RequestWrapper.js +80 -0
- package/esm/asyncApiSupport.js +35 -0
- package/esm/chargebee.esm.js +9 -0
- package/esm/chargebee.esm.worker.js +5 -0
- package/esm/chargebeeError.js +13 -0
- package/esm/coreCommon.js +67 -0
- package/esm/createChargebee.js +88 -0
- package/esm/environment.js +15 -0
- package/esm/filter.js +1 -0
- package/esm/net/ClientInterface.js +35 -0
- package/esm/net/FetchClient.js +81 -0
- package/esm/net/NodeClient.js +56 -0
- package/esm/package.json +1 -0
- package/esm/resources/api_endpoints.js +1083 -0
- package/esm/util.js +202 -0
- package/package.json +69 -38
- package/types/core.d.ts +558 -89
- package/types/index.d.ts +90 -55
- package/types/resources/Address.d.ts +57 -272
- package/types/resources/AdvanceInvoiceSchedule.d.ts +21 -94
- package/types/resources/AttachedItem.d.ts +91 -329
- package/types/resources/Attribute.d.ts +5 -5
- package/types/resources/BusinessEntity.d.ts +49 -69
- package/types/resources/BusinessEntityTransfer.d.ts +11 -17
- package/types/resources/Card.d.ts +146 -424
- package/types/resources/Comment.d.ts +72 -189
- package/types/resources/Contact.d.ts +12 -64
- package/types/resources/ContractTerm.d.ts +15 -96
- package/types/resources/Coupon.d.ts +282 -758
- package/types/resources/CouponCode.d.ts +56 -52
- package/types/resources/CouponSet.d.ts +92 -234
- package/types/resources/CreditNote.d.ts +588 -1758
- package/types/resources/CreditNoteEstimate.d.ts +131 -157
- package/types/resources/Currency.d.ts +75 -62
- package/types/resources/Customer.d.ts +892 -835
- package/types/resources/CustomerEntitlement.d.ts +24 -35
- package/types/resources/DifferentialPrice.d.ts +116 -314
- package/types/resources/Discount.d.ts +20 -125
- package/types/resources/Download.d.ts +6 -22
- package/types/resources/Entitlement.d.ts +51 -160
- package/types/resources/EntitlementOverride.d.ts +58 -139
- package/types/resources/Estimate.d.ts +1178 -527
- package/types/resources/Event.d.ts +67 -178
- package/types/resources/Export.d.ts +563 -723
- package/types/resources/Feature.d.ts +117 -433
- package/types/resources/GatewayErrorDetail.d.ts +16 -72
- package/types/resources/Gift.d.ts +265 -432
- package/types/resources/Hierarchy.d.ts +8 -36
- package/types/resources/HostedPage.d.ts +1017 -1153
- package/types/resources/ImpactedItem.d.ts +13 -50
- package/types/resources/ImpactedItemPrice.d.ts +13 -15
- package/types/resources/ImpactedSubscription.d.ts +13 -45
- package/types/resources/InAppSubscription.d.ts +93 -389
- package/types/resources/Installment.d.ts +35 -110
- package/types/resources/InstallmentConfig.d.ts +54 -155
- package/types/resources/InstallmentDetail.d.ts +19 -27
- package/types/resources/Invoice.d.ts +1574 -3157
- package/types/resources/InvoiceEstimate.d.ts +131 -161
- package/types/resources/Item.d.ts +133 -611
- package/types/resources/ItemEntitlement.d.ts +78 -215
- package/types/resources/ItemFamily.d.ts +69 -178
- package/types/resources/ItemPrice.d.ts +291 -1203
- package/types/resources/Metadata.d.ts +3 -5
- package/types/resources/Order.d.ts +538 -1471
- package/types/resources/PaymentIntent.d.ts +163 -347
- package/types/resources/PaymentReferenceNumber.d.ts +7 -29
- package/types/resources/PaymentSource.d.ts +476 -1272
- package/types/resources/PaymentVoucher.d.ts +87 -306
- package/types/resources/PortalSession.d.ts +71 -207
- package/types/resources/PriceVariant.d.ts +91 -279
- package/types/resources/PricingPageSession.d.ts +92 -41
- package/types/resources/PromotionalCredit.d.ts +90 -346
- package/types/resources/Purchase.d.ts +185 -315
- package/types/resources/Quote.d.ts +1406 -887
- package/types/resources/QuoteLineGroup.d.ts +125 -452
- package/types/resources/QuotedCharge.d.ts +45 -274
- package/types/resources/QuotedSubscription.d.ts +100 -488
- package/types/resources/Ramp.d.ts +230 -747
- package/types/resources/ResourceMigration.d.ts +25 -80
- package/types/resources/SiteMigrationDetail.d.ts +34 -112
- package/types/resources/Subscription.d.ts +2390 -4336
- package/types/resources/SubscriptionEntitlement.d.ts +59 -160
- package/types/resources/SubscriptionEstimate.d.ts +51 -75
- package/types/resources/TaxWithheld.d.ts +15 -40
- package/types/resources/ThirdPartyPaymentMethod.d.ts +7 -29
- package/types/resources/TimeMachine.d.ts +43 -97
- package/types/resources/Token.d.ts +15 -85
- package/types/resources/Transaction.d.ts +276 -911
- package/types/resources/UnbilledCharge.d.ts +189 -164
- package/types/resources/Usage.d.ts +89 -279
- package/types/resources/VirtualBankAccount.d.ts +103 -255
- package/types/resources/filter.d.ts +52 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -81
- package/.github/ISSUE_TEMPLATE/config.yml +0 -6
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -34
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -8
- package/lib/chargebee.js +0 -512
- package/lib/resources/api_endpoints.js +0 -2935
- package/types/resources/NonSubscription.d.ts +0 -30
- 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
subscription_id:string;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @description The `id` of the [customer](customers#customer_id) object to which the subscription belongs.
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
customer_id?:string;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @description The `id` 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 `id` 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 `receipt` 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=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=2#item_id) that matches `product[id]` 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=2#item_price_id) that matches the concatenation of `product[id]` and `product[currency_code]`, 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
|
-
* `id` set to [original_transaction_id](https://developer.apple.com/documentation/appstorereceipts/original_transaction_id?language=objc)
|
|
69
|
-
* `start_date` set to [responseBody.Latest_receipt_info.purchase_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language=objc)
|
|
70
|
-
* `current_term_end` set to `responseBody.Latest_receipt_info.expires_date_ms`
|
|
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=2#transaction_reference_number) is set to the [transaction_id](https://developer.apple.com/documentation/appstorereceipts/transaction_id?language=objc) of the payment.
|
|
74
|
-
* The [transaction.payment_method](/docs/api/transactions#transaction_payment_method) is set to `apple_pay`.
|
|
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'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=2#item_family_id) that matches the value `Google-Play-Store`, and create such a product family if not found.
|
|
89
|
-
2. Look for [item.id](/docs/api/items?prod_cat_ver=2#item_id) that matches `product[id]` and if not found, create such a [plan-item](/docs/api/items?prod_cat_ver=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=2#item_price_id) that matches the concatenation of `product[id]` and [priceCurrencyCode](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions?hl=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
|
-
* `id` 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=en) object from Google response.
|
|
94
|
-
* `start_date` set to `SubscriptionPurchase.startTimeMillis`.
|
|
95
|
-
* `current_term_end` set to `SubscriptionPurchase.expiryTimeMillis`.
|
|
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=2#transaction_reference_number) is set to the [orderId](https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions?hl=en#SubscriptionPurchase.FIELDS.order_id) of the payment.
|
|
99
|
-
* The [transaction.payment_method](/docs/api/transactions#transaction_payment_method) is set to `play_store`.
|
|
100
|
-
|
|
101
|
-
Path Parameter {#path_param_pcv2}
|
|
102
|
-
---------------------------------
|
|
103
|
-
|
|
104
|
-
`{in_app_subscription_app_id}`: 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 `{in_app_subscription_app_id}`, 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 `{in_app_subscription_app_id}`, 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=objc#overview) and imports [subscriptions](/docs/api/subscriptions) for all historical purchases made by the customer.
|
|
120
|
-
**Tip**
|
|
121
|
-
An `in_app_subscription` is created for every unique `original_transaction_id`. Apple creates `original_transaction_id` for every create, upgrade, or downgrade of the subscription. A receipt hardly contains more than 100 `original_transaction_id`s. If a receipt contains more than 100 `original_transaction_id`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's user interface before importing receipts using this API.
|
|
135
|
-
|
|
136
|
-
Chargebee validates the `receipt` 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=objc) in the Apple receipt.
|
|
143
|
-
**Note** : This is not done for `original_transaction_id`s for which a subscription already exists in Chargebee.
|
|
144
|
-
2. Each subscription imported has the following attributes set:
|
|
145
|
-
* `id` set to `original_transaction_id`.
|
|
146
|
-
* `start_date` set to the earliest [purchase_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language=objc).
|
|
147
|
-
* `current_term_start` set to latest [purchase_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language=objc).
|
|
148
|
-
* `current_term_end` set to [expires_date_ms](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language=objc) of the same `Latest_receipt_info` element with the latest `purchase_date_ms`.
|
|
149
|
-
* `item_price_id` set to `product_id`.
|
|
150
|
-
* `status` set to `in_trial` if there is only one element of [Latest_receipt_info](https://developer.apple.com/documentation/appstorereceipts/responsebody/latest_receipt_info?language=objc) with the `original_transaction_id` and the field `is_trial_period` is `true`, 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=objc) which has [is_trial_period](https://developer.apple.com/documentation/appstorereceipts/is_trial_period?language=objc) as `false`.
|
|
157
|
-
2. Each imported invoice has the `subscription_id` set to `original_transaction_id`.
|
|
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. `reference_number` set to the `transaction_id`.
|
|
164
|
-
2. `payment_method` set to `apple_store`.
|
|
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 `token`. If any other purchase `token` is passed instead of the latest one, there is a possibility of returning incorrect transaction details. If an expired purchase `token` 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 `token` expires, an API request to Google Developers API returns an error.
|
|
178
|
-
|
|
179
|
-
Chargebee validates the purchase `token` 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 `token`( `linkedPurchaseToken` field in `SubscriptionsV2.get` API Response).
|
|
184
|
-
|
|
185
|
-
* Each subscription imported has the following attributes set:
|
|
186
|
-
|
|
187
|
-
* `id` set to a unique identifier generated by Chargebee and mapped to the `token` and `latestOrderId` of the `SubscriptionPurchaseV2` object from Google response.
|
|
188
|
-
|
|
189
|
-
* `start_date` set to the earliest `SubscriptionPurchaseV2.startTime`.
|
|
190
|
-
|
|
191
|
-
* `current_term_start` set to latest `SubscriptionPurchaseV2.startTime`.
|
|
192
|
-
|
|
193
|
-
* `current_term_end` set to `expiryTime` of the same `SubscriptionPurchaseV2` element with the latest purchase.
|
|
194
|
-
|
|
195
|
-
* `item_price_id` set to the concatenation of `product[id]` and `priceCurrencyCode` from Google.
|
|
196
|
-
|
|
197
|
-
* `status` set to `in_trial` 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 `Active` 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 "https://apidocs.chargebee.com/docs/api/invoices?prod_cat_ver=2") is imported to Chargebee for every new subscription and renewal of an existing subscription using `latestOrderId`.
|
|
204
|
-
|
|
205
|
-
* Each imported invoice has the `subscription_id` set to a unique identifier generated by Chargebee and mapped to the `token` and `latestOrderId`.
|
|
206
|
-
|
|
207
|
-
#### Transactions for the invoices
|
|
208
|
-
|
|
209
|
-
A [transaction](/docs/api/transactions) is imported for each invoice with the following details:
|
|
210
|
-
|
|
211
|
-
* `transaction.reference_number` is set to the `latestOrderId`.
|
|
212
13
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
* Enable V1 notifications in the Apple App Store for subscriptions created without receipts. Chargebee depends on receipt data to update subscription statuses. Apple's V2 notifications do not have receipt information; therefore, Chargebee cannot process V2 notifications for subscriptions imported without receipts. Learn more about [++app store notifications++](https://apidocs.chargebee.com/docs/api/in_app_purchase_events?prod_cat_ver=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'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 `latest_receipt_info` 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
|
-
* `id` set to `subscription[id]` . This `subscription[id]` is `original_transaction_id` in the receipts.
|
|
262
|
-
|
|
263
|
-
* `start_date` set to `subscription[start_date]`. You need to provide this information from the oldest `Latest_receipt_info.purchase_date_ms`.
|
|
264
|
-
|
|
265
|
-
* `term_start` set to `subscription[term_start]`. You need to provide this information from the oldest `Latest_receipt_info.purchase_date_ms)`.
|
|
266
|
-
|
|
267
|
-
* `term_end` set to `subscription[term_end]`. You need to provide this information from the oldest `Latest_receipt_info.expires_date_ms`.
|
|
268
|
-
|
|
269
|
-
* `item_price_id` set to `subscription[product_id] + subscription[currency_code].` You need to provide this information from the `Latest_receipt_info.product_id`.
|
|
270
|
-
|
|
271
|
-
* Chargebee records the subscription in a **Trial** state if the `is_trial_period` is `true`.
|
|
272
|
-
|
|
273
|
-
* Chargebee records the subscription in a **Canceled** state if the `term_end` is less than the `System.currentTime()`.
|
|
274
|
-
|
|
275
|
-
#### Invoice for the subscription
|
|
276
|
-
|
|
277
|
-
1. The payment is recorded against the subscription invoice.
|
|
278
|
-
|
|
279
|
-
* Imported invoice has the `subscription_id` set to `original_transaction_id`.
|
|
280
|
-
|
|
281
|
-
**Transactions for the invoice**
|
|
282
|
-
|
|
283
|
-
1. The associated transaction is updated with the following details:
|
|
284
|
-
|
|
285
|
-
* The `transaction.reference_number` is set to the `transaction_id` of the payment.
|
|
286
|
-
|
|
287
|
-
* The `transaction.payment_method` is set to `apple_store`.
|
|
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 `in_app_subscription_app_id `for the Apple App Store, click **View Keys** within the **Sync Overview** page of the web app, and use the value of generated **App ID** for this parameter. See detailed steps [here](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 `{in_app_subscription_app_id}` and `receipt` 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
|
-
|
|
41
|
+
export interface ProcessReceiptResponse {
|
|
42
|
+
in_app_subscription: InAppSubscription;
|
|
43
|
+
}
|
|
306
44
|
|
|
307
|
-
|
|
308
|
-
|
|
45
|
+
export interface ImportReceiptResponse {
|
|
46
|
+
in_app_subscriptions: InAppSubscription[];
|
|
47
|
+
}
|
|
309
48
|
|
|
310
|
-
|
|
49
|
+
export interface ImportSubscriptionResponse {
|
|
50
|
+
in_app_subscription: InAppSubscription;
|
|
51
|
+
}
|
|
311
52
|
|
|
312
|
-
|
|
53
|
+
export interface RetrieveStoreSubsResponse {
|
|
54
|
+
in_app_subscriptions: InAppSubscription[];
|
|
55
|
+
}
|
|
313
56
|
|
|
314
|
-
|
|
315
|
-
|
|
57
|
+
// REQUEST PARAMS
|
|
58
|
+
//---------------
|
|
316
59
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
60
|
+
export interface ProcessReceiptInputParam {
|
|
61
|
+
receipt: string;
|
|
62
|
+
product?: ProductProcessReceiptInputParam;
|
|
63
|
+
customer?: CustomerProcessReceiptInputParam;
|
|
320
64
|
}
|
|
321
|
-
export interface
|
|
322
|
-
|
|
65
|
+
export interface ImportReceiptInputParam {
|
|
66
|
+
receipt: string;
|
|
67
|
+
product?: ProductImportReceiptInputParam;
|
|
68
|
+
customer?: CustomerImportReceiptInputParam;
|
|
323
69
|
}
|
|
324
|
-
export interface
|
|
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=objc#overview) taken from the Apple device after successful creation of the in-app purchase subscription.
|
|
328
|
-
|
|
329
|
-
**Google Play Store** : The purchase `token` 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
|
|
350
|
-
|
|
74
|
+
export interface RetrieveStoreSubsInputParam {
|
|
75
|
+
receipt: string;
|
|
351
76
|
}
|
|
352
|
-
export interface
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
**Google Play Store** : The purchase `token` 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
|
|
378
|
-
|
|
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
|
-
|
|
93
|
+
export interface CustomerImportReceiptInputParam {
|
|
94
|
+
id?: string;
|
|
95
|
+
email?: string;
|
|
395
96
|
}
|
|
396
|
-
export interface
|
|
397
|
-
|
|
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=objc#overview) taken from the Apple device after successful creation of the in-app purchase subscription.
|
|
403
|
-
|
|
404
|
-
**Google Play Store** : The purchase `token` taken from the Android device after the successful creation of an in-app purchase subscription.
|
|
405
100
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
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
|
+
}
|