### Start Metro Server for Example App Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/CONTRIBUTING.md Starts the Metro bundler, which is required to run the example application. This command is used to serve the JavaScript bundle for the React Native example app. ```shell yarn example start ``` -------------------------------- ### Start Metro Bundler Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/example/README.md Starts the Metro bundler, the JavaScript bundler for React Native. This command is run from the root of your React Native project. ```bash # using npm npm start # OR using Yarn yarn start ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/CONTRIBUTING.md Installs all necessary project dependencies using Yarn. This command is crucial for setting up the monorepo environment, including installing packages for the library and the example app. ```shell yarn ``` -------------------------------- ### Start React Native Application Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/example/README.md Launches your React Native application on an Android emulator/device or iOS simulator. Ensure the Metro bundler is running in a separate terminal. ```bash # For Android # using npm npm run android # OR using Yarn yarn android ``` ```bash # For iOS # using npm npm run ios # OR using Yarn yarn ios ``` -------------------------------- ### Run Example App on iOS Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/CONTRIBUTING.md Builds and runs the example application on an iOS simulator or device. This command is used to test library changes on the iOS platform. ```shell yarn example ios ``` -------------------------------- ### Run Example App on Android Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/CONTRIBUTING.md Builds and runs the example application on an Android device or emulator. This is essential for testing changes made to the library against a real Android environment. ```shell yarn example android ``` -------------------------------- ### Install Package Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/README.md Installs the @cafebazaar/react-native-poolakey package using either Yarn or npm. ```sh yarn add @cafebazaar/react-native-poolakey ``` ```sh npm install @cafebazaar/react-native-poolakey ``` -------------------------------- ### Publish to npm Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/CONTRIBUTING.md Publishes a new version of the library to npm using release-it. This script handles version bumping, tagging, and release creation, following semantic versioning conventions. ```shell yarn release ``` -------------------------------- ### Fix Formatting Errors Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/CONTRIBUTING.md Automatically fixes code formatting errors detected by ESLint and Prettier. This command should be run to ensure the code adheres to the project's styling standards. ```shell yarn lint --fix ``` -------------------------------- ### Run Unit Tests Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/CONTRIBUTING.md Executes the project's unit tests using Jest. It's important to run tests to verify the correctness of changes and ensure no regressions are introduced. ```shell yarn test ``` -------------------------------- ### Typecheck Project Files Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/CONTRIBUTING.md Performs type checking on the project's TypeScript files. This command helps ensure code quality and catch potential type-related errors before committing. ```shell yarn typecheck ``` -------------------------------- ### Lint Project Files Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/CONTRIBUTING.md Lints the project's code using ESLint to enforce code style and identify potential issues. This command helps maintain code consistency across the project. ```shell yarn lint ``` -------------------------------- ### Conventional Commits Specification Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/CONTRIBUTING.md Details the commit message convention used by the project, based on the Conventional Commits specification. This standardizes commit messages for better readability and automated changelog generation. ```markdown - `fix`: bug fixes, e.g. fix crash due to deprecated method. - `feat`: new features, e.g. add new method to the module. - `refactor`: code refactor, e.g. migrate from class components to hooks. - `docs`: changes into documentation, e.g. add usage example for the module.. - `test`: adding or updating tests, e.g. add integration tests using detox. - `chore`: tooling changes, e.g. change CI config. ``` -------------------------------- ### CafeBazaar Payment SDK API Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/README.md Comprehensive API documentation for the CafeBazaar React Native SDK, covering connection management, purchase operations, subscription handling, and data retrieval. ```APIDOC connect / disconnect TLDR: For each `connect` call, you need to call `disconnect` too. Description: Manages the connection to the Bazaar service. Multiple `connect` calls increment an internal counter, requiring an equal number of `disconnect` calls to fully disconnect. Other APIs will internally wait for a connection to be established. Usage in Functional Components: The `useBazaar` hook simplifies connection management by automatically handling `connect` and `disconnect` within component lifecycle hooks. purchaseProduct(productId: string): Promise Description: Initiates the purchase flow for a given product ID. The Bazaar app handles the payment process automatically. Parameters: - productId: The unique identifier of the product to purchase. Returns: A Promise that resolves with a PurchaseResult object upon successful purchase. consumePurchase(purchaseToken: string): Promise Description: Consumes a previously purchased consumable product. Requires the `purchaseToken` obtained from a `purchaseProduct` call. Parameters: - purchaseToken: The token associated with the purchase to be consumed. Returns: A Promise that resolves when the purchase is successfully consumed. subscribeProduct(productId: string): Promise Description: Initiates the subscription flow for a given product ID. The Bazaar app handles the payment process automatically. Parameters: - productId: The unique identifier of the product to subscribe to. Returns: A Promise that resolves with a PurchaseResult object upon successful subscription. getPurchasedProducts(): Promise Description: Retrieves a list of all products purchased by the currently logged-in user in the Bazaar app. Returns: A Promise that resolves with an array of PurchaseResult objects. getSubscribedProducts(): Promise Description: Retrieves a list of all subscriptions purchased by the currently logged-in user in the Bazaar app. Returns: A Promise that resolves with an array of PurchaseResult objects. queryPurchaseProduct(productId: string): Promise Description: Retrieves detailed data for a specific product purchase using its product ID. Parameters: - productId: The unique identifier of the product to query. Returns: A Promise that resolves with a PurchaseResult object for the specified product. querySubscribeProduct(productId: string): Promise Description: Retrieves detailed data for a specific subscription purchase using its product ID. Parameters: - productId: The unique identifier of the subscription product to query. Returns: A Promise that resolves with a PurchaseResult object for the specified subscription. getInAppSkuDetails(productIds: string[]): Promise Description: Fetches details for multiple in-app products based on their product IDs. Parameters: - productIds: An array of product IDs for which to fetch details. Returns: A Promise that resolves with an array of SkuDetails objects. getSubscriptionSkuDetails(productIds: string[]): Promise Description: Fetches details for multiple subscription products based on their product IDs. Parameters: - productIds: An array of product IDs for which to fetch subscription details. Returns: A Promise that resolves with an array of SkuDetails objects. PurchaseResult Type Definition: Description: Represents the result of a purchase or subscription operation. Structure: orderId: string packageName: string productId: string purchaseTime: Date purchaseState: number developerPayload: string purchaseToken: string SkuDetails Type Definition: Description: Represents the details of a product or subscription SKU. Structure: sku: string type: string price: string title: Date description: number ``` -------------------------------- ### Usage in Class Components Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/README.md Illustrates how to use the SDK in React Native class components, including connecting, disconnecting, and initiating purchases. ```javascript import bazaar from '@cafebazaar/react-native-poolakey'; // ... class MyApp extends React.Component { componentDidMount() { bazaar .connect(YOUR_RSA_KEY) .catch(handleError); // bazaar is not installed or what?! } componentWillUnmount() { bazaar.disconnect(); } async someButtonHandler() { const purchaseResult = await bazaar.purchaseProduct(productId); console.log(purchaseResult.purchaseToken); } } ``` -------------------------------- ### Usage in Functional Components Source: https://github.com/cafebazaar/react-native-poolakey/blob/main/README.md Demonstrates how to use the useBazaar hook in React Native functional components to access the payment SDK, including initiating purchases. ```javascript import { useBazaar } from '@cafebazaar/react-native-poolakey'; // ... function MyComponent() { const bazaar = useBazaar(RSA_KEY); // ... const someHandler = async () => { const purchaseResult = await bazaar.purchaseProduct(productId); console.log(purchaseResult.purchaseToken); }; // ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.