Create a checkout session
POST/checkout/session
Create a checkout session
Request
- application/json
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[]
line_items object[]required
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
expandstring[]
Specifies which fields in the response should be expanded.
Responses
- 201
- application/json
- Schema
- Example (auto)
Schema
urlstringrequired
{
"url": "string"
}
- csharp
- curl
- dart
- go
- http
- java
- javascript
- kotlin
- c
- nodejs
- objective-c
- ocaml
- php
- powershell
- python
- r
- ruby
- rust
- shell
- swift
- HTTPCLIENT
- RESTSHARP
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());