> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rinne.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Transactions

> Create payment transactions and understand defaults and payload structure.

Transactions in rinne-js represent the checkout amount and context used by wallet elements during authorization.

Create a new transaction whenever totals change so wallet sheets and backend charge requests stay aligned.

## Create a Transaction

Use `rinne.transaction.create()` before mounting Apple Pay or Google Pay.

```typescript theme={null}
const transaction = await rinne.transaction.create({
  amount: 5000,
  currency: 'BRL',
  country: 'BR',
  lineItems: [
    { label: 'Subtotal', amount: 4500 },
    { label: 'Shipping', amount: 500 }
  ]
})
```

<ParamField path="amount" type="number" required>
  Amount in cents.
</ParamField>

<ParamField path="currency" type="string" default="BRL">
  ISO 4217 currency code.
</ParamField>

<ParamField path="country" type="string" default="BR">
  ISO 3166 country code.
</ParamField>

<ParamField path="lineItems" type="Array<{ label: string; amount: number }>">
  Optional line item breakdown used by wallet UIs.
</ParamField>

## Behavior Notes

* The SDK initializes lazily on first transaction/element call.
* `currency` defaults to `BRL` and `country` defaults to `BR`.
* Returned transactions are intended to be passed into wallet elements.

<Tip>
  Create a new transaction whenever checkout totals change. Keep the transaction amount aligned with what you charge on your backend.
</Tip>

## Example with Dynamic Cart

```typescript theme={null}
const total = cartItems.reduce((sum, item) => sum + item.amount, 0)

const transaction = await rinne.transaction.create({
  amount: total,
  lineItems: cartItems.map((item) => ({
    label: item.label,
    amount: item.amount
  }))
})
```
