Skip to main content

Create a checkout session

POST 

/checkout/session

Create a checkout session

Request

Bodyrequired

    allow_promotion_codesboolean

    Enables user redeemable promotion codes.

    success_urlstringrequired

    The URL to which the customers is redirected when payment or setup is complete.

    cancel_urlstring

    If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website.

    currencystring

    Three-letter ISO currency code, in lowercase. Must be a supported currency.

    customerstring

    ID of an existing Customer, if one exists. If blank, a new Customer object based on information provided during the payment flow will be created.

    discounts object[]

    The coupon to apply. Currently, only up to one may be specified.

  • Array [
  • couponstring

    The ID of the coupon to apply.

  • ]
  • line_items object[]required

    A list of items the customer is purchasing. For payment mode, there is a maximum of 100 line items, however it is recommended to consolidate line items if there are more than a few dozen. For subscription mode, there is a maximum of 20 line items with recurring Prices and 20 line items with one-time Prices.

  • Array [
  • adjustable_quantity object

    When set, provides configuration for this item's quantity to be adjusted by the customer during Checkout.

    enabledbooleanrequired

    Set to true if the quantity can be adjusted to any non-negative integer. By default customers will be able to remove the line item by setting the quantity to 0.

    maximumnumber

    The maximum quantity the customer can purchase. By default this value is 99. You can specify a value up to 999999.

    Possible values: <= 999999

    minimumnumber

    The minimum quantity the customer must purchase. By default this value is 0.

    Possible values: >= 0

    pricestringrequired

    The ID of the Price object.

    quantitynumberrequired

    The quantity of the line item being purchased.

    Possible values: >= 1

  • ]
  • modestringrequired

    The mode of the Session. Pass subscription if it includes at least one recurring item.

    Possible values: [subscription, payment]

    payment_method_typesstring[]

    Possible values: [card, paypal, customer_balance]

    Default value: ["card"]
    subscription_data objectrequired
    trial_period_daysnumberrequired

    Integer representing the number of trial period days before the customer is charged for the first time.

    Possible values: >= 1

    expandstring[]

    Specifies which fields in the response should be expanded.

Responses

Schema
    urlstringrequired
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://connhex.com/checkout/session");
request.Headers.Add("Accept", "application/json");
var content = new StringContent("{\n \"allow_promotion_codes\": true,\n \"success_url\": \"string\",\n \"cancel_url\": \"string\",\n \"currency\": \"string\",\n \"customer\": \"string\",\n \"discounts\": [\n {\n \"coupon\": \"string\"\n }\n ],\n \"line_items\": [\n {\n \"adjustable_quantity\": {\n \"enabled\": true,\n \"maximum\": 0,\n \"minimum\": 0\n },\n \"price\": \"string\",\n \"quantity\": 0\n }\n ],\n \"mode\": \"subscription\",\n \"payment_method_types\": [\n \"card\"\n ],\n \"subscription_data\": {\n \"trial_period_days\": 0\n },\n \"expand\": [\n \"string\"\n ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Request Collapse all
Body required
{
  "allow_promotion_codes": true,
  "success_url": "string",
  "cancel_url": "string",
  "currency": "string",
  "customer": "string",
  "discounts": [
    {
      "coupon": "string"
    }
  ],
  "line_items": [
    {
      "adjustable_quantity": {
        "enabled": true,
        "maximum": 0,
        "minimum": 0
      },
      "price": "string",
      "quantity": 0
    }
  ],
  "mode": "subscription",
  "payment_method_types": [
    "card"
  ],
  "subscription_data": {
    "trial_period_days": 0
  },
  "expand": [
    "string"
  ]
}