stripe/resources/checkout_session_ext.rs
1use crate::client::{Client, Response};
2use crate::ids::CheckoutSessionId;
3use crate::params::Expand;
4use crate::resources::CheckoutSession;
5use crate::{CheckoutSessionItem, List};
6
7/// The parameters for `CheckoutSession::retrieve_line_items`.
8#[derive(Clone, Debug, serde::Serialize, Default)]
9pub struct RetrieveCheckoutSessionLineItems {
10 /// A cursor for use in pagination.
11 ///
12 /// `ending_before` is an object ID that defines your place in the list.
13 /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub ending_before: Option<CheckoutSessionId>,
16
17 /// A limit on the number of objects to be returned.
18 ///
19 /// Limit can range between 1 and 100, and the default is 10.
20 #[serde(skip_serializing_if = "Option::is_none")]
21 pub limit: Option<u64>,
22
23 /// A cursor for use in pagination.
24 ///
25 /// `starting_after` is an object ID that defines your place in the list.
26 /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub starting_after: Option<CheckoutSessionId>,
29}
30
31impl CheckoutSession {
32 /// Retrieves a Session object.
33 ///
34 /// For more details see <https://stripe.com/docs/api/checkout/sessions/retrieve>.
35 pub fn retrieve(
36 client: &Client,
37 id: &CheckoutSessionId,
38 expand: &[&str],
39 ) -> Response<CheckoutSession> {
40 client.get_query(&format!("/checkout/sessions/{}", id), Expand { expand })
41 }
42
43 /// Expires a checkout session.
44 ///
45 /// For more details see <https://stripe.com/docs/api/checkout/sessions/expire>.
46 pub fn expire(client: &Client, id: &CheckoutSessionId) -> Response<CheckoutSession> {
47 client.post(&format!("/checkout/sessions/{}/expire", id))
48 }
49
50 /// Retrieves a Checkout Session's line items
51 ///
52 /// For more details see <https://docs.stripe.com/api/checkout/sessions/line_items>
53 pub fn retrieve_line_items(
54 client: &Client,
55 id: &CheckoutSessionId,
56 params: &RetrieveCheckoutSessionLineItems,
57 ) -> Response<List<CheckoutSessionItem>> {
58 client.get_query(&format!("/checkout/sessions/{}/line_items", id), params)
59 }
60}