Skip to content
An example of Netlify Lambda functions that process payment with Braintree payment provider
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
functions
lib
.gitignore
README.md
netlify.toml
package.json
yarn.lock

README.md

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

yarn 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

yarn 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

You can’t perform that action at this time.