feat: integrate Stripe SDK for PaymentIntent creation#69
Open
guangningsun wants to merge 1 commit into
Open
Conversation
- Add stripe npm package (v16)
- Rewrite paymentService.js to use real Stripe SDK instead of stub
- Add initStripe(secretKey, stripeInstance) for DI/testability
- Validate payload.amount (required, positive integer) before API call
- Return {paymentId, clientSecret, amount, currency, provider}
- Pass through Stripe error messages unchanged
- Add payment.test.js with 8 unit tests covering:
- Validation (missing/zero/negative/non-numeric amount)
- Correct PaymentIntent field mapping
- Default currency to 'usd'
- Error message passthrough
Closes SecureBananaLabs#1
Signed-off-by: sunguangning <sun-guangning@126.com>
9 tasks
Code ReviewPR: feat: integrate Stripe SDK for PaymentIntent creation by @guangningsun
Wallet: Code review for SecureBananaLabs bug-bounty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the stub
createPaymentIntentimplementation with a real Stripe SDK integration.Changes
stripenpm package (v16) toapps/api/package.jsonpaymentService.js: Replace fakepay_${Date.now()}ID generation with realstripe.paymentIntents.create()callinitStripe(secretKey, stripeInstance)for dependency injection and testabilitypayload.amount(required, positive integer) before making any API call{ paymentId, clientSecret, amount, currency, provider }— maps directly from Stripe'sPaymentIntentobjectStripeCardError, etc.) are caught and re-thrown with the original message preservedAcceptance Criteria
stripenpm package installed withSTRIPE_SECRET_KEYenv varpayload.amountvalidated (required, positive integer) with descriptive errorcurrencydefaults to"usd"when not providedstripe.paymentIntents.create({ amount, currency })call madeclientSecret(mapped frompaymentIntent.client_secret) andpaymentId(mapped frompaymentIntent.id)pay_${Date.now()}id generation removedpaymentIntents.create()Test Results
PR closes: SecureBananaLabs/bug-bounty#1
/bounty $350