-
Notifications
You must be signed in to change notification settings - Fork 63
Stripe API Endpoint
This procedure tests that the Payment Request button is properly hooked into the Stripe backend after you complete the initial integration.
- Create a Payment Intent Request. Call the
/create-payment-intent
endpoint in POST and send adonationAmount
variable in the body. - The Stripe API returns a
clientSecret
. Use this client secret in the Stripe UI package to create the transaction. - The Stripe UI package returns a response with the created transaction. Pass the transaction response to the
/create-transaction
endpoint via POST so that Amplify records the transaction in our database. - Show the user the corresponding success message on the UI.
STRIPE_SECRET_KEY
: sk_test_51IravfFqipIA40A3FOW6EzlXlJiXjL9V0FXKfb9n7cxh25Ww9QMA9aWwCzTSQscBOQFcB7s1TI6UCtW1JG83Hz1z000Sg2vSIr
Use this publishable key: pk_test_51IravfFqipIA40A3SI50i113zqo0M0Smy1hNa59eEYl15AbdCBhHQC4qd1lhxkgAYXyoFGkeZGDg4vYB8P76N7GW00bI6nvygJ
This test code is designed to test a route in an API by making a GET request to the endpoint and checking if the response is what is expected. However, the actual test case is skipped with the test.skip function, so it will not run until the skip is removed.
This test code is used to set up an Express.js application for testing an API endpoint and to define Jest testing configuration. The code includes the following components:
- Express Application Setup:
- It creates an Express application instance.
- It mounts an API router under the '/api' route.
- Jest Testing Configuration:
- It Utilizes Jest's testing framework for test case execution.
- After each test, it clears all Jest mocks to ensure a clean slate for each test.
- It defines a test suite for 'GET /api/...' to test an API endpoint.
- Inside the test suite, there's a placeholder test case (currently skipped) that checks if `true` is equal to `true`. This is a minimal placeholder test.
- Cleanup After All Tests:
- After all tests are completed, it introduces a 500-millisecond delay using `setTimeout` to avoid a Jest open handle error. This delay provides additional time for Jest to clean up resources.
- Home
- App Logic
- App Structure
- Getting Started
- Local Environment Setup
- Interacting with the Development Database
- User Background
- Features
- Data Structures
- API Quick Reference
- Single Campaign Mode (Beta)
- Front-end
- Components
- Pages
- State Management
- Amplify API reference (Database)
- Lob Mailing API integration
- Auth0 API Integration
- Stripe API integration
- Cicero API Integration
- Twilio API Integration