Giter Site home page Giter Site logo

alexmacarthur / netlify-lambda-function-example Goto Github PK

View Code? Open in Web Editor NEW
97.0 4.0 31.0 982 KB

An example Netlify Lambda function that processes payments with Stripe.

Home Page: https://macarthur.me/posts/building-a-lambda-function-with-netlify

JavaScript 67.67% HTML 32.33%
netlify serverless lambda stripe stripe-checkout serverless-functions jamstack

netlify-lambda-function-example's Introduction

Netlify Lambda Function Example

Build Status

This is an example serverless function using Netlify's Lambda function service. It processes payments with Stripe, using Stripe Checkout.

Read the Post

A full walkthrough of this example can be found on my blog:

https://macarthur.me/posts/building-a-lambda-function-with-netlify

Install

Run npm install.

Usage

Run npm run dev to locally serve the page at http://localhost:8080, as well as the function at http://locahost:9000/purchase.

After both of these processes are running, you'll be able to process a test purchase with Stripe. For your card number, use 4242424242424242.

See the Example

https://netlify-lambda.netlify.com

License

MIT © Alex MacArthur

netlify-lambda-function-example's People

Contributors

alexmacarthur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

netlify-lambda-function-example's Issues

Process exited before result

When I try and process my payment it says charge failed. When I go to the file directly I get this error:

{"errorMessage":"RequestId: 0f83acda-87fa-4d37-92e7-2208f799fb33 Process exited before completing request"}

This is a link to the function:

https://spiroartdemo.netlify.com/.netlify/functions/purchase

When I look at my logs it says this:

11:40:44 PM: purchase invoked
11:40:44 PM: SyntaxError: Unexpected end of JSON input at JSON.parse () at t.handler (/var/task/purchase.js:1:15721)RequestId: 030c55fe-de2a-4630-9e25-c83ab186d01c Process exited before completing request

I’m not sure but I think perhaps it’s getting to this line:

const data = JSON.parse(event.body);

Even with an empty post request body (I.e the same as visiting the file directly) the code shouldn’t be failing in this way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.