Search⌘ K
AI Features

Creating a Transaction

Explore how to create payment transactions using the Braintree API, including generating payment method nonces, submitting transactions for settlement, and searching transactions by order ID. Understand transaction result handling and key attributes to build secure payment flows.

Create a transaction

To create a transaction, we use the transaction.sale() method from the Braintree gateway. This method requires, at least, the following two parameters:

  1. Amount
  2. Payment method nonce

In the code below, we are creating a transaction in lines 12–19. We have specified the amount and the payment method nonce in line 13 and line 15 respectively. Moreover, we provide an option in line 17 as an instruction that the transaction should be submitted for settlement immediately.

Apart from that, the code also requires ...