CLI Reference
Availability
We're building functions with the same proven expertise and rock solid foundations you expect from
Braintree. Take a look at our documentation preview to get a jump start on what you'll make with
functions. Email
functions-requests@braintreepayments.com
to learn more.
Installation
Before installing the braintree-functions-cli, make sure you have
Node.js installed on your machine.
Note
Version
8.x or 10.x is
required. We recommend using a tool such as
nvm to manage node versions.
- bash
$ npm i -g @braintree/functions-clibtfns namespace available to you from the command line. If you would
prefer to not install this package globally, use the
npx command:
- bash
$ npx btfns <command>Uninstall
If installed globally:
- bash
$ npm uninstall -g @braintree/functions-cliOptions
| Option | Description |
|---|---|
| -v, --version | show installed version |
CLI Commands
| Command | Description |
|---|---|
| `deploy` | Deploy your function |
| `help` | Display help for btfns |
| `init` | Create a new function |
| `login` | Login to your Braintree account for deployment and testing |
| `logout` | Log out of your Braintree account |
| `ls` | List functions, events, or triggers |
| `package` | Package your function in order to publish to Braintree's function ecosystem |
| `publish` | Publish your function to share with others |
| `test` | Simulate function invocation to test your code before deployment |
| `generate-test-data` | Generate JSON files to mock expected payloads for testing |
deploy
Deploy your function.
- bash
$ btfns deploydeployOptions
| Option | Description |
|---|---|
| -h, --help | show command help |
| --production | deploys function to production environment |
help
Displays commands and version of your installation of btfns.
init
Create a new function.
- bash
$ btfns init MyFunction --template=dataExport --events=transaction.settledinitOptions
| Option | Description |
|---|---|
| -t, --template=templateType | creates configuration and javascript files for type. valid types: `dataExport`, `dataImport`, `paymentMethod` |
| -h, --help | show command help |
| -T, --triggers=trigger | triggers associated to the function, use `btfn ls --triggers` to see all |
| -e, --events=event | events associated to a `dataExport` function, use `btfns ls --events` to see all |
login
Login to a Braintree account.
- bash
$ btfns login -e sandbox -m merchantIdloginOptions
| Option | Description |
|---|---|
| -e, --environment | set environment |
| -h, --help | show command help |
| -m, --merchant | set merchant ID |
| -u, --user | set username |
logout
Logout of your Braintree account.
- bash
$ btfns logoutls
List functions, events, or triggers.
- bash
$ btfns ls --functions -e sandboxlsOptions
| Option | Description |
|---|---|
| -h, --help | show command help |
| -e, --environment | set environment |
| --functions | list functions deployed to your account |
| --triggers | list triggers available to be used by a function |
| --events | list events available to be used by a function |
package
Package and publish your function to share with others.
- bash
$ btfns package .packageOptions
| Option | Description |
|---|---|
| -h, --help | show command help |
publish
Package and publish your function to share with others.
- bash
$ btfns publish . -v 1.0.0publishOptions
| Option | Description |
|---|---|
| -h, --help | show command help |
| -v, --version | sets version of function |
test
Simulate function invocation to test your code before deployment. Depending on your template type
the appropriate payload will be sent to your function.
- bash
$ btfns test -p tests/sample.jsontestOptions
| Option | Description |
|---|---|
| -h, --help | See available options for the `test` command |
| -p, --test-payload | Path to a test `json` file with a pre-build payload |
generate-test-data
Generate JSON files to mock expected payloads for testing. Running this command will write a JSON
file to the __tests__ directory generated by your project.
- bash
$ btfns generate-test-data -o test/sample.jsongenerate-test-dataOptions
| Option | Description |
|---|---|
| -h, --help | See available options for the `test` command |
| -o, --output |
The name and path of the generated file (defaults to `tests/ |