-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/simplified version #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Updated `emitPaymentEvent` in `PlugpagEventEmitter.kt` to include a custom message parameter for better event logging. - Refactored `App.tsx` to utilize the new event emission structure, displaying real-time payment event updates. - Removed deprecated `doPaymentWithEvents` function and integrated its functionality into the standard `doPayment` method. - Simplified payment flow management by eliminating the `usePaymentFlow` hook. - Added a new function `generatePixQRCode` for generating PIX QR codes. - Cleaned up unused styles and components in the UI for better readability and performance.
…d update related references
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR simplifies the React Native PlugPag Nitro library by removing complex payment flow features and consolidating functionality into a more streamlined API. The changes focus on providing essential payment processing capabilities with real-time event monitoring while removing advanced workflow management features.
- Removes the
doPaymentWithEventsfunction and consolidates event handling into the maindoPaymentfunction - Simplifies the React hooks API by replacing
useTransactionPaymentEventwithuseTransactionEventand removingusePaymentFlow - Eliminates helper functions, payment presets, and React Native configuration files to reduce API surface area
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/index.tsx | Major API simplification removing payment flow hooks, helper functions, and payment presets |
| src/PlugpagNitro.nitro.ts | Removes doPaymentWithEvents interface definition |
| react-native.config.js | Completely removes React Native configuration file |
| example/src/App.tsx | Updates example app to use simplified API with basic payment functions |
| android/.../PlugpagNitro.kt | Consolidates payment methods by removing separate doPayment implementation |
| android/.../PlugpagEventEmitter.kt | Enhances event emitter with better logging and custom message support |
| README.md | Comprehensive documentation update reflecting the simplified API |
Comments suppressed due to low confidence (1)
example/src/App.tsx:127
- [nitpick] Function name uses inconsistent casing 'PIX' compared to other payment functions which use camelCase. Should be 'handlePixPayment' for consistency.
const handlePIXPayment = async () => {
| Alert.alert( | ||
| '✅ Pagamento Aprovado', | ||
| `Transação PIX realizada com sucesso!\n\nValor: ${formatCurrency(2500)}\nCódigo: ${result.transactionCode}\nNSU: ${result.hostNsu}` | ||
| `Transação realizada com sucesso!\nCódigo: ${result.transactionCode}\nValor: R$ 25,00` |
Copilot
AI
Jul 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded amount display (R$ 25,00) doesn't match the actual payment amount (R$ 15,00) used in the PIX payment function. This will show incorrect amount information to users.
| `Transação realizada com sucesso!\nCódigo: ${result.transactionCode}\nValor: R$ 25,00` | |
| `Transação realizada com sucesso!\nCódigo: ${result.transactionCode}\nValor: R$ ${(result.amount / 100).toFixed(2).replace('.', ',')}` |
| }, []); | ||
|
|
||
| return { | ||
| ...paymentEvent, |
Copilot
AI
Jul 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return statement uses an object literal instead of the typed return that was removed. This creates inconsistency with the function's return type annotation which expects PaymentEvent & { resetEvent: () => void }.
| ...paymentEvent, | |
| code: paymentEvent.code, | |
| message: paymentEvent.message, |
| val params = Arguments.createMap().apply { | ||
| putDouble("code", code) | ||
| putString("message", message) | ||
| putString("customMessage", customMessage ?: "") |
Copilot
AI
Jul 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing an empty string for null customMessage instead of null itself changes the API contract. JavaScript consumers expecting null/undefined will receive an empty string, which could break conditional logic checking for the presence of customMessage.
| putString("customMessage", customMessage ?: "") | |
| putString("customMessage", customMessage) |
This pull request introduces significant changes to the
PlugpagNitromodule, focusing on simplifying the payment flow, removing redundant methods, and improving event handling. The most notable updates include the consolidation of payment methods, the removal of thedoPaymentWithEventsmethod, and enhancements to the event listener interface. Additionally, unused helper functions and presets were removed to streamline the codebase.Event Handling Enhancements:
PlugpagEventEmitterto save an instance for emitting events and improved logging foremitPaymentEventto handle null instances gracefully (PlugpagEventEmitter.kt, [1] [2].Payment Flow Simplification:
doPaymentWithEventsmethod and consolidated its functionality into the existingdoPaymentmethod, which now includes built-in event handling (PlugpagNitro.kt, [1];index.tsx, [2] [3].useTransactionEventhook to include aresetEventmethod, replacing the olderuseTransactionPaymentEventhook (index.tsx, [1] [2].Codebase Cleanup:
isTransactionSuccessful,getTransactionError) and payment presets (PaymentPresets) to reduce clutter and improve maintainability (index.tsx, src/index.tsxL304-L356).usePaymentFlowhook, as its functionality is no longer required after the payment flow simplification (index.tsx, src/index.tsxL197-L258).Configuration Updates:
react-native.config.jsfile, as it is no longer necessary for module configuration (react-native.config.js, react-native.config.jsL1-L13).TypeScript Interface Adjustments:
doPaymentWithEventsmethod from thePlugpagNitroTypeScript interface to align with the updated API (PlugpagNitro.nitro.ts, src/PlugpagNitro.nitro.tsL186-L204).