{"id":50946077,"url":"https://github.com/globalpayments-samples/save-and-reuse-payment-methods","last_synced_at":"2026-06-17T20:07:30.703Z","repository":{"id":320451036,"uuid":"1069255275","full_name":"globalpayments-samples/save-and-reuse-payment-methods","owner":"globalpayments-samples","description":"One-click payment system with Global Payments customer vault. Secure payment method storage, multi-use token creation, and instant checkout.","archived":false,"fork":false,"pushed_at":"2026-05-26T19:37:44.000Z","size":226,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-26T21:21:37.295Z","etag":null,"topics":["checkout","customer-vault","ecommerce","global-payments","lang-dotnet","lang-java","lang-php","one-click-payment","payment-methods","sdk","stored-payments","token-management"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/globalpayments-samples.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,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-10-03T16:32:47.000Z","updated_at":"2026-05-26T19:37:46.000Z","dependencies_parsed_at":"2025-10-23T22:23:00.363Z","dependency_job_id":"4d6b570b-aa3f-42fb-aa43-93a58d69ba4a","html_url":"https://github.com/globalpayments-samples/save-and-reuse-payment-methods","commit_stats":null,"previous_names":["globalpayments-samples/save-and-reuse-payment-methods"],"tags_count":0,"template":false,"template_full_name":"globalpayments-samples/starter-template","purl":"pkg:github/globalpayments-samples/save-and-reuse-payment-methods","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globalpayments-samples%2Fsave-and-reuse-payment-methods","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globalpayments-samples%2Fsave-and-reuse-payment-methods/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globalpayments-samples%2Fsave-and-reuse-payment-methods/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globalpayments-samples%2Fsave-and-reuse-payment-methods/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/globalpayments-samples","download_url":"https://codeload.github.com/globalpayments-samples/save-and-reuse-payment-methods/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globalpayments-samples%2Fsave-and-reuse-payment-methods/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34463585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["checkout","customer-vault","ecommerce","global-payments","lang-dotnet","lang-java","lang-php","one-click-payment","payment-methods","sdk","stored-payments","token-management"],"created_at":"2026-06-17T20:07:29.749Z","updated_at":"2026-06-17T20:07:30.695Z","avatar_url":"https://github.com/globalpayments-samples.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Save and Reuse Payment Methods System\n\nA comprehensive multi-language demonstration of multi-use one-click payment processing using the Global Payments SDK. This example showcases secure payment method storage, multi-use token creation with integrated customer data, and streamlined payment processing across multiple programming languages.\n\n## 🚀 Features\n\n### Core Payment Capabilities\n- **Multi-Use Token Creation** - Convert single-use tokens to stored payment tokens with customer data integration\n- **Payment Method Management** - Store, retrieve, edit, and manage customer payment methods securely\n- **One-Click Payment Processing** - Process immediate charges ($25) using stored payment methods\n- **Customer Data Integration** - Associate billing information directly with payment tokens\n- **Real-Time Processing** - Immediate transaction processing with live API integration\n\n### Development \u0026 Testing\n- **Mock Mode Support** - Test payment flows with simulated responses without hitting live APIs\n- **Test Card Integration** - Built-in Global Payments test cards for development\n- **Comprehensive Web Interface** - Complete UI with payment method management and transaction processing\n- **Global Payments SDK Integration** - Secure tokenization using hosted payment fields\n\n### Technical Features\n- **Consistent API Structure** - Identical endpoints and functionality across all language implementations\n- **JSON-Based Storage** - Simple file-based persistence for payment methods and customer data\n- **Environment Configuration** - Secure credential management with .env files\n- **Health Monitoring** - System status endpoints for monitoring and debugging\n\n## 🌐 Available Implementations\n\nEach implementation provides identical functionality with language-specific best practices:\n\n| Language | Framework | Requirements | Status |\n|----------|-----------|--------------|--------|\n| Language | Framework | Requirements | Status |\n|----------|-----------|--------------|--------|\n| **[PHP](./php/)** - ([Preview](https://githubbox.com/globalpayments-samples/save-and-reuse-payment-methods/tree/main/php)) | Native PHP | PHP 7.4+, Composer | ✅ Complete |\n| **[Java](./java/)** - ([Preview](https://githubbox.com/globalpayments-samples/save-and-reuse-payment-methods/tree/main/java)) | Jakarta EE | Java 11+, Maven | ✅ Complete |\n| **[.NET](./dotnet/)** - ([Preview](https://githubbox.com/globalpayments-samples/save-and-reuse-payment-methods/tree/main/dotnet)) | ASP.NET Core | .NET 9.0+ | ✅ Complete |\n\n## 🏗️ Architecture Overview\n\n### Token Lifecycle\n\n```mermaid\nsequenceDiagram\n    participant B as Browser\n    participant GP_JS as globalpayments.js\n    participant S as Backend\n    participant GP as GP API\n\n    B-\u003e\u003eS: GET /config\n    S--\u003e\u003eB: { publicApiKey }\n    B-\u003e\u003eGP_JS: Initialize hosted payment fields\n    B-\u003e\u003eGP_JS: Customer enters card details\n    GP_JS-\u003e\u003eGP: Tokenize card (PCI-compliant)\n    GP--\u003e\u003eB: single-use token\n\n    B-\u003e\u003eS: POST /payment-methods (single-use token + billing info)\n    S-\u003e\u003eGP: Convert to multi-use token\n    GP--\u003e\u003eS: { paymentMethodToken }\n    S--\u003e\u003eB: Payment method saved\n\n    Note over B,GP: Later — charge a saved method\n    B-\u003e\u003eS: POST /charge (paymentMethodToken)\n    S-\u003e\u003eGP: card.charge(amount) with stored token\n    GP--\u003e\u003eS: { transactionId, status: \"CAPTURED\" }\n    S--\u003e\u003eB: Charge successful\n```\n\n### Frontend Architecture\n- **Global Payments SDK Integration** - Secure tokenization with hosted payment fields\n- **Responsive Web Interface** - Complete payment management UI\n- **Test Card Helper** - Integrated Global Payments test cards\n- **Real-Time Validation** - Client-side form validation and error handling\n\n### Backend Architecture\n- **RESTful API Design** - Consistent endpoints across all implementations\n- **Multi-Use Token Creation** - Secure conversion of single-use to stored payment tokens\n- **Customer Data Storage** - Integrated billing information with payment methods\n- **Mock Mode Capability** - Simulated responses for development and testing\n\n### API Endpoints\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| `GET` | `/health` | System health check and status |\n| `GET` | `/config` | Frontend configuration (public API key, mock mode) |\n| `GET` | `/payment-methods` | Retrieve all stored payment methods |\n| `POST` | `/payment-methods` | Create new payment method or edit existing |\n| `POST` | `/charge` | Process $25 charge using stored payment method |\n| `GET` | `/mock-mode` | Get current mock mode status |\n| `POST` | `/mock-mode` | Toggle mock mode on/off |\n\n## 🚀 Quick Start\n\n### Prerequisites\n- Global Payments account with API credentials ([Sign up here](https://developer.globalpayments.com/))\n- Development environment for your chosen language\n- Package manager (npm, composer, maven, dotnet, go mod)\n\n### Setup Instructions\n\n1. **Clone the repository**\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd save-and-reuse-payment-methods\n   ```\n\n2. **Choose your implementation**\n   ```bash\n   cd dotnet  # or java, php\n   ```\n\n3. **Configure environment**\n   ```bash\n   cp .env.sample .env\n   # Edit .env with your Global Payments GP API credentials:\n   # GP_API_APP_ID=your_app_id\n   # GP_API_APP_KEY=your_app_key\n   # GP_API_ENVIRONMENT=sandbox\n   ```\n\n4. **Install dependencies and run**\n   ```bash\n   ./run.sh\n   ```\n\n   Or manually for each language:\n   ```bash\n   # .NET\n   dotnet restore \u0026\u0026 dotnet run\n\n   # Java\n   mvn clean compile cargo:run\n\n   # PHP\n   composer install \u0026\u0026 php -S localhost:8000\n   ```\n\n5. **Access the application**\n   Open [http://localhost:8000](http://localhost:8000) in your browser\n\n## 🧪 Development \u0026 Testing\n\n### Mock Mode\nEach implementation includes a mock mode that allows you to:\n- Test payment flows without live API calls\n- Use simulated responses for consistent testing\n- Develop and debug without API costs\n- Toggle between mock and live modes via the UI\n\n### Test Cards\nBuilt-in Global Payments test cards:\n- **Visa**: 4012002000060016\n- **MasterCard**: 2223000010005780, 5473500000000014\n- **Discover**: 6011000990156527\n- **American Express**: 372700699251018\n- **JCB**: 3566007770007321\n\nAll test cards use:\n- **Expiry**: 12/2028\n- **CVV**: 123 (1234 for Amex)\n\n### Customer Data\nThe system includes pre-filled customer information for testing:\n- **Name**: Jane Doe\n- **Email**: jane.doe@example.com\n- **Phone**: 5551112222\n- **Address**: 1 Example Way, Jeffersonville, IN 47130, USA\n\n## 💳 Payment Flow\n\n### Adding Payment Methods\n1. **Customer Information** - Collect name, email, phone, and billing address\n2. **Payment Details** - Secure tokenization using Global Payments SDK\n3. **Multi-Use Token Creation** - Convert single-use token to multi-use token with customer data\n4. **Storage** - Save payment method with optional nickname and default status\n\n### Processing Payments\n1. **Method Selection** - Choose from stored payment methods\n2. **One-Click Processing** - Immediate $25 charge processing\n3. **Real-Time Results** - Live transaction status and details\n4. **Transaction History** - Complete transaction information display\n\n## 🔧 Customization\n\n### Extending Functionality\nEach implementation provides a solid foundation for:\n- **Custom Payment Amounts** - Modify charge amounts and currency\n- **Additional Payment Types** - Add authorization/capture, refunds, voids\n- **Enhanced Customer Management** - Expand customer data fields\n- **Subscription Processing** - Recurring payment capabilities\n- **Advanced Reporting** - Transaction history and analytics\n\n### Production Considerations\nBefore deploying to production:\n- **Security**: Implement proper input validation and sanitization\n- **Logging**: Add comprehensive logging and monitoring\n- **Error Handling**: Enhance error handling and user feedback\n- **Database**: Replace JSON storage with production database\n- **Authentication**: Add user authentication and authorization\n- **Compliance**: Ensure PCI DSS compliance measures\n\n## Security Considerations\n\n- **PCI Compliance** — Drop-In UI handles card data client-side; your server never sees raw card numbers\n- **Token-Based Processing** — All payments use multi-use tokens, not card data\n- **Credential Isolation** — Store API keys in `.env` files, never commit to version control\n- **HTTPS Required** — Always use TLS in production environments\n- **Input Validation** — Validate and sanitize all user input server-side\n- **JSON Storage Limitation** — File-based storage is for demo only; use an encrypted database in production\n\n## 📚 Documentation\n\nEach language implementation includes detailed documentation:\n- **Setup Instructions** - Environment configuration and dependencies\n- **API Documentation** - Endpoint specifications and examples\n- **Code Structure** - File organization and architecture\n- **Troubleshooting** - Common issues and solutions\n- **Recent Updates** - Bug fixes and improvements\n\n## 🛠️ Recent Improvements\n\n### Cross-Language Consistency\n- ✅ **Unified API Structure** - Consistent endpoints across all implementations\n- ✅ **Payment Token Handling** - Fixed frontend/backend data structure alignment\n- ✅ **Customer Data Integration** - Standardized customer information collection\n- ✅ **Mock Mode Functionality** - Consistent testing capabilities\n\n### Bug Fixes \u0026 Enhancements\n- ✅ **Java**: Fixed compilation errors and response validation with Global Payments SDK\n- ✅ **.NET**: Fixed CAPTURED response validation and multi-use token creation\n- ✅ **PHP**: Implemented comprehensive GP API payment system\n- ✅ **All Languages**: Migrated from Portico to GP API configuration\n\n## 🤝 Contributing\n\nThis project serves as a comprehensive example for Global Payments SDK integration. When contributing:\n- Maintain consistency across all language implementations\n- Follow each language's best practices and conventions\n- Ensure thorough testing with both mock and live modes\n- Update documentation to reflect any changes\n\n## 📄 License\n\nThis project is provided as an educational example for Global Payments SDK integration. Please review the license file for specific terms and conditions.\n\n## Resources\n\n- [Global Payments Developer Portal](https://developer.globalpayments.com/)\n- [API Reference](https://developer.globalpayments.com/api/references-overview)\n- [Test Cards](https://developer.globalpayments.com/resources/test-cards)\n- [PHP SDK](https://github.com/globalpayments/php-sdk)\n- [Java SDK](https://github.com/globalpayments/java-sdk)\n- [.NET SDK](https://github.com/globalpayments/dotnet-sdk)\n\n## Community\n\n- 🌐 **Developer Portal** — [developer.globalpayments.com](https://developer.globalpayments.com)\n- 💬 **Discord** — [Join the community](https://discord.gg/myER9G9qkc)\n- 📋 **GitHub Discussions** — [github.com/orgs/globalpayments/discussions](https://github.com/orgs/globalpayments/discussions)\n- 📧 **Newsletter** — [Subscribe](https://www.globalpayments.com/en-gb/modals/newsletter)\n- 💼 **LinkedIn** — [Global Payments for Developers](https://www.linkedin.com/showcase/global-payments-for-developers/posts/?feedView=all)\n\nHave a question or found a bug? [Open an issue](https://github.com/globalpayments-samples/save-and-reuse-payment-methods/issues) or reach out at [communityexperience@globalpay.com](mailto:communityexperience@globalpay.com).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobalpayments-samples%2Fsave-and-reuse-payment-methods","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglobalpayments-samples%2Fsave-and-reuse-payment-methods","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobalpayments-samples%2Fsave-and-reuse-payment-methods/lists"}