Thank you for your interest in contributing to React Native Pay! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Setup
- Project Structure
- Development Workflow
- AI Spec-Driven Development
- Code Style
- Testing
- Nitro Modules
- Pull Request Process
- What to Contribute
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/react-native-pay.git cd react-native-pay - Add the upstream remote:
git remote add upstream https://github.com/gmi-software/react-native-pay.git
- Node.js (v18 or higher)
- bun
- React Native development environment
- For iOS: Xcode and CocoaPods
- For Android: Android Studio and Android SDK
- Expo CLI (for running the example app)
# Install root dependencies
bun install
# Install package dependencies
cd package && bun install
# Install example app dependencies
cd ../example && bun install
# Generate Nitro bindings (required after cloning)
cd ../package
bun run specsThe example app in /example is used for testing and verification:
cd example
# iOS
npx expo prebuild
npx expo run:ios
# Android
npx expo prebuild
npx expo run:androidNote: Payment functionality requires real devices. Simulator/Emulator support is limited.
react-native-pay/
├── package/ # Main library package
│ ├── src/ # TypeScript source
│ │ ├── hooks/ # React hooks
│ │ ├── specs/ # Nitro Module specifications (*.nitro.ts)
│ │ ├── types/ # TypeScript type definitions
│ │ ├── utils/ # Utility functions
│ │ └── plugin/ # Expo config plugins
│ ├── ios/ # iOS native code (Swift)
│ ├── android/ # Android native code (Kotlin, C++)
│ ├── nitrogen/ # Generated Nitro bindings (do not edit)
│ └── package.json
├── example/ # Example Expo app for testing
└── README.md
git checkout main
git pull upstream main
git checkout -b feature/your-feature-nameUse descriptive branch names:
feature/add-shipping-addressfix/google-pay-error-handlingdocs/update-api-documentation
- Write clean, maintainable code
- Follow existing patterns and conventions
- Add JSDoc comments for public APIs
- Update types when adding new features
Before submitting a PR, ensure:
- TypeScript compiles without errors:
cd package && bun run typecheck - Linting passes:
cd package && bun run lint - Automated tests pass:
cd package && bun run test:ci - Example app runs on iOS (if applicable)
- Example app runs on Android (if applicable)
- Tested in both TEST and PRODUCTION modes (for payment features)
- Update
README.mdfor API changes - Add code examples for new features
- Update type definitions if needed
- Docs site (
docs/): The technical documentation is in thedocs/folder (Docusaurus, English). When you change public API, setup, or behavior, update the relevant page underdocs/docs/(e.g.api/use-payment-checkout.md,setup/ios-apple-pay.md). Runbun run docs:buildlocally to verify the site builds. The docs workflow runs only when a new tag is pushed (see.github/workflows/docs.yml), not on every PR.
This repository follows AI spec-driven development for important changes in package/.
The source of truth for architecture and behavior lives in .ai/specs/. Code and specs must evolve together.
- Always check for an existing relevant spec before implementing changes.
- For significant feature/API/architecture updates, update the matching spec in
.ai/specs/. - For new modules or major new features, create a new spec file.
- Keep each spec changelog updated with a dated entry.
- If you add a new spec file, update
.ai/specs/README.mdspecification table.
- New spec files must follow:
SPEC-{next-number}-{YYYY-MM-DD}-{kebab-title}.md - Follow the section guidance from
.ai/specs/README.mdand.ai/specs/AGENTS.md. - Include only applicable sections (for example: Overview, Architecture, API Contracts, Configuration, Changelog).
- Before coding
- Read the related spec in
.ai/specs/ - Confirm constraints, contracts, and assumptions
- Read the related spec in
- While implementing
- Keep notes on behavior/API/config changes that must be reflected in specs
- After implementation
- Update existing spec(s) or create a new one
- Add a changelog entry with date and summary
- Update
.ai/specs/README.mdif a new spec was created
Include spec changes in the same PR as the code change whenever possible. If specs are intentionally deferred, explain why in the PR description.
- Follow existing TypeScript patterns in the codebase
- Use TypeScript strict mode
- Prefer explicit types over
any - Export types from
src/types/index.ts
- Prettier is configured and runs automatically
- Use single quotes for strings
- Use 2 spaces for indentation
- No semicolons (as per project config)
- Files: camelCase for utilities, PascalCase for components/types
- Functions: camelCase
- Types/Interfaces: PascalCase
- Constants: UPPER_SNAKE_CASE
Add JSDoc comments for all public APIs:
/**
* Initiates a payment checkout flow.
* @param request - Payment request configuration
* @returns Promise resolving to payment result
* @throws {PaymentError} If payment fails or is cancelled
*/
export async function checkout(request: PaymentRequest): Promise<PaymentResult> {
// ...
}The library now includes automated tests using:
- Jest for unit tests
- React Native Testing Library for integration tests (hooks/components)
Run tests from the package/ workspace:
# Run all tests
cd package && bun run test
# Run tests in CI mode (single run, no watch)
cd package && bun run test:ci
# Run a single test file
cd package && bun run test -- src/hooks/__tests__/usePaymentCheckout.integration.test.tsAutomated coverage does not replace device verification for payment flows. Manual testing is still required:
- Test on Real Devices: Payment features require real iOS/Android devices
- Test Both Platforms: Verify changes work on both iOS and Android
- Test Both Environments: Use both TEST and PRODUCTION payment environments
- Test Error Cases: Verify error handling works correctly
- Unit and integration tests pass locally (
cd package && bun run test:ci) - Payment flow completes successfully
- Error handling works for invalid inputs
- UI components render correctly
- TypeScript types are correct
- No console errors or warnings
This project uses Nitro Modules for native bindings.
- Spec Files: Located in
package/src/specs/*.nitro.ts - Generated Code: The
package/nitrogen/directory contains generated bindings - do not edit manually - Regeneration: After changing any
*.nitro.tsfile, run:cd package bun run specs - Type Generation: The
specscommand generates both native bindings and TypeScript types
- Edit the
.nitro.tsspecification file - Run
bun run specsto regenerate bindings - Implement native code in Swift (iOS) or Kotlin (Android)
- Test thoroughly on both platforms
-
Sync with upstream:
git checkout main git pull upstream main git checkout your-branch git rebase main
-
Ensure all checks pass:
- TypeScript compilation
- Linting
- Automated tests
- Manual testing
-
Write a clear description:
- What changes were made
- Why the changes were needed
- How to test the changes
- Any breaking changes
## Summary
- Brief description of changes
- Key improvements or fixes
## Changes
- List of specific changes made
## Testing
- [ ] TypeScript compiles: `cd package && bun run typecheck`
- [ ] Linting passes: `cd package && bun run lint`
- [ ] Automated tests pass: `cd package && bun run test:ci`
- [ ] Tested on iOS (device)
- [ ] Tested on Android (device)
- [ ] Tested in TEST mode
- [ ] Tested in PRODUCTION mode
## Screenshots/Videos
(If applicable)
## Related Issues
Closes #(issue number)
## Breaking Changes
(If any, describe migration path)- PRs will be reviewed by maintainers
- Address feedback promptly
- Keep PRs focused and reasonably sized
- Be patient and respectful during reviews
- Documentation improvements
- Bug fixes
- Type improvements
- Example app enhancements
Check the Roadmap for planned features, or open an issue to discuss new features before implementing.
- Additional payment gateway support
- Performance optimizations
- Documentation examples
- Check existing issues to avoid duplicates
- Use the bug report template
- Include:
- Steps to reproduce
- Expected vs actual behavior
- Device/platform information
- Code snippets if relevant
- 📧 Email: support@gmi.software
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
Thank you for contributing to React Native Pay! 🎉