# Braintree

> Accept card and digital-wallet payments and automate refunds with Braintree, a PayPal service.

App · Payments & Billing · 5 actions. Web page: https://docs.lodol.com/docs/integrations/braintree

## Actions

### Create a Braintree transaction

Charge a payment method (a client-generated nonce or a vaulted token) for a given amount.

**Inputs**

- Payment method (`payment_method_id`, text, required): A single-use payment method nonce or a vaulted payment method token to charge. In the sandbox you can use 'fake-valid-nonce' to simulate a successful card.
- Amount (`amount`, text, required): The amount to charge as a decimal string, for example '10.00'. Use the account's default currency.
- Order ID (`order_id`, text): Your own order or invoice reference (optional).

**Outputs**: Braintree transaction object with its id, status, amount, and order id.

**Example output**

```json
{
  "amount": {
    "currencyIsoCode": "USD",
    "value": "10.00"
  },
  "id": "test_txn_id",
  "status": "SUBMITTED_FOR_SETTLEMENT"
}
```

### Generate a Braintree client token

Generate a client token used to initialize Braintree's client-side SDKs (Drop-in UI, Hosted Fields, or the mobile SDKs).

**Inputs**

- Merchant account ID (`merchant_account_id`, text): Scope the token to a specific merchant account, for example a non-default currency (optional).

**Outputs**: Object with a 'clientToken' string to hand to a Braintree client SDK.

**Example output**

```json
{
  "clientToken": "test_client_token_value"
}
```

### Refund a Braintree transaction

Refund a settled transaction, in full or in part. Use Reverse a transaction instead if it has not settled yet.

**Inputs**

- Transaction ID (`transaction_id`, text, required): The ID of the settled transaction to refund.
- Amount (`amount`, text): The amount to refund as a decimal string, for example '5.00'. Leave blank to refund the full amount.

**Outputs**: Braintree refund object with its id, status, and amount.

**Example output**

```json
{
  "amount": {
    "currencyIsoCode": "USD",
    "value": "5.00"
  },
  "id": "test_refund_id",
  "status": "SUBMITTED_FOR_SETTLEMENT"
}
```

### Reverse a Braintree transaction

Cancel a transaction. Braintree voids it if it has not settled yet, or refunds it in full if it already has.

**Inputs**

- Transaction ID (`transaction_id`, text, required): The ID of the transaction to reverse.

**Outputs**: Braintree reversal object: either the voided transaction or a refund, distinguished by its __typename.

**Example output**

```json
{
  "__typename": "Transaction",
  "amount": {
    "currencyIsoCode": "USD",
    "value": "10.00"
  },
  "id": "test_txn_id",
  "status": "VOIDED"
}
```

### Search Braintree transactions

Search recent transactions, optionally filtered by status.

**Inputs**

- Status (`status`, text): Filter by transaction status, for example 'SETTLED', 'SUBMITTED_FOR_SETTLEMENT', 'VOIDED', or 'PROCESSOR_DECLINED'. Leave blank to return the most recent transactions of any status.
- Maximum results (`first`, number): Maximum transactions to return (Braintree caps a page at 50). From 1 to 50. Default: `20`.

**Outputs**: Array of Braintree transaction objects.

**Example output**

```json
[
  {
    "amount": {
      "currencyIsoCode": "USD",
      "value": "10.00"
    },
    "id": "test_txn_id",
    "status": "SETTLED"
  }
]
```
