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

# Creating transactions

The final step is to use the card data stored using **Secure Fields** to either
create a transaction or store a card on file for later use.

## Create a transaction

Card data stored in a checkout session can be used to create a transaction.

<CodeGroup>
  ```csharp C# theme={"system"}
  var transaction = await client.Transactions.CreateAsync(
      transactionCreate: new TransactionCreate()
      {
          Amount = 1299,
          Currency = "USD",
          Country = "US",
          PaymentMethod =
              TransactionCreatePaymentMethod.CreateCheckoutSessionWithUrlPaymentMethodCreate(
                  new CheckoutSessionWithUrlPaymentMethodCreate()
                  {
                      Id = checkoutSession.Id,
                  }
              ),
      }
  );
  ```

  ```go Go theme={"system"}
  amount := int64(1299)
  currency := "USD"

  checkoutSessionWithURLPaymentMethodCreate := components.CheckoutSessionWithURLPaymentMethodCreate{
      ID: checkoutSession.ID,
  }
  paymentMethod := components.CreateTransactionCreatePaymentMethodCheckoutSessionWithURLPaymentMethodCreate(checkoutSessionWithURLPaymentMethodCreate)

  transactionCreate := components.TransactionCreate{
      Amount:        amount,
      Currency:      currency,
      PaymentMethod: &paymentMethod,
  }

  transaction, err := client.Transactions.Create(ctx, transactionCreate, nil, nil)

  // handle response
  ```

  ```java Java theme={"system"}
  CreateTransactionResponse transactionResponse = gr4vyClient.transactions().create()
      .transactionCreate(TransactionCreate.builder()
          .amount(1299L)
          .currency("USD")
          .paymentMethod(TransactionCreatePaymentMethod.of(CheckoutSessionWithUrlPaymentMethodCreate.builder()
              .id(checkoutSession.id())
              .build()))
          .build())
      .call();

  Transaction transaction = transactionResponse.transaction().orElse(null);

  // handle response
  ```

  ```php PHP theme={"system"}
  $transactionCreate = new TransactionCreate(amount: 1299, currency: 'USD', paymentMethod: new CheckoutSessionWithUrlPaymentMethodCreate(id: $checkoutSession->id));
  $response = self::$sdk->transactions->create($transactionCreate);
  $transaction = $response->transaction;
  ```

  ```python Python theme={"system"}
  transaction: models.Transaction = client.transactions.create(
      amount=1299,
      currency="USD",
      payment_method={
          "method": "checkout-session",
          "id": checkout_session.id,
      }
  )
  ```

  ```ts TypeScript theme={"system"}
  const transaction = await gr4vy.transactions.create({
      amount: 1299,
      currency: "USD",
      paymentMethod: {
      method: "checkout-session",
      id: checkoutSession.id
      }
  })
  ```
</CodeGroup>

The returned transaction includes details about the payment method used, and the
status of the transaction.

<CodeGroup>
  ```json Response theme={"system"}
  {
    "type": "transaction",
    "id": "fe26475d-ec3e-4884-9553-f7356683f7f9",
    "status": "authentication_succeeded",
    "amount": 1299,
    "currency": "AUD",
    "payment_method": {
      "type": "payment-method",
      "id": "77a76f7e-d2de-4bbc-ada9-d6a0015e6bd5",
      "method": "card",
      "scheme": "visa",
      "expiration_date": "07/24",
      ...
    },
    ...
  }
  ```
</CodeGroup>

## Store a card for later use

Card data in a checkout session can also be used to create a stored payment
method that can be used again later. This can be done either at the time of creating a transaction by
setting the [`store` property to `true`](/reference/transactions/new-transaction#body-store),
or when creating a [new payment method](/reference/payment-methods/new-payment-method#checkout-session-payment-method-create)
directly from the checkout session.

<Warning>
  This deletes the `security_code` from the
  vault and any transaction created later requires the code to be
  requested again.
</Warning>

## 3-D Secure

3-D Secure can be used in conjunction with Secure Fields using the [hosted 3DS solution][hosted-3ds]. To enable hosted 3DS, add a `redirect_url` to the API call to create a transaction, and then redirect the buyer to the `approval_url` in the response.

## Summary

In this step you:

* Used the checkout session to create a transaction or store a payment method

## Next

That's it for the quick start guide. It's recommended to look into some of the additional options, [theming](../theming), [adding logos](../theming#logos),
and how to work with [stored cards](../stored-cards).

[hosted-3ds]: /guides/features/3ds/hosted
