amplify
amplify copied to clipboard
[Test]: Stripe API integration tests
Payment/Donation
User stories:
- Constituent pays a default of 1.00 (close to a forever stamp) which offsets the use of APIs like Lob, Stripe, and Cicero to mail the letter
- Constituent can select a donation amount to support their cause further
- A progress bar creates a visual incentive of the goal to support
QA Files: In checkout.js for functions and checkout.test.js for tests
- [ ] Add tests for Payment Intents
- Copilot prompt: How can I handle errors or exceptions in the payment intent logic?
- [ ] Add tests for server side code
- Copilot prompt: How can I handle errors when making API requests in JavaScript?
- [ ] Add tests for Charges
Copilot prompt: Create tests in jest for createCharge
Context:
When using the Payment Intents API with Stripe’s client libraries and SDKs, ensure that:
- Authentication flows are triggered when required (use the regulatory test card numbers and PaymentMethods.)
- No authentication (default U.S. card): 4242 4242 4242 4242.
- Authentication required: 4000 0027 6000 3184.
- The PaymentIntent is created with an idempotency key to avoid erroneously creating duplicate PaymentIntents for the same purchase.
- Errors are caught and displayed properly in the UI.
Charges API When using the Charges API with Stripe’s client libraries and SDKs, ensure that:
- The card Element is passed correctly to createToken in your submit handler.
- In the response handler for createToken, card errors are handled and displayed properly.
- Only valid tokens are passed to your server as part of payment form submission.
Server-side code In your server-side code, ensure that:
- All requests are being made successfully. You may find it useful to view your account’s events and logs as you test your integration.
- All API errors are handled properly.
- Relevant webhooks are handled correctly.
cc: @charliegerard-stripe