Class: Dodopayments::Resources::CheckoutSessions

Inherits:
Object
  • Object
show all
Defined in:
lib/dodopayments/resources/checkout_sessions.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ CheckoutSessions

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CheckoutSessions.

Parameters:



152
153
154
# File 'lib/dodopayments/resources/checkout_sessions.rb', line 152

def initialize(client:)
  @client = client
end

Instance Method Details

#create(product_cart:, allowed_payment_method_types: nil, billing_address: nil, billing_currency: nil, cancel_url: nil, confirm: nil, custom_fields: nil, customer: nil, customization: nil, discount_code: nil, feature_flags: nil, force_3ds: nil, metadata: nil, minimal_address: nil, payment_method_id: nil, product_collection_id: nil, return_url: nil, short_link: nil, show_saved_payment_methods: nil, subscription_data: nil, tax_id: nil, request_options: {}) ⇒ Dodopayments::Models::CheckoutSessionResponse

Some parameter documentations has been truncated, see Models::CheckoutSessionCreateParams for more details.

Parameters:

  • product_cart (Array<Dodopayments::Models::ProductItemReq>)
  • allowed_payment_method_types (Array<Symbol, Dodopayments::Models::PaymentMethodTypes>, nil)

    Customers will never see payment methods that are not in this list.

  • billing_address (Dodopayments::Models::CheckoutSessionBillingAddress, nil)

    Billing address information for the session

  • billing_currency (Symbol, Dodopayments::Models::Currency, nil)

    This field is ingored if adaptive pricing is disabled

  • cancel_url (String, nil)

    The URL to redirect the customer if they cancel or go back from the checkout.

  • confirm (Boolean)

    If confirm is true, all the details will be finalized. If required data is missi

  • custom_fields (Array<Dodopayments::Models::CustomField>, nil)

    Custom fields to collect from customer during checkout (max 5 fields)

  • customer (Dodopayments::Models::AttachExistingCustomer, Dodopayments::Models::NewCustomer, nil)

    Customer details for the session

  • customization (Dodopayments::Models::CheckoutSessionCustomization)

    Customization for the checkout session page

  • discount_code (String, nil)
  • feature_flags (Dodopayments::Models::CheckoutSessionFlags)
  • force_3ds (Boolean, nil)

    Override merchant default 3DS behaviour for this session

  • metadata (Hash{Symbol=>String}, nil)

    Additional metadata associated with the payment. Defaults to empty if not provid

  • minimal_address (Boolean)

    If true, only zipcode is required when confirm is true; other address fields rem

  • payment_method_id (String, nil)

    Optional payment method ID to use for this checkout session.

  • product_collection_id (String, nil)

    Product collection ID for collection-based checkout flow

  • return_url (String, nil)

    The url to redirect after payment failure or success.

  • short_link (Boolean)

    If true, returns a shortened checkout URL.

  • show_saved_payment_methods (Boolean)

    Display saved payment methods of a returning customer False by default

  • subscription_data (Dodopayments::Models::SubscriptionData, nil)
  • tax_id (String, nil)

    Tax ID for the customer (e.g. VAT number). Requires billing_address with country

  • request_options (Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



58
59
60
61
62
63
64
65
66
67
# File 'lib/dodopayments/resources/checkout_sessions.rb', line 58

def create(params)
  parsed, options = Dodopayments::CheckoutSessionCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "checkouts",
    body: parsed,
    model: Dodopayments::CheckoutSessionResponse,
    options: options
  )
end

#preview(product_cart:, allowed_payment_method_types: nil, billing_address: nil, billing_currency: nil, cancel_url: nil, confirm: nil, custom_fields: nil, customer: nil, customization: nil, discount_code: nil, feature_flags: nil, force_3ds: nil, metadata: nil, minimal_address: nil, payment_method_id: nil, product_collection_id: nil, return_url: nil, short_link: nil, show_saved_payment_methods: nil, subscription_data: nil, tax_id: nil, request_options: {}) ⇒ Dodopayments::Models::CheckoutSessionPreviewResponse

Some parameter documentations has been truncated, see Models::CheckoutSessionPreviewParams for more details.

Parameters:

  • product_cart (Array<Dodopayments::Models::ProductItemReq>)
  • allowed_payment_method_types (Array<Symbol, Dodopayments::Models::PaymentMethodTypes>, nil)

    Customers will never see payment methods that are not in this list.

  • billing_address (Dodopayments::Models::CheckoutSessionBillingAddress, nil)

    Billing address information for the session

  • billing_currency (Symbol, Dodopayments::Models::Currency, nil)

    This field is ingored if adaptive pricing is disabled

  • cancel_url (String, nil)

    The URL to redirect the customer if they cancel or go back from the checkout.

  • confirm (Boolean)

    If confirm is true, all the details will be finalized. If required data is missi

  • custom_fields (Array<Dodopayments::Models::CustomField>, nil)

    Custom fields to collect from customer during checkout (max 5 fields)

  • customer (Dodopayments::Models::AttachExistingCustomer, Dodopayments::Models::NewCustomer, nil)

    Customer details for the session

  • customization (Dodopayments::Models::CheckoutSessionCustomization)

    Customization for the checkout session page

  • discount_code (String, nil)
  • feature_flags (Dodopayments::Models::CheckoutSessionFlags)
  • force_3ds (Boolean, nil)

    Override merchant default 3DS behaviour for this session

  • metadata (Hash{Symbol=>String}, nil)

    Additional metadata associated with the payment. Defaults to empty if not provid

  • minimal_address (Boolean)

    If true, only zipcode is required when confirm is true; other address fields rem

  • payment_method_id (String, nil)

    Optional payment method ID to use for this checkout session.

  • product_collection_id (String, nil)

    Product collection ID for collection-based checkout flow

  • return_url (String, nil)

    The url to redirect after payment failure or success.

  • short_link (Boolean)

    If true, returns a shortened checkout URL.

  • show_saved_payment_methods (Boolean)

    Display saved payment methods of a returning customer False by default

  • subscription_data (Dodopayments::Models::SubscriptionData, nil)
  • tax_id (String, nil)

    Tax ID for the customer (e.g. VAT number). Requires billing_address with country

  • request_options (Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



138
139
140
141
142
143
144
145
146
147
# File 'lib/dodopayments/resources/checkout_sessions.rb', line 138

def preview(params)
  parsed, options = Dodopayments::CheckoutSessionPreviewParams.dump_request(params)
  @client.request(
    method: :post,
    path: "checkouts/preview",
    body: parsed,
    model: Dodopayments::Models::CheckoutSessionPreviewResponse,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ Dodopayments::Models::CheckoutSessionStatus

Parameters:

Returns:

See Also:



77
78
79
80
81
82
83
84
# File 'lib/dodopayments/resources/checkout_sessions.rb', line 77

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["checkouts/%1$s", id],
    model: Dodopayments::CheckoutSessionStatus,
    options: params[:request_options]
  )
end