{"id":28254955,"url":"https://github.com/chargebee/chargebee-ios","last_synced_at":"2025-07-11T08:12:41.442Z","repository":{"id":37493812,"uuid":"277504918","full_name":"chargebee/chargebee-ios","owner":"chargebee","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-22T10:06:28.000Z","size":9551,"stargazers_count":11,"open_issues_count":3,"forks_count":12,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-05-19T20:19:01.809Z","etag":null,"topics":["critical","mobile-subscription"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-07-06T09:55:13.000Z","updated_at":"2025-04-22T10:06:32.000Z","dependencies_parsed_at":"2023-12-22T07:28:31.383Z","dependency_job_id":"d2d887be-160b-4f26-80f2-bb3601b6a18d","html_url":"https://github.com/chargebee/chargebee-ios","commit_stats":{"total_commits":189,"total_committers":20,"mean_commits":9.45,"dds":0.7936507936507937,"last_synced_commit":"643f7989d71b09a23027e1455a483e3b88c16f94"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/chargebee/chargebee-ios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chargebee","download_url":"https://codeload.github.com/chargebee/chargebee-ios/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-ios/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260114437,"owners_count":22960907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["critical","mobile-subscription"],"created_at":"2025-05-19T20:16:31.559Z","updated_at":"2025-07-11T08:12:41.421Z","avatar_url":"https://github.com/chargebee.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!WARNING]  \n\u003e **Chargebee iOS 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\nChargebee iOS (Legacy)\n=============\n\nThis is the official  Software Development Kit (SDK) for Chargebee iOS. This SDK makes it efficient and comfortable to build an impressive subscription experience in your iOS app.\n\nPost-installation, initialization, and authentication with the Chargebee site, this SDK will support the following capabilities.\n\n-   **Sync In-App Subscriptions with Chargebee**: [Integrate](https://www.chargebee.com/docs/2.0/mobile-app-store-connect.html) with [Apple Store Connect](https://appstoreconnect.apple.com/login) to process in-app purchase subscriptions, and track them on your Chargebee account for a single source of truth for subscriptions across the Web and Apple App Store. Use this if you are selling digital goods or services, or are REQUIRED to use Apple's in-app purchases as per their [app review guidelines](https://developer.apple.com/app-store/review/guidelines/).\n    For SDK functions to work seamlessly, ensure that products configured in the Apple App Store and existing subscriptions are successfuly [imported](https://www.chargebee.com/docs/2.0/mobile-app-store-product-iap.html#import-products) into Chargebee.\n\n-   **Tokenisation of credit card**: Tokenize credit card information while presenting your own user interface. Use this if you are selling physical goods or offline services or are NOT REQUIRED to use Apple's in-app purchases as per their [app review guidelines](https://developer.apple.com/app-store/review/guidelines/).\n\n-  **Note**: This SDK doesn’t support Apps developed using Objective C. If your app is developed using Objective C then we can guide you to integrate Objective C with our SDK code. Please reach out to support@chargebee.com\n\nRequirements\n------------\n\nThe following requirements must be set up prior to installing Chargebee's iOS SDK\n\n-   iOS 12+\n\n-   Swift 5+\n\nInstallation\n------------\n\nChoose from the following options to install Chargeee iOS SDK.\n\n### Github\n\nAdd the following snippet to the Podfile to install directly from Github.\n\n```swift\npod 'Chargebee', :git =\u003e 'https://github.com/chargebee/chargebee-ios', :tag =\u003e '1.0.28'\n```\n\n### CocoaPods\n\nAdd the following line to your Podfile to install using [CocoaPods](https://cocoapods.org/pods/Chargebee).\n\n```swift\npod 'Chargebee'\n```\n\n### Swift Package Manager\n\nFollow the step to install SDK using Swift Package Manager.\n\n-   Select File \u003e Swift Packages \u003e Add Package Dependency\n\n-   Add repository URL https://github.com/chargebee/chargebee-ios\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-ios.\n\n-   Run pod install from the Example directory.\n\nConfiguring SDK\n---------------\n\nThere are two types of configuration.\n\n-   Configuration for In-App Purchases\n\n-   Configuration for credit card using tokenization\n\n### Configuration for In-App Purchases\n\nTo configure the Chargebee iOS SDK for completing and managing In-App Purchases, follow these steps.\n\n-   [Integrate](https://www.chargebee.com/docs/2.0/mobile-app-store-connect.html) the [App Store Connect](https://appstoreconnect.apple.com/login) with your [Chargebee site](https://app.chargebee.com/login).\n\n-   On the **Sync Overview** page of the web app, click **View Keys** and use the value of generated [**App ID**](https://www.chargebee.com/docs/2.0/mobile-app-store-product-iap.html#connection-keys_app-id) as the **SDK Key**.\n\n-   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) 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).\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 step. Read [more](https://www.chargebee.com/docs/2.0/api_keys.html#types-of-api-keys_publishable-key).\n\n-   Initialize the SDK with your Chargebee site, Publishable API Key, and SDK Key by including the following snippets in your app delegate during app startup.\n\n```swift\nimport Chargebee\n\nChargebee.configure(site: \"your-site\",\n                    apiKey: \"publishable_api_key\",\n                    sdkKey: \"SDK Key\")\n}\n```\n\n### Configuration for credit card using tokenization\n\nTo configure SDK only for tokenizing credit card details, follow these steps.\n\n-   Initialize the SDK with your Chargebee Site and Publishable/Full Access Key.\n\n-   Initialize the SDK during your app startup by including the following snippets in your app delegate.\n\n```swift\nimport Chargebee\n\nChargebee.configure(site: \"your-site\", apiKey: \"publishable_api_key\")\n```\n\nSDK Integration Processes\n-------------------------\n\nThis section describes the SDK integration capabilities.\n\n-   Integrating In-App Purchases\n\n-   Integrating credit card tokenization\n\n### Integrating In-App Purchases\n\nThe following 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-in-app-purchases.html).\n\n#### Get all IAP Product IDs from Chargebee\n\nEvery In-App Purchase subscription product you configure in your App Store Connect account can be configured in Chargebee as a Plan. Start by retrieving the Apple IAP Product IDs from your Chargebee account.\n\n```swift\nCBPurchase.shared.retrieveProductIdentifers(queryParams :[\"String\": \"String\"], completion:  { result in\nswitch result {\n    case let .success(products):\n        print(\"array of Products Id's \\(products)\")\n    case let .failure(error):\n        // Handle error here\n}\n})\n```\n\nFor example, query parameters can be passed as **\"limit\": \"100\"**.\n\nThe above function will automatically determine your product catalog version in Chargebee and call the relevant APIs to retrieve the Chargebee Plans that correspond to Apple IAP products and their Apple IAP Product IDs.\n\n#### Get IAP Products\n\nYou can then convert the IAP Product IDs to Apple IAP Product objects with the following function.\n\n```swift\nCBPurchase.shared.retrieveProducts(withProductID : [\"Product ID from Apple\"],completion: { result in\n    switch result {\n    case let .success(products):\n        print(\"array of Products \\(products)\")\n    case let .failure(error):\n        // Handle error here\n}\n}\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 `CBProduct` and  `CBCustomer` objects to the following function when the user chooses the product to purchase.\n\n`CBCustomer` - **Optional object**. Although this is an optional object, we recommend passing the necessary customer details, such as `customerID`, `firstName`, `lastName`, and `email` if it is available before the user subscribes to your App. 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.\n\n**Note**: The `customer` parameter in the below code snippet is an instance of `CBCustomer` class that contains the details of the customer who wants to subscribe or buy the product.\n\n```swift\n\n    let product = CBProduct(product: SKProduct())\n    let customer = CBCustomer(customerID: \"\",firstName:\"\",lastName: \"\",email: \"\")\n    CBPurchase.shared.purchaseProduct(product: product,customer: customer) { result in\n    switch result {\n        case .success(let result):\n            print(result.status)\n            print(result.subscriptionId) // this will print the subscription ID \n            print(result.planId) // this will print the Plan ID \n        case .failure(let error):\n            // Handle error here\n    }\n}\n```\n\nThe above function will handle the purchase against App Store Connect and send the IAP 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\nThis function also returns the plan ID associated with a subscription. You can associate JSON metadata with the Apple App Store plans in Chargebee and retrieve the same by passing plan ID to the SDK function - [retrievePlan](https://github.com/chargebee/chargebee-ios#get-plan-details)(PC 1.0) or [retrieveItem](https://github.com/chargebee/chargebee-ios#get-item-details)(PC 2.0).\n\n#### Upgrade or Downgrade Subscription\n\nWhen a user changes their subscription level from a lower price plan to a higher price plan, it's considered an upgrade. On the other hand, when a user switches from a higher-price plan to a lower-price plan, it's considered a downgrade.\n\nIn the case of the Apple App Store, you can arrange the subscriptions using the drag-and-drop option in **Edit Subscription Order** in App Store Connect. [Learn more](https://developer.apple.com/app-store/subscriptions/#ranking).\n\n##### Invoke Upgrade or Downgrade Subscription Flow in your App\n\nThe `showManageSubscriptionsSettings()` function is designed to invoke the upgrade/downgrade flow in your app using Chargebee's iOS SDKs.\n`Chargebee.shared.showManageSubscriptionsSettings()`, opens the App Store App subscriptions settings page.\n\n**Note**: Upgrades and downgrades are handled through [Apple App Store Server Notifications](https://apidocs.chargebee.com/docs/api/in_app_purchase_events?prod_cat_ver=2#app_store_notifications) in Chargebee.\n\n#### One-Time Purchases\n\nThe `purchaseNonSubscriptionProduct` function handles the one-time purchase against App Store Connect and 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. There are three types of one-time purchases `consumable`, `non_consumable`, and `non_renewing_subscription`.\n\n```swift\nlet product = CBProduct(product: SKProduct())\n    let customer = CBCustomer(customerID: \"\",firstName:\"\",lastName: \"\",email: \"\")\n    let typeOfProduct: productType = .non_consumable\n    CBPurchase.shared.purchaseNonSubscriptionProduct(product: withproduct,customer: customer,productType: typeOfProduct) { result in\n      switch result {\n      case .success(let success):\n        print(result.customerID)\n        print(result.chargeID ?? \"\")\n        print(result.invoiceID ?? \"\")\n      case .failure(let failure):\n        // Handle error here\n      }\n    }\n```\n\nThe given code defines a closure-based function named `purchaseNonSubscriptionProduct` in the `CBPurchase` class, which takes three input parameters:\n- `product`: An instance of `CBProduct` class, initialized with a `SKProduct` instance representing the product to be purchased from the Apple App Store.\n- `customer`: 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`, .`non_consumable`, or .`non_renewing_subscription`.\n\nThe function is called asynchronously, and it returns a `Result` object with a `success` or `failure` case, which can be handled in the closure.\n- If the purchase is successful, the closure will be called with the `success` case, which includes the `customerID`, `chargeID`, and `invoiceID` associated with the purchase.\n- If there is any failure during the purchase, the closure will be called with the `failure` case, which includes an error object that can be used to handle the error.\n\n#### Restore purchase\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 `includeInActiveProducts` parameter set to `true`. If you only want to restore active subscriptions, set the parameter to `false`. Here is an example of how to use the `restorePurchases()` function in your code with the `includeInActiveProducts` parameter set to `true`.\n\nCBCustomer - Optional object. Although this is an optional object, we recommend passing the necessary customer details, such as customerId, firstName, lastName, and email if it is available before the user subscribes to your App. 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. Also, the restored subscriptions will not be associate with existing customerId.\n\n```swift\n\nlet customer = CBCustomer(customerID: \"Test123\",firstName: \"CB\",lastName: \"Test\",email: \"cbTest@chargebee.com\")\nCBPurchase.shared.restorePurchases(includeInActiveProducts: true, customer: customer) { result in\n      switch result {\n      case .success(let response):\n        for subscription in response {\n          if subscription.storeStatus.rawValue == StoreStatus.Active.rawValue{\n            print(\"Successfully restored purchases\")\n          }\n        }\n      case .failure(let error):\n        // Handle error here\n        print(\"Error:\",error)\n      }\n    }\n```\n##### Return Subscriptions Object\n\nThe `restorePurchases()` function returns an array of subscription objects and each object holds three attributes `subscription_id`, `plan_id`, and `store_status`. The value of `store_status` can be used to verify subscription status.\n\n##### Error Handling\n\nIn the event of any failures during the refresh and validation process or while finding associated subscriptions for the restored items, iOS SDK will return an error, as mentioned in the following table.\n\n###### Error Codes\n\nThese are the possible error codes and their descriptions:\n| Error Code                        | Description                                                                                                                 |\n|-----------------------------------|-----------------------------------------------------------------------------------------------------------------------------|\n| `RestoreError.noReceipt`            | This error occurs when the user attempts to restore a purchase, but there is no receipt associated with the purchase.       |\n| `RestoreError.refreshReceiptFailed` | This error occurs when the attempt to refresh the receipt for a purchase fails.                                             |\n| `RestoreError.restoreFailed`        | This error occurs when the attempt to restore a purchase fails for reasons other than a missing or invalid receipt.         |\n| `RestoreError.invalidReceiptURL`    | This error occurs when the URL for the receipt bundle provided during the restore process is invalid or cannot be accessed. |\n| `RestoreError.invalidReceiptData`   | This error occurs when the data contained within the receipt is not valid or cannot be parsed.                              |\n| `RestoreError.noProductsToRestore`  | This error occurs when there are no products available to restore.                                                          |\n| `RestoreError.serviceError`         | This error occurs when there is an error with the Chargebee service during the restore process.                             |\n\n**Note**: These error codes are implemented in our example app. [Learn more](https://github.com/chargebee/chargebee-ios/blob/master/Example/Chargebee/CBSDKOptionsViewController.swift#L202-L224).\n\n#### Synchronization of Apple App Store Purchases with Chargebee through Receipt Validation\n\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, and the network connection goes off, the purchase details may not be updated in Chargebee. In such cases, you can use a retry mechanism by following these steps:\n-   Add a network observer, as shown in the example project.\n-   Save the product identifier in the cache once the purchase is initiated and clear the cache once the purchase is successful.\n-   When the network connectivity is lost after the purchase is completed at Apple App Store but not synced with Chargebee, retrieve the product ID from the cache once the network connection is back and initiate `validateReceipt()`/`validateReceiptForNonSubscriptions()` by passing `CBProduct` and `CBCustomer(Optional)` as input. This will validate the purchase receipt and sync the purchase in Chargebee as a subscription or one-time purchase.\nFor subscriptions, use the function `validateReceipt()`; for one-time purchases, use the function `validateReceiptForNonSubscriptions()`.\n\nUse the function available for the retry mechanism.\n\n**Function for subscriptions**\n\n```swift\nCBPurchase.shared.validateReceipt(product,customer: nil) { result in\n      switch result {\n      case .success(let result):\n        print(result.status )\n        // Clear persisted product details once the validation succeeds.\n      case .failure(let error):\n        print(\"error\", error.localizedDescription)\n        // Retry based on the error\n      }\n    }\n```\n\n**Function for one-time purchases**\n\n```swift\nCBPurchase.shared.validateReceiptForNonSubscriptions(product,type,customer: nil) { result in\n        switch result {\n        case .success(let result):\n          // Clear persisted product details once the validation succeeds.\n        case .failure(let error):\n          // Retry based on the error\n        }\n      }\n```\n\n#### Get Subscription Status for Existing Subscribers\n\nThe following are funtions for checking the subscription status of a subscriber who already purchased the product.\n\n##### Get Subscription Status for Existing Subscribers using Query Parameters\n\nUse query parameters - Subscription ID, Customer ID, or Status for checking the Subscription status on Chargebee and confirm the access - granted or denied.\n\n```swift\nChargebee.shared.retrieveSubscriptions(queryParams :[\"String\" : \"String\"]\") { result in\n  switch result {\n  case let .success(result):\n    print(\"Next offset \\(result.nextOffset)\")\n    print(\"Subscriptions: \\(result.list)\")\n  case let .error(error):\n    // Handle error here\n  }\n}\n```\n\nFor example, query parameters can be passed as **\"customer_id\" : \"id\"**, **\"subscription_id\": \"id\"**, or **\"status\": \"active\"**.\n\n##### Get Subscription Status for Existing Subscribers using Subscription ID\n\nUse only Subscription ID for checking the Subscription status on Chargebee and confirm the access - granted or denied.\n\n```swift\nChargebee.shared.retrieveSubscription(forID: \"SubscriptionID\") { result in\n    switch result {\n    case let .success(result):\n        print(\"Status \\(result.status)\")\n    case let .error(error):\n        // Handle error here\n    }\n}\n```\n\nThe above functions return the plan ID associated with a subscription. You can associate JSON metadata with the Apple App Store plans in Chargebee and retrieve the same by passing plan ID to the SDK function - [retrievePlan](https://github.com/chargebee/chargebee-ios#get-plan-details)(PC 1.0) or [retrieveItem](https://github.com/chargebee/chargebee-ios#get-item-details)(PC 2.0).\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```swift\nChargebee.shared.retrieveEntitlements(forID: \"SubscriptionID\") { result in\n    switch result {\n    case let .success(result):\n        print(\"Status \\(result.status)\")\n    case let .error(error):\n        // Handle error here\n    }\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\n### Integrating credit card tokenization\n\nThe following section describes how to use the SDK to tokenize credit card information.\n\n#### Product Catalog 2.0\n\nIf your Chargebee site is configured to PC 2.0, use the following functions to retrieve the product or product list for purchase.\n\n##### Get all items\n\nRetrieve the list of items using the following function.\n\n```swift\n  CBItem.retrieveAllItems(queryParams :[\"String\" : \"String\"], completion:  { result in\n                DispatchQueue.main.async {\n                    switch result {\n                    case let .success(itemLst):\n                        self.items =  itemLst.list\n                        debugPrint(\"items: \\(self.items)\")\n                        self.performSegue(withIdentifier: \"itemList\", sender: self)\n                    case let .error(error):\n                        debugPrint(\"Error: \\(error.localizedDescription)\")\n                    }\n                }\n    })\n```\n\nFor example, query parameters can be passed as **\"sort_by[desc]\" : \"name\"** or **\"limit\": \"100\"**.\n\n##### Get item details\n\nRetrieve specific item details using the following function. Use the Item ID that you received from the previous function - Get all items.\n\n```swift\nCBItem.retrieveItem(\"Item ID\"){ (itemResult) in\n            switch itemResult {\n            case .success(let item):\n                print(item)\n                self.itemName.text = item.name\n                self.itemStatus.text = item.status\n\n            case .error(let error):\n                print(\"Error\\(error)\")\n                self.error.text = error.localizedDescription\n            }\n        }\n```\n\n#### Product Catalog 1.0\n\nIf your Chargebee site is configured to PC 1.0, use the relevant functions to retrieve the product or product list for purchase.\n\n##### Get All Plans\n\nRetrieve a list of plans using the following function.\n\n```swift\nCBPlan.retrieveAllPlans(queryParams: [\"String\":\"String\" ]) { (result) in\n    switch result {\n    case .success(let plan):\n        print(\"Plan Array: \\(plan)\")\n        // Use plan details here\n    case .error(let error):\n        // Handle error here\n    }\n}\n```\n\nFor example, query parameters can be passed as **\"sort_by[desc]\" : \"name\"** or **\"limit\": \"100\"**.\n\n##### Get Plan Details\n\nRetrieve specific plan details passing plan ID in the following function.\n\n```swift\nCBPlan.retrieve(\"planId\") { (planResult) in\n    switch planResult {\n    case .success(let plan):\n        print(\"Plan Name: \\(plan.name)\")\n        // Use plan details here\n    case .error(let error):\n        // Handle error here\n    }\n}\n```\n\n##### Get Addon Details\n\nRetrieve specific addon details passing addon ID in the following function.\n\n```swift\nCBAddon.retrieve(\"addonId\") { (addonResult) in\n    switch addonResult {\n    case .success(let addon):\n        print(\"Addon Name: \\(addon.name)\")\n        // Use addon details here\n    case .error(let error):\n        // Handle error here\n    }\n}\n```\n\n### Get Payment Token\n\nOnce the user selects the product to purchase, and you collect the credit card information, use the following function to tokenize the credit card details against Stripe. You need to have connected your Stripe account to your Chargebee site.\n\n```swift\nlet card = CBCard(\n        cardNumber: \"4321567890123456\",\n        expiryMonth: \"12\",\n        expiryYear: \"29\",\n        cvc: \"123\")\n\nlet paymentDetail = CBPaymentDetail(type: CBPaymentType.Card, currencyCode: \"USD\", card: card)\n\nChargebee.shared.createTempToken(paymentDetail: paymentDetail) { tokenResult in\n    switch tokenResult {\n    case .success(let token):\n        print(\"Chargebee Token \\(token)\")\n        // Use token here\n    case .error(let error):\n        // Handle error here\n    }\n}\n```\n\n### Use the Chargebee Token\n\nAfter the customer's card data is processed and stored and a Chargebee token reference is returned to you, use the token in subsequent API calls to process transactions.\n\nThe following are some endpoints that accept Chargebee tokens for processing subscriptions.\n\n-   [Create a Payment Source for the customer](https://apidocs.chargebee.com/docs/api/payment_sources#create_using_chargebee_token)\n\n-   [Create a Subscription](https://apidocs.chargebee.com/docs/api/subscriptions#create_a_subscription)\n\n-   [Update a Subscription](https://apidocs.chargebee.com/docs/api/subscriptions#update_a_subscription)\n\nPlease refer to the [Chargebee API Docs](https://apidocs.chargebee.com/docs/api) for subsequent integration steps.\n\nLicense\n-------\n\nChargebee is available under the [MIT license](https://opensource.org/licenses/MIT). For more information, see the LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchargebee%2Fchargebee-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchargebee%2Fchargebee-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchargebee%2Fchargebee-ios/lists"}