Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 2.12 KB

README.md

File metadata and controls

58 lines (38 loc) · 2.12 KB

Contoso Real Estate App: API Package

IMPORTANT: THIS REPOSITORY IS OPTIMIZED FOR CODESPACES AND TO WORK AS A SET OF COMPOSABLE APPS AND APIS. STANDALONE PACKAGE FUNCTIONALITY IS LIMITED AND MAY REQUIRE ADDITIONAL CONFIGURATION OR DEVELOPMENT

This package deploys an Azure Functions API that is used by the Contoso Real Estate App, with multiple endpoints, and serving multiple applications, that are part of the scenarios.

Pre-requisites

IMPORTANT: THIS SCENARIO IS TIGHTLY COUPLED WITH SCENARIO 3. SOME PARTS OF THIS FUNCTION APP MAY NOT WORK AS EXPECTED IF YOU DON'T FOLLOW THE INSTRUCTIONS IN SCENARIO 3. THIS FUNCTION APP QUERIES TWO DATABASES. THEY MAY NEED TO BE IN PLACE IN ORDER FOR THE ENDPOINTS TO WORK

If you want to run the API independently and locally, the following technologies must be in place:

Steps to start the API

  1. fork or clone the repository locally
  2. assumming you are in the folder containing your clone, go to the terminal and run
cd packages/api && npm install

Now you have all the dependencies installed for the API and can run

npm start

Stripe API integration

To test Stripe integration, you need to create a Stripe account and get the API keys.

Then, you need to add in your packages/api/.env file in the following content:

STRIPE_PUBLIC_KEY=<YOUR_STRIPE_PUBLIC_KEY>
STRIPE_SECRET_KEY=<YOUR_STRIPE_SECRET_KEY>
STRIPE_WEBHOOK_SECRET=<YOUR_STRIPE_WEBHOOK_SECRET>

To test the webhook integration, you need to install the Stripe CLI and run the following commands:

# Make sure the app is running first with `npm start`
stripe login
stripe listen --forward-to localhost:7071/api/checkout/complete

Then you can trigger events such as:

stripe trigger payment_intent.succeeded

To test payments, you can use the Stripe test cards.