---
displayed_sidebar: entitiesSidebar
slug: /references/entities/classes/PaymentSession
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# PaymentSession

A Payment Session is created when a Customer initilizes the checkout flow, and can be used to hold the state of a payment flow. Each Payment Session is controlled by a Payment Provider, which is responsible for the communication with external payment services. Authorized Payment Sessions will eventually get promoted to Payments to indicate that they are authorized for payment processing such as capture or refund. Payment sessions can also be used as part of payment collections.

## Properties

<ParameterTypes parameters={[
  {
    "name": "amount",
    "type": "`number`",
    "description": "The amount that the Payment Session has been authorized for.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "cart",
    "type": "[Cart](entities.Cart.mdx)",
    "description": "The details of the cart that the payment session was created for.",
    "optional": false,
    "defaultValue": "",
    "expandable": true,
    "children": [
      {
        "name": "billing_address",
        "type": "[Address](entities.Address.mdx)",
        "description": "The details of the billing address associated with the cart.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "billing_address_id",
        "type": "`string`",
        "description": "The billing address's ID",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "completed_at",
        "type": "`Date`",
        "description": "The date with timezone at which the cart was completed.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "context",
        "type": "`Record<string, unknown>`",
        "description": "The context of the cart which can include info like IP or user agent.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "created_at",
        "type": "`Date`",
        "description": "The date with timezone at which the resource was created.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "customer",
        "type": "[Customer](entities.Customer.mdx)",
        "description": "The details of the customer the cart belongs to.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "customer_id",
        "type": "`string`",
        "description": "The customer's ID",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "deleted_at",
        "type": "`null` \\| `Date`",
        "description": "The date with timezone at which the resource was deleted.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "discount_total",
        "type": "`number`",
        "description": "The total of discount rounded",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "discounts",
        "type": "[Discount](entities.Discount.mdx)[]",
        "description": "An array of details of all discounts applied to the cart.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "email",
        "type": "`string`",
        "description": "The email associated with the cart",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "gift_card_tax_total",
        "type": "`number`",
        "description": "The total of gift cards with taxes",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "gift_card_total",
        "type": "`number`",
        "description": "The total of gift cards",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "gift_cards",
        "type": "[GiftCard](entities.GiftCard.mdx)[]",
        "description": "An array of details of all gift cards applied to the cart.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "id",
        "type": "`string`",
        "description": "The cart's ID",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "idempotency_key",
        "type": "`string`",
        "description": "Randomly generated key used to continue the completion of a cart in case of failure.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "item_tax_total",
        "type": "`null` \\| `number`",
        "description": "The total of items with taxes",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "items",
        "type": "[LineItem](entities.LineItem.mdx)[]",
        "description": "The line items added to the cart.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "metadata",
        "type": "`Record<string, unknown>`",
        "description": "An optional key-value map with additional details",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "object",
        "type": "`\"cart\"`",
        "description": "",
        "optional": false,
        "defaultValue": "\"cart\"",
        "expandable": false,
        "children": []
      },
      {
        "name": "payment",
        "type": "[Payment](entities.Payment.mdx)",
        "description": "The details of the payment associated with the cart.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "payment_authorized_at",
        "type": "`Date`",
        "description": "The date with timezone at which the payment was authorized.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "payment_id",
        "type": "`string`",
        "description": "The payment's ID if available",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "payment_session",
        "type": "`null` \\| [PaymentSession](entities.PaymentSession.mdx)",
        "description": "The details of the selected payment session in the cart.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "payment_sessions",
        "type": "[PaymentSession](entities.PaymentSession.mdx)[]",
        "description": "The details of all payment sessions created on the cart.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "raw_discount_total",
        "type": "`number`",
        "description": "The total of discount",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "refundable_amount",
        "type": "`number`",
        "description": "The amount that can be refunded",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "refunded_total",
        "type": "`number`",
        "description": "The total amount refunded if the order associated with this cart is returned.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "region",
        "type": "[Region](entities.Region.mdx)",
        "description": "The details of the region associated with the cart.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "region_id",
        "type": "`string`",
        "description": "The region's ID",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "sales_channel",
        "type": "[SalesChannel](entities.SalesChannel.mdx)",
        "description": "The details of the sales channel associated with the cart.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "sales_channel_id",
        "type": "`null` \\| `string`",
        "description": "The sales channel ID the cart is associated with.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "shipping_address",
        "type": "`null` \\| [Address](entities.Address.mdx)",
        "description": "The details of the shipping address associated with the cart.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "shipping_address_id",
        "type": "`string`",
        "description": "The shipping address's ID",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "shipping_methods",
        "type": "[ShippingMethod](entities.ShippingMethod.mdx)[]",
        "description": "The details of the shipping methods added to the cart.",
        "optional": false,
        "defaultValue": "",
        "expandable": true,
        "children": []
      },
      {
        "name": "shipping_tax_total",
        "type": "`null` \\| `number`",
        "description": "The total of shipping with taxes",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "shipping_total",
        "type": "`number`",
        "description": "The total of shipping",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "subtotal",
        "type": "`number`",
        "description": "The subtotal of the cart",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "tax_total",
        "type": "`null` \\| `number`",
        "description": "The total of tax",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "total",
        "type": "`number`",
        "description": "The total amount of the cart",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "type",
        "type": "[CartType](../enums/entities.CartType.mdx)",
        "description": "The cart's type.",
        "optional": false,
        "defaultValue": "default",
        "expandable": false,
        "children": []
      },
      {
        "name": "updated_at",
        "type": "`Date`",
        "description": "The date with timezone at which the resource was updated.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  },
  {
    "name": "cart_id",
    "type": "`null` \\| `string`",
    "description": "The ID of the cart that the payment session was created for.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "created_at",
    "type": "`Date`",
    "description": "The date with timezone at which the resource was created.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "data",
    "type": "`Record<string, unknown>`",
    "description": "The data required for the Payment Provider to identify, modify and process the Payment Session. Typically this will be an object that holds an id to the external payment session, but can be an empty object if the Payment Provider doesn't hold any state.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "id",
    "type": "`string`",
    "description": "The payment session's ID",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "idempotency_key",
    "type": "`string`",
    "description": "Randomly generated key used to continue the completion of a cart in case of failure.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "is_initiated",
    "type": "`boolean`",
    "description": "A flag to indicate if a communication with the third party provider has been initiated.",
    "optional": false,
    "defaultValue": "false",
    "expandable": false,
    "children": []
  },
  {
    "name": "is_selected",
    "type": "`null` \\| `boolean`",
    "description": "A flag to indicate if the Payment Session has been selected as the method that will be used to complete the purchase.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "payment_authorized_at",
    "type": "`Date`",
    "description": "The date with timezone at which the Payment Session was authorized.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "provider_id",
    "type": "`string`",
    "description": "The ID of the Payment Provider that is responsible for the Payment Session",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "status",
    "type": "`string`",
    "description": "Indicates the status of the Payment Session. Will default to `pending`, and will eventually become `authorized`. Payment Sessions may have the status of `requires\\_more` to indicate that further actions are to be completed by the Customer.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "updated_at",
    "type": "`Date`",
    "description": "The date with timezone at which the resource was updated.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} expandUrl="https://docs.medusajs.com/development/entities/repositories#retrieving-a-list-of-records"/>
