|
| 1 | +# Using functions for Sending Email |
| 2 | + |
| 3 | +This lesson will walk through creating a function to process payments via [Stripe](https://www.stripe.com/). |
| 4 | + |
| 5 | +<!-- AUTO-GENERATED-CONTENT:START (TOC) --> |
| 6 | +- [Lesson Steps](#lesson-steps) |
| 7 | +- [Complete code](#complete-code) |
| 8 | +<!-- AUTO-GENERATED-CONTENT:END --> |
| 9 | + |
| 10 | +## Lesson Steps |
| 11 | + |
| 12 | +<!-- AUTO-GENERATED-CONTENT:START (GENERATE_LESSONS_STEPS)--> |
| 13 | +1. Create a `netlify.toml` file in your project. |
| 14 | + |
| 15 | + The `netlify.toml` file is where we configure how the site builds and where your serverless functions live. |
| 16 | + |
| 17 | +2. In `netlify.toml`, add a `[build]` section and add `publish` and `functions` values |
| 18 | + |
| 19 | +3. We need to create this site in Netlify |
| 20 | + |
| 21 | + Open your terminal and run the following command: |
| 22 | + |
| 23 | + ```bash |
| 24 | + netlify init |
| 25 | + ``` |
| 26 | + |
| 27 | + Choose manual deployments |
| 28 | + |
| 29 | +5. After configuring your redirect, its time to deploy |
| 30 | + |
| 31 | + Open your terminal and run the following command: |
| 32 | + |
| 33 | + ```bash |
| 34 | + netlify deploy -p |
| 35 | + ``` |
| 36 | + |
| 37 | +6. Invoke the function to ensure it's working properly |
| 38 | +
|
| 39 | + Visit your site and the URL https://your-site-url.netlify.com/.netlify/functions/redirect |
| 40 | +
|
| 41 | + It should redirect you to a new location. |
| 42 | +<!-- AUTO-GENERATED-CONTENT:END --> |
| 43 | +
|
| 44 | +<!-- SCROLL UP FOR STEPS --> |
| 45 | +
|
| 46 | +<!-- Step 1. Create a `netlify.toml` file in your project. |
| 47 | +
|
| 48 | + The `netlify.toml` file is where we configure how the site builds and where your serverless functions live. |
| 49 | +
|
| 50 | +--> |
| 51 | +
|
| 52 | +<!-- Step 3. We need to create this site in Netlify |
| 53 | +
|
| 54 | + Open your terminal and run the following command: |
| 55 | +
|
| 56 | + ```bash |
| 57 | + netlify init |
| 58 | + ``` |
| 59 | +
|
| 60 | + Choose manual deployments |
| 61 | +--> |
| 62 | +
|
| 63 | +<!-- Step 5. After configuring your redirect, its time to deploy |
| 64 | +
|
| 65 | + Open your terminal and run the following command: |
| 66 | +
|
| 67 | + ```bash |
| 68 | + netlify deploy -p |
| 69 | + ``` |
| 70 | +--> |
| 71 | +
|
| 72 | +<!-- Step 6. Invoke the function to ensure it's working properly |
| 73 | + |
| 74 | + Visit your site and the URL https://your-site-url.netlify.com/.netlify/functions/redirect |
| 75 | + |
| 76 | + It should redirect you to a new location. |
| 77 | + |
| 78 | +--> |
| 79 | + |
| 80 | + |
| 81 | +<!-- AUTO-GENERATED-CONTENT:START (README_BOTTOM) --> |
| 82 | +## Complete code |
| 83 | + |
| 84 | +If you need help or get stuck refer to the completed code of this lesson |
| 85 | + |
| 86 | +[View Complete Code](https://github.com/DavidWells/netlify-functions-workshop/tree/master/lessons-code-complete/use-cases/6-scraping) |
| 87 | +<!-- AUTO-GENERATED-CONTENT:END --> |
| 88 | + |
| 89 | + |
| 90 | +## Additional Resources |
| 91 | + |
| 92 | +- [Serverless User Engagement with AWS Lambda, SendGrid, BadgeUp and Node.js](https://codeburst.io/serverless-user-engagement-with-aws-lambda-sendgrid-badgeup-and-node-js-53cdc4fa1ddd) |
| 93 | +- [Sendgrid Send HTML Email](https://github.com/BadgeUp/badgeup-serverless-email-demo/blob/a686df908d77713271142dbae285f322db670969/index.js) |
0 commit comments