Section 33: Using Third-Party APIs / Services - Adding Payments Via Stripe
The goals
๐ช๐ปWhat are "Services" & "APIs"?
โ๐ปIntroducing Stripe For Handling Payments
๐๐ปUsing Stripe In Our Online Shop
What are Services & APIs?
Services are just that: Services you can use in your projects / websites
- Packages like Axios or Express
- Google Maps API
- Google Analytics
- Stripe Payments
Expose "Actions" or "Endpoints" you can access from inside your code
=> API (Application Programming Interface)
An API is the bridge between our code and the code / actions provided by some service.
Why Services / APIs?
As a (Web) developer, you can't build all features on your own
Use paid or free third-party services / APIs to add certain features to your app
Or: Build a service / API that can be consumed by others
์ด ๋ชจ๋์ ์์ ๋ถ๋ถ์์ ์ธ๊ธํ๋ฏ์ด ์น์ฌ์ดํธ์ ์ถ๊ฐํ ์ ์๋ ์๋น์ค์ ํจํค์ง๊ฐ ๋ง์ด ์์ต๋๋ค.
์ธ์ ์๋น์ค๊ฐ ํ์ํ์ง(๊ทธ๋ฆฌ๊ณ ์ด๋ค ์๋น์ค๋ฅผ ์ฌ์ฉํด์ผ ํ๋์ง) ์ด๋ป๊ฒ ์ ์ ์์๊น์?
์ผ๋ฐ์ ์ผ๋ก ํน์ ๋ฌธ์ ์์ ์์ํฉ๋๋ค.- ์์: "์ ์น์ฌ์ดํธ์ ์ง๋๋ฅผ ํ์ํ๊ณ ์ถ์ต๋๋ค."
๊ทธ๋ฐ ๋ค์ ๋ค์ ๋จ๊ณ๋ก "์น ๊ฐ๋ฐ ์น์ฌ์ดํธ์์ ์ง๋ ํ์"์ ๊ฐ์ ๊ฒ์ ๊ฒ์ํ ์ ์์ต๋๋ค. ๊ฒ์ ๊ฒฐ๊ณผ์์ ๋์์ด ๋ ์ ์๋ ์๋น์ค ์น์ฌ์ดํธ ๋๋ ํผํ ์๋น์ค๋ฅผ ๊ฐ๋ฆฌํค๋ ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ/ํฌ๋ผ ํ ๋ก ์ ์ฐพ์์ผ ํฉ๋๋ค.
์ผ๋ฐ์ ์ธ ๋ฌธ์ ์ ์๋น์ค๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
โ ์ฌ์ฉ์์๊ฒ ์ด๋ฉ์ผ์ ๋ณด๋ด๊ณ ์ถ์ต๋๋ค => ์๋ฃจ์ : Mailchimp์ ๊ฐ์ ์๋น์ค๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค(๋ค๋ฅธ ์๋น์ค๋ ๋ง์ด ์์ต๋๋ค!). "send email api"์ ๊ฐ์ ๊ฒ์ ๊ฒ์ํ๋ฉด ํธ๋ฆญ์ ์ํํด์ผ ํฉ๋๋ค.
โ ์ฌ์ฉ์๊ฐ ๊ตฌ๊ธ/ํ์ด์ค๋ถ/์ ํ ๋ฑ์ ํตํด ๋ก๊ทธ์ธํ ์ ์๋๋ก ํ๊ณ ์ถ์ต๋๋ค(์: "์์ ๋ก๊ทธ์ธ") => ์๋ฃจ์ : "website add facebook login"๊ณผ ๊ฐ์ ํญ๋ชฉ์ ๊ฒ์ํฉ๋๋ค. => ๊ณต์ ๋ฌธ์ ์ค์์ ๋ค์ํ ๊ฒ์ ๊ฒฐ๊ณผ๋ฅผ ์ฐพ์ ์ ์์ด์. ํ์ด์ค๋ถ ์ ๊ณต ํ์ด์ง: https://developers.facebook.com/docs/facebook-login/
โ ์ ์น์ฌ์ดํธ์ ์ง๋๋ฅผ ํ์ํ๊ณ ์ถ์ต๋๋ค => ์ ์ฐธ์กฐ => ๋ค๋ฅธ ์ ๊ณต(์: OpenStreetMap)๋ ์์ง๋ง ๊ตฌ๊ธ ๋งต API/์๋น์ค ๋ฌธ์๋ฅผ ์ฐพ์ ์ ์์ ๊ฒ์ ๋๋ค.
โ ์ ์น์ฌ์ดํธ์ ์ ๋๋ฆฌ์คํฑ์ ์ถ๊ฐํด์ ์ฌ์ฉ์๊ฐ ์ด๋์์ ์๋์ง ๋ฑ์ ํ์ธํ๊ณ ์ถ์ต๋๋ค. => ์๋ฃจ์ : "website add analytics"์ ๊ฐ์ ๊ฒ์ => ๊ตฌ๊ธ ์ ๋๋ฆฌ์คํฑ ์น์ฌ์ดํธ ๋ฐ ๋ฌธ์ ์ค์์ ๋ค์ํ ๊ฒฐ๊ณผ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.
๋ฌผ๋ก ๊ฐ๋ฅํ ์๋๋ฆฌ์ค, ๋ฌธ์ ์ ์๋น์ค๋ ๋ฌดํํ์ง๋ง ์น ๊ฒ์์ ์ฌ๋ฌ๋ถ์ ์น๊ตฌ์ ๋๋ค!
์๋น์ค ์ฌ์ฉ๊ณผ ๊ด๋ จํ์ฌ ์๋น์ค๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์์ธํ ์ค๋ช ๋์ด ์๋ ํด๋น ๋ฌธ์์ ์๋น์ค์์ ์ ๊ณตํ๋ ๊ณต์ ๋ฌธ์๋ฅผ ํญ์ ์์ธํ ์ดํด๋ณด์์ผ ํฉ๋๋ค. ์ข ์ข ๊ณต์ ๋ฌธ์ ํ์ด์ง์๋ ์ ์ฉํ ์์ ๊ฐ ํฌํจ๋์ด ์์ต๋๋ค.