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(requestor)
  @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.



2409
2410
2411
2412
2413
2414
2415
2416
2417
# File 'lib/stripe/services/checkout/session_service.rb', line 2409

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.



2422
2423
2424
2425
2426
2427
2428
2429
2430
# File 'lib/stripe/services/checkout/session_service.rb', line 2422

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.



2433
2434
2435
2436
2437
2438
2439
2440
2441
# File 'lib/stripe/services/checkout/session_service.rb', line 2433

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.



2444
2445
2446
2447
2448
2449
2450
2451
2452
# File 'lib/stripe/services/checkout/session_service.rb', line 2444

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.



2455
2456
2457
2458
2459
2460
2461
2462
2463
# File 'lib/stripe/services/checkout/session_service.rb', line 2455

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