functions (Preview)

Advanced Topicsanchor

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.

Runtime Contextanchor

Environment Variablesanchor

You can provide your own environment variables in the generated config.yml file.

  1. yml
name: "MyFunction"
environmentVariables:
  "HTTP_TIMEOUT": 1000
  sandbox:
    "PAYMENT_URL": "https://sandbox.payments.service"
  production:
    "PAYMENT_URL: "https://payments.service"

Secretsanchor

context Argumentanchor

Your function will be invoked with a single argument. This argument (referred to as context) is a JavaScript Object which contains both the event data specific to the trigger as well as structured Braintree metadata.

  1. JavaScript
{
  eventData: {

  },
  __metadata__: {
    environment: "production",
    invocationId: "1b3b0113-cd71-454c-b8fb-a5a52d727584",
    requestId: "076580eb-fd0d-4c69-be41-f1714f43b8be"
  }
}

eventDataanchor

See API Reference for specific data corresponding to your event.

metadata

KeyTypeDescription
environmentStringThe Braintree environment for this function. This value will be "sandbox" or "production"
invocationIdStringA uuid representing the Braintree execution of this function. This value is useful for debugging and tracing.
requestIdStringA uuid representing the request that caused a function to be executed. This value is useful for debugging and tracing.

Examplesanchor

  1. JSON
{
  "data": {},
  "__meta": {
    "braintreeEnvironment": "production"
  }
}

Next Page: Packaging and Publishing