Skip to content

Commit fe47829

Browse files
authored
Merge pull request #808 from Lemoncode/feature/stripe-update-xvi
Stripe update XVI edition
2 parents fbc0c86 + be7de71 commit fe47829

32 files changed

+709
-193
lines changed

04-frameworks/07-pasarelas/00-base/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"sourceMap": true,
99
"noLib": false,
1010
"allowJs": true,
11-
"suppressImplicitAnyIndexErrors": true,
1211
"skipLibCheck": true,
1312
"esModuleInterop": true,
1413
"baseUrl": "./src"
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# Express Base
1+
# Stripe Checkout
22

33
[🇪🇸 Versión Español](./README_es.md)
4-
5-
Project startup:
6-
7-
- Express installed and configured.
8-
- Static files configured.
9-
- API end points configured.
10-
- Environment variables support configured.

04-frameworks/07-pasarelas/01-stripe-checkout/README_es.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,46 @@
22

33
[🇬🇧 English version](./README.md)
44

5-
# Que vamos a cubrir
5+
## Que vamos a cubrir
66

7-
Vamos a configurar el kiosko de stripe (checkout) para hacer una compra (sin notificación a servidor, eso lo veremos en el siguiente ejemplo).
7+
Vamos a configurar el checkout de Stripe para hacer una compra (sin notificación a servidor, eso lo veremos en el siguiente ejemplo).
88

9-
# Pasos
9+
## Pasos
1010

1111
- Definimos un fichero de variables de entorno en local:
1212

13-
_./env_
13+
_./env_:
1414

1515
```env
1616
NODE_ENV=development
1717
PORT=8081
1818
```
1919

20+
- Instalamos las dependencias:
21+
22+
```bash
23+
npm install
24+
```
25+
2026
- Podemos arrancar el proyecto y ver que hay en el boiler plate:
2127

2228
```bash
2329
npm start
2430
```
2531

26-
en http://localhost:8081 tenemos la página home
32+
en <http://localhost:8081> tenemos la página home
2733

28-
en http://localhost:8081/api tenemos un endpoint que devuelve datos
34+
en <http://localhost:8081/api> tenemos un endpoint que devuelve datos
2935

30-
- Vamos a instalar la librería de servidor de stripe (esta ya trae los typings incorporados):
36+
- Vamos a parar la ejecución e instalar la librería de servidor de Stripe (esta ya trae los typings incorporados):
3137

3238
```bash
33-
npm install stripe --save
39+
npm i stripe
3440
```
3541

3642
- Creamos una hoja de estilo para que nuestras páginas tengan buena pinta (la del ejemplo de Stripe):
3743

38-
_./src/static/style.css_
44+
_./src/static/style.css_:
3945

4046
```css
4147
body {
@@ -122,7 +128,7 @@ h5 {
122128

123129
- Vamos a crear la maquetacíon de la página (reemplazamos el contenido del fichero completo)
124130

125-
_./static/index.html_
131+
_./static/index.html_:
126132

127133
```html
128134
<!DOCTYPE html>
@@ -150,7 +156,7 @@ _./static/index.html_
150156
</html>
151157
```
152158

153-
- Vamos a probar que se muestra la ventana aunque esta no tendrá funcionalidad (abrimos nuestro browser favorito y navegamos a http://localhost:8081).
159+
- Vamos a probar que se muestra la ventana aunque esta no tendrá funcionalidad (abrimos nuestro browser favorito y navegamos a <http://localhost:8081>).
154160

155161
```bash
156162
npm start
@@ -169,7 +175,7 @@ npm start
169175
Para este ejemplo vamos a usar una clave genérica de stripe
170176
(Chequear [este enlace](https://stripe.com/docs/checkout/quickstart?lang=node#init-stripe) para ver si hay una clave diferente):
171177

172-
_./.env_
178+
_./.env_:
173179

174180
```diff
175181
NODE_ENV=development
@@ -179,7 +185,7 @@ PORT=8081
179185

180186
Y enlazarla a nuestro fichero de constantes:
181187

182-
_./env.constants.ts_
188+
_./env.constants.ts_:
183189

184190
```diff
185191
export const envConstants = {
@@ -192,7 +198,7 @@ export const envConstants = {
192198
- Y en el lado de los endpoints vamos a traernos la librería
193199
de servidor de stripe, como vamos a usar el import en modo genérico, vamos a configurar esto en nuetro tsconfig
194200

195-
_./tsconfig.json_
201+
_./tsconfig.json_:
196202

197203
```diff
198204
{
@@ -206,7 +212,7 @@ _./tsconfig.json_
206212
"noLib": false,
207213
"allowJs": true,
208214
"suppressImplicitAnyIndexErrors": true,
209-
+ "allowSyntheticDefaultImports": true,
215+
+ "allowSyntheticDefaultImports": true,
210216
"skipLibCheck": true,
211217
"esModuleInterop": true,
212218
"baseUrl": "./src"
@@ -217,13 +223,13 @@ _./tsconfig.json_
217223

218224
- Vamos ahora a nuestro fichero de _api_ e importarnos Stripe, configurandolo con la cuenta que acabamos de introducir en nuestra variable de entorno.
219225

220-
_./src/api.ts_
226+
_./src/api.ts_:
221227

222228
```diff
223229

224230
import { Router } from 'express';
225231
+ import Stripe from 'stripe';
226-
+ import {envConstants} from './env.constants';
232+
+ import { envConstants } from './env.constants';
227233

228234
+ // https://github.com/stripe/stripe-node#usage-with-typescript
229235
+ const stripe = new Stripe(envConstants.STRIPE_SECRET, {
@@ -245,7 +251,7 @@ api.get('/', async (req, res) => {
245251
- Le indicamos lo que cuesta.
246252
- Le indicamos la dirección de ok y ko (transacción completada con éxito, o transacción errónea)
247253

248-
_./src/api.ts_
254+
_./src/api.ts_:
249255

250256
```diff
251257
api.get('/', async (req, res) => {
@@ -281,7 +287,7 @@ api.get('/', async (req, res) => {
281287

282288
- Vamos a definir la página de exito y la de error:
283289

284-
_./src/static/success.html_
290+
_./src/static/success.html_:
285291

286292
```html
287293
<html>
@@ -300,7 +306,7 @@ _./src/static/success.html_
300306
</html>
301307
```
302308

303-
_./src/static/error.html_
309+
_./src/static/error.html_:
304310

305311
```html
306312
<html>
@@ -325,7 +331,7 @@ _./src/static/error.html_
325331
- Redirigimos a la pasarela de Stripe.
326332
- Stripe ya tiene el mando, nos redirigirá a la página de success o de cancel según se complete la operación.
327333

328-
_./src/static/index.html_
334+
_./src/static/index.html_:
329335

330336
```diff
331337
<!DOCTYPE html>

04-frameworks/07-pasarelas/01-stripe-checkout/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"sourceMap": true,
99
"noLib": false,
1010
"allowJs": true,
11-
"suppressImplicitAnyIndexErrors": true,
1211
"allowSyntheticDefaultImports": true,
1312
"skipLibCheck": true,
1413
"esModuleInterop": true,
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Express Base
1+
# Stripe Notifications
22

33
[🇪🇸 Versión Español](./README_es.md)
4-
5-
wip... if you want to contribute and port README_es.md into english you are more than welcome :)

0 commit comments

Comments
 (0)