Skip to content

An example of Netlify Lambda functions that process payment with Braintree payment provider

Notifications You must be signed in to change notification settings

nadirbad/netlify-functions-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Netlify Lambda Function example

This is an example of serverless AWS Lambda Function on Netlify and implementation of Braintree payment Braintree Simple Server. We can easily use Lambda function to implement simple Node.js server.

Read the tutorial

You can find full tutorial on my blog post.

Install

npm install

Configure

  1. Setup Braintree Sandbox environment for testing Sandbox
  2. Create .env file in root of project and fill it in with your API credentials. Here is the content of .env file:
BT_ENVIRONMENT = "sandbox"
BT_MERCHANT_ID = "XXXXXXX"
BT_PUBLIC_KEY = "XXXXXXX"
BT_PRIVATE_KEY = "XXXXXXX"

Serve and test Lambda functions locally

npm run dev

netlify-lambda starts server on http://localhost:9000/ and there are two functions you need:

1. Generate a client token

curl -X GET http://localhost:9000/braintree-get-token

2. Create a transaction

You can create a transaction using an amount and the nonceFromTheClient.

curl -X POST \
  http://localhost:9000/braintree-create-transaction \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{ "payment_method_nonce": "fake-valid-nonce",	"amount": 10.0 }'

See the Live Functions

Netlify Status

https://netlify-lambda-braintree.netlify.com/

License

MIT © Nadir Badnjevic

About

An example of Netlify Lambda functions that process payment with Braintree payment provider

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published