### Get App Info Example Source: https://github.com/stripe/stripe-react-native/blob/master/example-stripe-connect/API_DOCUMENTATION.md Example of how to use the `appInfo` method to fetch application details and handle potential errors. ```typescript import { APIError } from './api/StripeConnectAPI'; try { const appInfo = await client.appInfo(); console.log('Publishable Key:', appInfo.publishable_key); console.log('Merchants:', appInfo.available_merchants); } catch (error) { if ((error as APIError).type === 'responseError') { console.error('API Error:', error.response.error); } else if ((error as APIError).type === 'networkError') { console.error('Network Error:', error.message); } else { console.error('Unknown Error:', error); } } ``` -------------------------------- ### Install Dependencies Source: https://github.com/stripe/stripe-react-native/blob/master/example-stripe-connect/README.md Run this command to install the necessary project dependencies. ```bash npm install ``` -------------------------------- ### isPlatformPaySupported example Source: https://github.com/stripe/stripe-react-native/blob/master/MIGRATING.md Replaced isGooglePaySupported with isPlatformPaySupported. ```diff - isGooglePaySupported(myParams); + isPlatformPaySupported({googlePay: myParams}); ``` -------------------------------- ### Run example app on iOS Source: https://github.com/stripe/stripe-react-native/blob/master/CONTRIBUTING.md Starts the Metro bundler and then builds and runs the example app on an iOS simulator. ```sh # Terminal 1: Start Metro bundler yarn example start # Terminal 2: Build and run on simulator yarn example ios ``` -------------------------------- ### Run example app on Android Source: https://github.com/stripe/stripe-react-native/blob/master/CONTRIBUTING.md Starts the Metro bundler and then builds and runs the example app on an Android emulator or device. ```sh # Terminal 1: Start Metro bundler yarn example start # Terminal 2: Build and run on emulator/device yarn example android ``` -------------------------------- ### Start Expo Development Server Source: https://github.com/stripe/stripe-react-native/blob/master/example-stripe-connect/README.md Use this command to start the Expo development server for running the application. ```bash npm start ``` -------------------------------- ### Example App Info Response Source: https://github.com/stripe/stripe-react-native/blob/master/example-stripe-connect/API_DOCUMENTATION.md Example JSON object representing a successful response from the /app_info endpoint. ```json { "publishable_key": "pk_test_...", "available_merchants": [ { "display_name": "Example Merchant", "merchant_id": "acct_..." } ] } ``` -------------------------------- ### Create Account Session Example Source: https://github.com/stripe/stripe-react-native/blob/master/example-stripe-connect/API_DOCUMENTATION.md Example of how to use the `accountSession` method to create a session for a merchant and handle potential errors. ```typescript import { APIError } from './api/StripeConnectAPI'; try { const session = await client.accountSession('acct_123'); console.log('Client Secret:', session.client_secret); } catch (error) { if ((error as APIError).type === 'responseError') { console.error('API Error:', error.response.error); } } ``` -------------------------------- ### Install CocoaPods Source: https://github.com/stripe/stripe-react-native/blob/master/CONTRIBUTING.md Installs CocoaPods using Homebrew. ```sh brew install cocoapods ``` -------------------------------- ### Install SwiftLint Source: https://github.com/stripe/stripe-react-native/blob/master/CONTRIBUTING.md Installs SwiftLint using Homebrew, required for pre-commit hooks. ```sh brew install swiftlint ``` -------------------------------- ### Example Account Session Response Source: https://github.com/stripe/stripe-react-native/blob/master/example-stripe-connect/API_DOCUMENTATION.md Example JSON object for a successful response from the POST /account_session endpoint. ```json { "client_secret": "cas_..." } ``` -------------------------------- ### React Query Integration Examples Source: https://github.com/stripe/stripe-react-native/blob/master/example-stripe-connect/API_DOCUMENTATION.md Examples demonstrating how to integrate the Stripe Connect API client with React Query for data fetching. ```typescript import { useQuery } from '@tanstack/react-query'; import { createAPIClient } from '../api/StripeConnectAPI'; // Hook to fetch app info export function useAppInfo(baseURL: string) { return useQuery({ queryKey: ['appInfo', baseURL], queryFn: async () => { const client = createAPIClient(baseURL); return await client.appInfo(); }, }); } // Hook to fetch account session export function useAccountSession(merchantId: string, baseURL: string) { return useQuery({ queryKey: ['accountSession', merchantId, baseURL], queryFn: async () => { const client = createAPIClient(baseURL); return await client.accountSession(merchantId); }, }); } ``` -------------------------------- ### Retry pod install Source: https://github.com/stripe/stripe-react-native/blob/master/CONTRIBUTING.md Retries the 'pod install' command for the iOS example app, useful if CocoaPods CDN is flaky. ```sh cd example/ios && pod install --repo-update ``` -------------------------------- ### Install Maestro Source: https://github.com/stripe/stripe-react-native/blob/master/CONTRIBUTING.md Installs Maestro, a tool for end-to-end testing, using Homebrew. ```sh brew tap mobile-dev-inc/tap brew install maestro ``` -------------------------------- ### Confirm Setup Intent Source: https://github.com/stripe/stripe-react-native/blob/master/docs/tipsi-stripe-migration-guide.md Confirms a Setup Intent, typically used for setting up recurring payments or one-time payments where the final amount is determined later. ```APIDOC ## POST /confirmSetupIntent ### Description Confirms a Setup Intent for future payments. ### Method POST ### Endpoint /confirmSetupIntent ### Parameters #### Request Body - **clientSecret** (string) - Required - The client secret of the Setup Intent. - **type** (string) - Required - The type of payment method, e.g., 'Card'. - **billingDetails** (object) - Required - Billing details for the payment method. ### Request Example ```json { "clientSecret": "seti_12345_secret_67890", "type": "Card", "billingDetails": { "email": "test@example.com" } } ``` ### Response #### Success Response (200) - **setupIntent** (object) - The confirmed SetupIntent object. - **error** (object) - An error object if the confirmation failed. #### Response Example ```json { "setupIntent": { "id": "seti_12345", "status": "succeeded" }, "error": null } ``` ``` -------------------------------- ### Install patch-package for Automatic Patching Source: https://github.com/stripe/stripe-react-native/blob/master/patches/README.md Install `patch-package` as a development dependency to manage patches automatically. This is the recommended approach. ```bash npm install --save-dev patch-package ``` -------------------------------- ### Usage example Source: https://github.com/stripe/stripe-react-native/blob/master/README.md Example of how to integrate StripeProvider and use the useStripe hook for payment sheet. ```typescript // App.ts import { StripeProvider } from '@stripe/stripe-react-native'; function App() { return ( ); } // PaymentScreen.ts import { useStripe } from '@stripe/stripe-react-native'; export default function PaymentScreen() { const { initPaymentSheet, presentPaymentSheet } = useStripe(); const setup = async () => { const { error } = await initPaymentSheet({ merchantDisplayName: 'Example, Inc.', paymentIntentClientSecret: paymentIntent, // retrieve this from your server }); if (error) { // handle error } }; useEffect(() => { setup(); }, []); const checkout = async () => { const { error } = await presentPaymentSheet(); if (error) { // handle error } else { // success } }; return (