Class: Stripe::Checkout::SessionService

Inherits:
StripeService show all
Defined in:
lib/stripe/services/checkout/session_service.rb

Defined Under Namespace

Classes: CreateParams, ExpireParams, ListParams, RetrieveParams, UpdateParams

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from StripeService

#request, #request_stream

Constructor Details

#initialize(requestor) ⇒ SessionService

Returns a new instance of SessionService.



9
10
11
12
# File 'lib/stripe/services/checkout/session_service.rb', line 9

def initialize(requestor)
  super
  @line_items = Stripe::Checkout::SessionLineItemService.new(@requestor)
end

Instance Attribute Details

#line_itemsObject (readonly)

Returns the value of attribute line_items.



7
8
9
# File 'lib/stripe/services/checkout/session_service.rb', line 7

def line_items
  @line_items
end

Instance Method Details

#create(params = {}, opts = {}) ⇒ Object

Creates a Checkout Session object.



2976
2977
2978
2979
2980
2981
2982
2983
2984
# File 'lib/stripe/services/checkout/session_service.rb', line 2976

def create(params = {}, opts = {})
  request(
    method: :post,
    path: "/v1/checkout/sessions",
    params: params,
    opts: opts,
    base_address: :api
  )
end

#expire(session, params = {}, opts = {}) ⇒ Object

A Checkout Session can be expired when it is in one of these statuses: open

After it expires, a customer can’t complete a Checkout Session and customers loading the Checkout Session see a message saying the Checkout Session is expired.



2989
2990
2991
2992
2993
2994
2995
2996
2997
# File 'lib/stripe/services/checkout/session_service.rb', line 2989

def expire(session, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/checkout/sessions/%<session>s/expire", { session: CGI.escape(session) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#list(params = {}, opts = {}) ⇒ Object

Returns a list of Checkout Sessions.



3000
3001
3002
3003
3004
3005
3006
3007
3008
# File 'lib/stripe/services/checkout/session_service.rb', line 3000

def list(params = {}, opts = {})
  request(
    method: :get,
    path: "/v1/checkout/sessions",
    params: params,
    opts: opts,
    base_address: :api
  )
end

#retrieve(session, params = {}, opts = {}) ⇒ Object

Retrieves a Checkout Session object.



3011
3012
3013
3014
3015
3016
3017
3018
3019
# File 'lib/stripe/services/checkout/session_service.rb', line 3011

def retrieve(session, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/checkout/sessions/%<session>s", { session: CGI.escape(session) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#update(session, params = {}, opts = {}) ⇒ Object

Updates a Checkout Session object.

Related guide: [Dynamically update Checkout](docs.stripe.com/payments/checkout/dynamic-updates)



3024
3025
3026
3027
3028
3029
3030
3031
3032
# File 'lib/stripe/services/checkout/session_service.rb', line 3024

def update(session, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/checkout/sessions/%<session>s", { session: CGI.escape(session) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end