{"id":28254936,"url":"https://github.com/chargebee/chargebee-react-native","last_synced_at":"2026-02-23T23:15:34.887Z","repository":{"id":38865847,"uuid":"276608667","full_name":"chargebee/chargebee-react-native","owner":"chargebee","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-19T05:21:51.000Z","size":3255,"stargazers_count":8,"open_issues_count":15,"forks_count":15,"subscribers_count":22,"default_branch":"master","last_synced_at":"2026-02-19T11:38:33.060Z","etag":null,"topics":["chargebee","react-native"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chargebee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-07-02T09:46:35.000Z","updated_at":"2026-02-02T14:55:13.000Z","dependencies_parsed_at":"2023-02-19T04:46:13.677Z","dependency_job_id":"709185b3-3011-4081-8d0a-ca1ff9672f0a","html_url":"https://github.com/chargebee/chargebee-react-native","commit_stats":{"total_commits":101,"total_committers":13,"mean_commits":7.769230769230769,"dds":0.693069306930693,"last_synced_commit":"c11daf31a56dec477b71cd071a173cb6f85a3cc8"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/chargebee/chargebee-react-native","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-react-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-react-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-react-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-react-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chargebee","download_url":"https://codeload.github.com/chargebee/chargebee-react-native/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-react-native/sbom","scorecard":{"id":274118,"data":{"date":"2025-08-11","repo":{"name":"github.com/chargebee/chargebee-react-native","commit":"cfb3541bd8262600a00655d16079139fb331f11b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.5,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Info: Found linked content: SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":10,"reason":"14 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/secret.scan.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":8,"reason":"binaries present in source code","details":["Warn: binary detected: android/gradle/wrapper/gradle-wrapper.jar:1","Warn: binary detected: example/android/gradle/wrapper/gradle-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/chargebee/chargebee-react-native/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/chargebee/chargebee-react-native/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/chargebee/chargebee-react-native/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/chargebee/chargebee-react-native/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/secret.scan.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/chargebee/chargebee-react-native/secret.scan.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/secret.scan.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/chargebee/chargebee-react-native/secret.scan.yml/master?enable=pin","Info:   0 out of   5 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":3,"reason":"SAST tool is not run on all commits -- score normalized to 3","details":["Warn: 11 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"23 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-rxrc-rgv4-jpvx","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-h5c3-5r3r-rr8q","Warn: Project is vulnerable to: GHSA-rmvr-2pp2-xj38","Warn: Project is vulnerable to: GHSA-xx4v-prfh-6cgc","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-cchq-frgv-rjh5","Warn: Project is vulnerable to: GHSA-g644-9gfx-q4q4"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T14:03:03.514Z","repository_id":38865847,"created_at":"2025-08-17T14:03:03.514Z","updated_at":"2025-08-17T14:03:03.514Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29760250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T21:02:23.375Z","status":"ssl_error","status_checked_at":"2026-02-23T20:58:31.539Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chargebee","react-native"],"created_at":"2025-05-19T20:16:31.065Z","updated_at":"2026-02-23T23:15:34.855Z","avatar_url":"https://github.com/chargebee.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!WARNING]  \n\u003e **Chargebee React Native SDK** is part of Chargebee's legacy Mobile Subscription Solution and will not include the latest enhancements. We recommend using Chargebee's new [Omnichannel Subscriptions](https://www.chargebee.com/docs/billing/2.0/mobile-subscriptions/omnichannel-subscription-overview) solution for improved reliability and unified mobile subscriptions experience. \nIf you are a new customer, or considering to migrate new solution, please reach out to support@chargebee.com or contact your Technical Success Manager (TSM) for guidance.\n\n![Latest Release](https://github.com/chargebee/chargebee-react-native/actions/workflows/release.yml/badge.svg?branch=master)\n\nIntroduction\n======================\n\nThis is Chargebee’s React Native Software Development Kit (SDK). This SDK makes it efficient and comfortable to build a seamless subscription experience in your React Native App.\n\nPost-installation, initialization, and authentication with the Chargebee site, this SDK will support the following process.\n\n - **Sync In-App Subscriptions with Chargebee**: Integrate your App developed on React Native with Chargebee to process and track in-app subscriptions of the [Apple App Store](https://appstoreconnect.apple.com/login) and [Google Play Store](https://play.google.com/console/about/) on your Chargebee account. Thus you can create a single source of truth for subscriptions across Apple, Google, and Web stores. Use this if you are selling digital goods or services or are REQUIRED to use Apple's and Google's in-app purchases as per their app review guidelines ([Apple](https://developer.apple.com/app-store/review/guidelines/) and [Google](https://support.google.com/googleplay/android-developer/answer/9858738)). **For SDK methods to work, ensure that prerequisites (Apple and Google) are configured in Chargebee**.\n\n**_Note: If you are using the React native wrapper for performing web checkouts for physical goods, follow the set up for our 1.x SDK [here](https://github.com/chargebee/chargebee-react-native/tree/1.x)._**\n\n\nRequirements\n------------\n\nThe following requirements must be set up before installing Chargebee’s React Native SDK.\n\n-    Recommended React Native version 0.71.0 or higher. The minimum supported React Native version is 0.67.\n-    Requirements for Android https://github.com/chargebee/chargebee-android#requirements\n-    Requirements for iOS https://github.com/chargebee/chargebee-ios#requirements\n\n\n\nInstallation\n------------\n\nTo use Chargebee SDK in your React Native app, follow the below step.\n\n```sh\nyarn add @chargebee/react-native-chargebee\n```\n\nFor iOS, perform `pod install` after adding the SDK, to install the corresponding cocoapod package.\n\n\n\nPermissions\n------------\n\n1. For Android include the BILLING permission in your AndroidManifest.xml file.\n\n```sh\n\u003cuses-permission android:name=\"com.android.vending.BILLING\" /\u003e\n```\n\n2. For iOS enable In-App Purchase capability in Xcode by going to `Signing \u0026 Capabilities` and adding the `In-App Purchase` capability.\n\n\n\n\nExample project\n---------------\n\nThis is an optional step that helps you to verify the SDK implementation using this example project. You can download or clone the example project via GitHub.\n\nTo run the example project, follow these steps.\n\n-   Clone the repo - https://github.com/chargebee/chargebee-react-native.\n\n-   To install the base dependencies, run `yarn bootstrap` in the root directory\n\n-   To run the example app on Android, run `yarn example android`.\n\n-   To run the example app on iOS, run `yarn example ios`.\n\n\n## Configuring SDK\n\n**Prerequisites**\nBefore configuring the Chargebee ReactNative SDK for syncing In-App Purchases, follow these steps.\n\n1.  **iOS**: [Integrate](https://www.chargebee.com/docs/2.0/mobile-app-store-connect.html \"https://www.chargebee.com/docs/2.0/mobile-app-store-connect.html\") the [Apple App Store account](https://appstoreconnect.apple.com/login \"https://appstoreconnect.apple.com/login\") with your [Chargebee site](https://app.chargebee.com/login \"https://app.chargebee.com/login\").\n **Android**: [Integrate](https://www.chargebee.com/docs/2.0/mobile-playstore-connect.html \"https://www.chargebee.com/docs/2.0/mobile-playstore-connect.html\") [Google Play Store account](https://play.google.com/console/about/ \"https://play.google.com/console/about/\") with your [Chargebee site](https://app.chargebee.com/login \"https://app.chargebee.com/login\").\n2.  **iOS**: On the**Sync Overview** pageof theweb app, click **View Keys** and use the value of generated [**App ID**](https://www.chargebee.com/docs/1.0/mobile-app-store-product-iap.html#app-id \"https://www.chargebee.com/docs/1.0/mobile-app-store-product-iap.html#app-id\") as the **SDK Key**.\n**Android**: On the **Sync Overview** page of the web app, click **Set up notifications** and use the generated [**App ID**](https://www.chargebee.com/docs/1.0/mobile-playstore-notifications.html#app-id \"https://www.chargebee.com/docs/1.0/mobile-playstore-notifications.html#app-id\") value as the **SDK Key**.\n3.  On the Chargebee site, navigate to **Configure Chargebee** \u003e [**API Keys**](https://www.chargebee.com/docs/2.0/api_keys.html#create-an-api-key \"https://www.chargebee.com/docs/2.0/api_keys.html#create-an-api-key\") to create a new **Publishable API Key** or use an existing [**Publishable API Key**](https://www.chargebee.com/docs/2.0/api_keys.html#types-of-api-keys_publishable-key \"https://www.chargebee.com/docs/2.0/api_keys.html#types-of-api-keys_publishable-key\").\n\n**Note:** During the publishable API key creation you must allow **read-only** access to plans/items otherwise this key will not work in the following snippet. Read [more](https://www.chargebee.com/docs/2.0/api_keys.html#types-of-api-keys_publishable-key \"https://www.chargebee.com/docs/2.0/api_keys.html#types-of-api-keys_publishable-key\").\n\nInitialize the Chargebee ReactNative SDK with your Chargebee site, Publishable API Key, and SDK Keys by including the following snippets in your app delegate during app startup.\n\n```ts\nimport Chargebee from '@chargebee/react-native-chargebee';\n\nChargebee.configure({\n      site: \"SITE_NAME\",\n      publishableApiKey: \"API-KEY\",\n      androidSdkKey: \"Android SDK Key\",\n      iOsSdkKey: \"iOS SDK Key\",\n    });\n```\n\n## Integrating In-App Purchases\n\nThis section describes how to use the SDK to integrate In-App Purchase information. For details on In-App Purchase, read [more](https://www.chargebee.com/docs/2.0/mobile_subscriptions.html).\n\n#### Get all IAP Product Identifiers from Chargebee\n\nEvery In-App Purchase subscription product that you configure in your account, can be configured in Chargebee as a Plan. Start by retrieving the IAP Product IDs from your Chargebee account using the following function.\n\n```ts\nimport Chargebee from '@chargebee/react-native-chargebee';\n\nconst queryParams = new Map\u003cstring, string\u003e();\nqueryParams.set('limit', '100');\ntry {\n    const result: Array\u003cstring\u003e = await Chargebee.retrieveProductIdentifiers(queryParams);\n    console.log(result);\n} catch (error) {\n    console.error(error);\n}\n```\nFor example, query parameters can be passed as **\"limit\": \"100\"**.\n\n#### Get IAP Products\n\nRetrieve the IAP `Product` objects with Product IDs using the following function.\n\n```ts\nimport Chargebee, { Product } from '@chargebee/react-native-chargebee';\n\ntry {\n      const result: Array\u003cProduct\u003e = await Chargebee.retrieveProducts([\"Product ID from Google or Apple\"]);\n      console.log(result);\n    } catch (error) {\n      console.error(error);\n    }\n```\nYou can present any of the above products to your users for them to purchase.\n\n#### Buy or Subscribe Product\n\nPass the product and customer to the following function when your customer chooses the product to purchase.\n\n`id` - **Optional parameter**. Although this is an optional parameter, we recommend passing it if available, before the user subscribes to your App. Passing this parameter ensures that the customer id in your database matches that in Chargebee. In case this parameter is not passed, then the id will be the same as the SubscriptionId created in Chargebee.\n\n`firstName` - **Optional parameter**. Contains the first name of the customer.\n\n`lastName` - **Optional parameter**. Contains the last name of the customer.\n\n`email` - **Optional parameter**. Contains the email of the customer.\n\n\n\n```ts\nimport Chargebee, {\n    Purchase,\n    Customer\n} from '@chargebee/react-native-chargebee';\nconst customer: Customer = {\n    id: 'id',\n    firstName: 'fname',\n    lastName: 'lname',\n    email: 'fname@domain.com',\n};\ntry {\n    const result: Purchase = await Chargebee.purchaseProduct(\"product-id\", customer);\n    console.log(result);\n} catch (error) {\n    console.error(error);\n}\n```\n\nThe above function will handle the purchase against Apple App Store or Google Play Store and send the in-app purchase receipt for server-side receipt verification to your Chargebee account. Use the Subscription ID returned by the above function to check for Subscription status on Chargebee and confirm the access - **_granted or denied_**.\n\n### One-Time Purchases\nThe `purchaseNonSubscriptionProduct` function handles the one-time purchase against Apple App Store and Google Play Store and then sends the IAP receipt for server-side receipt verification to your Chargebee account. Post verification a Charge corresponding to this one-time purchase will be created in Chargebee. The Apple App Store supports three types of one-time purchases `consumable`, `non_consumable` and `non_renewing_subscription`. The Google Play Store supports two types of one-time purchases `consumable` and `non_consumable`.\n\n```ts\nimport Chargebee, {\n    OneTimePurchase,\n    Customer\n} from '@chargebee/react-native-chargebee';\nconst customer: Customer = {\n    id: 'id',\n    firstName: 'fname',\n    lastName: 'lname',\n    email: 'fname@domain.com',\n};\nconst productType = ProductType.NON_CONSUMABLE\ntry {\n    const result: OneTimePurchase = await Chargebee.purchaseNonSubscriptionProduct(\"product-id\", productType, customer);\n    console.log(result);\n} catch (error) {\n    console.error(error);\n}\n```\n\nThe given code defines a function named `purchaseNonSubscriptionProduct` in the Chargebee class, which takes three input parameters:\n\n- `product`: An instance of `Product` class, representing the product to be purchased from the Apple App Store or Google Play Store.\n- `customer`: Optional. An instance of `CBCustomer` class, initialized with the customer's details such as `customerId`, `firstName`, `lastName`, and `email`.\n- `productType`: An enum instance of `productType` type, indicating the type of product to be purchased. It can be either `consumable`, or `non_consumable`, or `non_renewing_subscription`. Note that `non_renewing_subscription` is supported only in Apple App Store.\n\nThe function is called asynchronously, and it returns a `Result` object with a `success` or `failure` case, as mentioned are below.\n- If the purchase is successful, it returns `OneTimePurchase` object. which includes the `invoiceId`, `chargeId`, and `customerId` associated with the purchase.\n- If there is any failure during the purchase, it returns error object that can be used to handle the error.\n\n\n#### Get Subscription Status for Existing Subscribers using Query Parameters\n\nUse the method, `retrieveSubscriptions` to check the subscription status of a subscriber who has already purchased the product.\n\nUse `SubscriptionsRequest` with query parameters- Subscription ID, Customer ID, or Status for checking the subscription status on Chargebee and confirming the access - **_granted or denied*_*.\n\n```ts\nimport Chargebee, { SubscriptionsRequest, Subscription } from '@chargebee/react-native-chargebee';\n\ntry {\n    const queryParams: SubscriptionsRequest = {customer_id : 'customer_id', subscription_id : 'subscription_id', status: 'active'}\n    const subscriptions: Subscription[] = await Chargebee.retrieveSubscriptions(queryParams);\n    console.log(subscriptions);\n} catch (error) {\n    console.error(error);\n}\n\n```\n\n#### Retrieve Entitlements of a Subscription\n\nUse the Subscription ID for fetching the list of [entitlements](https://www.chargebee.com/docs/2.0/entitlements.html) associated with the subscription.\n\n```ts\nconst request: EntitlementsRequest = {\n    subscriptionId: 'subscription-id',\n};\ntry {\n    const entitlements: Array\u003cEntitlement\u003e = await Chargebee.retrieveEntitlements(request);\n} catch (error) {\n    console.log(error);\n}\n```\n\n**Note**: Entitlements feature is available only if your Chargebee site is on [Product Catalog 2.0](https://www.chargebee.com/docs/2.0/product-catalog.html).\n\n\n#### Restore Purchases\n\nThe `restorePurchases()` function helps to recover your app user's previous purchases without making them pay again. Sometimes, your app user may want to restore their previous purchases after switching to a new device or reinstalling your app. You can use the `restorePurchases()` function to allow your app user to easily restore their previous purchases.\n\nTo retrieve **inactive** purchases along with the **active** purchases for your app user, you can call the `restorePurchases()` function with the `includeInactivePurchases` parameter set to true. If you only want to restore active subscriptions, set the parameter to false. To associate the restored purchases to an existing **customer**, it is recommended to pass the necessary customer details, such as **customerId**, **firstName**, **lastName**, and **email**. This ensures that the customer details in your database match the customer details in Chargebee. If the customerId is not passed in the customer’s details, then the value of customerId will be the same as the SubscriptionId created in Chargebee. \nHere is an example of how to use the restorePurchases() function in your code with the `includeInactivePurchases` parameter set to true.\n\n```ts\nimport Chargebee, { RestoredSubscription } from '@chargebee/react-native-chargebee';\nconst customer: Customer = {\n    id: 'id',\n    firstName: 'fname',\n    lastName: 'lname',\n    email: 'fname@domain.com',\n};\ntry {\n    const restoredSubscriptions: RestoredSubscription[] = await Chargebee.restorePurchases(true, customer);\n    console.log(restoredSubscriptions);\n} catch (error) {\n    console.error(error);\n}\n\n```\n\n##### Return Subscriptions Object\n\nThe `restorePurchases()` function returns an array of subscription objects and each object holds three attributes `subscriptionId`, `planId`, and `storeStatus`. The value of `storeStatus` can be used to verify subscription status.\n\n\n##### Error Handling\n\nIn the event of any errors/failures, the React native SDK will return an error object, which has the below format.\n`code` -  **number**. Chargebee Error code.\n`message` - **string**. Error description.\n`userInfo` - **(ChargebeeErrorDetail)** __Optional Object__. Contains additional error information.\n\nThe `ChargebeeErrorDetail` object is the below format:\n`apiErrorCode` - **string** __Optional__. Error code from Chargebee backend.\n`httpStatusCode` - **number** __Optional__. Http status code from Chargebee backend.\n`message` - **string** __Optional__. Error description.\n\n###### Example\n```ts\n{\n    \"code\": \"1000\",\n    \"message\": \"Sorry, we couldn't find the site abc-test\",\n    \"userInfo\": {\n        \"apiErrorCode\": \"site_not_found\",\n        \"httpStatusCode\": 404,\n        \"message\": \"Sorry, we couldn't find the site abc-test\"\n    }\n}\n```\n\n###### Error Codes\n\nThese are the possible error codes and their descriptions:\n\n| Error Code    | Description                             |\n|---------------|-----------------------------------------|\n|\t1000\t\t|\tINVALID_SDK_CONFIGURATION\t\t\t  |\n|\t1001\t\t|\tINVALID_CATALOG_VERSION\t\t\t\t  |\n|\t1002\t\t|\tCANNOT_MAKE_PAYMENTS\t\t\t\t  |\n|\t1003\t\t|\tNO_PRODUCT_TO_RESTORE\t\t\t\t  |\n|\t1004\t\t|\tINVALID_RESOURCE\t\t\t     \t  |\n|\t2001\t\t|\tINVALID_OFFER\t\t\t\t          |\n|\t2002\t\t|\tINVALID_PURCHASE\t\t\t\t      |\n|\t2003\t\t|\tINVALID_SANDBOX\t\t\t\t          |\n|\t2004\t\t|\tNETWORK_ERROR\t\t\t\t          |\n|\t2005\t\t|\tPAYMENT_FAILED\t\t\t\t          |\n|\t2006\t\t|\tPAYMENT_NOT_ALLOWED\t\t\t\t      |\n|\t2007\t\t|\tPRODUCT_NOT_AVAILABLE\t\t\t\t  |\n|\t2008\t\t|\tPURCHASE_NOT_ALLOWED\t\t\t\t  |\n|\t2009\t\t|\tPURCHASE_CANCELLED\t\t\t\t      |\n|\t2010\t\t|\tSTORE_PROBLEM\t\t\t\t          |\n|\t2011\t\t|\tINVALID_RECEIPT\t\t\t\t          |\n|\t2012\t\t|\tREQUEST_FAILED\t\t\t\t          |\n|\t2013\t\t|\tPRODUCT_PURCHASED_ALREADY\t\t      |\n|\t3000\t\t|\tSYSTEM_ERROR\t\t\t\t          |\n|\t0\t\t\t|\tUNKNOWN\t\t\t\t                  |\n\n\n#### Synchronization of Apple App Store/Google Play Store Purchases with Chargebee through Receipt Validation\nReceipt validation is crucial to ensure that the purchases made by your users are synced with Chargebee. In rare cases, when a purchase is made at the Apple App Store/Google Play Store, and the network connection goes off or the server was not responding, the purchase details may not be updated in Chargebee. In such cases, you can use a retry mechanism by following these steps:\n\n* Save the product identifier in the cache once the purchase is initiated and clear the cache once the purchase/retry validation is successful.\n* When the purchase is completed at Apple App Store/Google Play Store but not synced with Chargebee, retrieve the product from the cache and initiate validateReceipt() by passing `productId` and `Customer` as input. This will validate the receipt and sync the purchase in Chargebee as a subscription.\n\nUse the function available for the retry mechanism.\n##### Function for validating the Subscriptions receipt\n\n``` ts\nimport Chargebee from '@chargebee/react-native-chargebee';\n\ntry {\n    const purchase = await Chargebee.validateReceipt(productId, customer)\n} catch (error) {\n    console.log(\"error\", error);\n}\n```\n\n##### Function for validating the One-Time Purchases receipt\n\n``` ts\nimport Chargebee, {\n    OneTimePurchase,\n    Customer\n} from '@chargebee/react-native-chargebee';\nconst customer: Customer = {\n    id: 'id',\n    firstName: 'fname',\n    lastName: 'lname',\n    email: 'fname@domain.com',\n};\nconst productType = ProductType.NON_CONSUMABLE\ntry {\n    const result: OneTimePurchase = await Chargebee.validateReceiptForNonSubscriptions(productId, productType, customer)\n} catch (error) {\n    console.log(\"error\", error);\n}\n```\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## License\n\nChargebee is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchargebee%2Fchargebee-react-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchargebee%2Fchargebee-react-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchargebee%2Fchargebee-react-native/lists"}