stripe-ruby/lib/stripe/services/terminal/reader_service.rb
2025-05-15 21:47:32 +00:00

579 lines
23 KiB
Ruby

# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
module Terminal
class ReaderService < StripeService
class DeleteParams < Stripe::RequestParams; end
class RetrieveParams < Stripe::RequestParams
# Specifies which fields in the response should be expanded.
attr_accessor :expand
def initialize(expand: nil)
@expand = expand
end
end
class UpdateParams < Stripe::RequestParams
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# The new label of the reader.
attr_accessor :label
# Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
attr_accessor :metadata
def initialize(expand: nil, label: nil, metadata: nil)
@expand = expand
@label = label
@metadata = metadata
end
end
class ListParams < Stripe::RequestParams
# Filters readers by device type
attr_accessor :device_type
# A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. 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.
attr_accessor :ending_before
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
attr_accessor :limit
# A location ID to filter the response list to only readers at the specific location
attr_accessor :location
# Filters readers by serial number
attr_accessor :serial_number
# A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. 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.
attr_accessor :starting_after
# A status filter to filter readers to only offline or online readers
attr_accessor :status
def initialize(
device_type: nil,
ending_before: nil,
expand: nil,
limit: nil,
location: nil,
serial_number: nil,
starting_after: nil,
status: nil
)
@device_type = device_type
@ending_before = ending_before
@expand = expand
@limit = limit
@location = location
@serial_number = serial_number
@starting_after = starting_after
@status = status
end
end
class CreateParams < Stripe::RequestParams
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# Custom label given to the reader for easier identification. If no label is specified, the registration code will be used.
attr_accessor :label
# The location to assign the reader to.
attr_accessor :location
# Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
attr_accessor :metadata
# A code generated by the reader used for registering to an account.
attr_accessor :registration_code
def initialize(
expand: nil,
label: nil,
location: nil,
metadata: nil,
registration_code: nil
)
@expand = expand
@label = label
@location = location
@metadata = metadata
@registration_code = registration_code
end
end
class CancelActionParams < Stripe::RequestParams
# Specifies which fields in the response should be expanded.
attr_accessor :expand
def initialize(expand: nil)
@expand = expand
end
end
class CollectInputsParams < Stripe::RequestParams
class Input < Stripe::RequestParams
class CustomText < Stripe::RequestParams
# The description which will be displayed when collecting this input
attr_accessor :description
# The skip button text
attr_accessor :skip_button
# The submit button text
attr_accessor :submit_button
# The title which will be displayed when collecting this input
attr_accessor :title
def initialize(description: nil, skip_button: nil, submit_button: nil, title: nil)
@description = description
@skip_button = skip_button
@submit_button = submit_button
@title = title
end
end
class Selection < Stripe::RequestParams
class Choice < Stripe::RequestParams
# The unique identifier for this choice
attr_accessor :id
# The style of the button which will be shown for this choice
attr_accessor :style
# The text which will be shown on the button for this choice
attr_accessor :text
def initialize(id: nil, style: nil, text: nil)
@id = id
@style = style
@text = text
end
end
# List of choices for the `selection` input
attr_accessor :choices
def initialize(choices: nil)
@choices = choices
end
end
class Toggle < Stripe::RequestParams
# The default value of the toggle
attr_accessor :default_value
# The description which will be displayed for the toggle
attr_accessor :description
# The title which will be displayed for the toggle
attr_accessor :title
def initialize(default_value: nil, description: nil, title: nil)
@default_value = default_value
@description = description
@title = title
end
end
# Customize the text which will be displayed while collecting this input
attr_accessor :custom_text
# Indicate that this input is required, disabling the skip button
attr_accessor :required
# Options for the `selection` input
attr_accessor :selection
# List of toggles to be displayed and customization for the toggles
attr_accessor :toggles
# The type of input to collect
attr_accessor :type
def initialize(custom_text: nil, required: nil, selection: nil, toggles: nil, type: nil)
@custom_text = custom_text
@required = required
@selection = selection
@toggles = toggles
@type = type
end
end
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# List of inputs to be collected using the Reader
attr_accessor :inputs
# Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
attr_accessor :metadata
def initialize(expand: nil, inputs: nil, metadata: nil)
@expand = expand
@inputs = inputs
@metadata = metadata
end
end
class CollectPaymentMethodParams < Stripe::RequestParams
class CollectConfig < Stripe::RequestParams
class Tipping < Stripe::RequestParams
# Amount used to calculate tip suggestions on tipping selection screen for this transaction. Must be a positive integer in the smallest currency unit (e.g., 100 cents to represent $1.00 or 100 to represent ¥100, a zero-decimal currency).
attr_accessor :amount_eligible
def initialize(amount_eligible: nil)
@amount_eligible = amount_eligible
end
end
# This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow.
attr_accessor :allow_redisplay
# Enables cancel button on transaction screens.
attr_accessor :enable_customer_cancellation
# Override showing a tipping selection screen on this transaction.
attr_accessor :skip_tipping
# Tipping configuration for this transaction.
attr_accessor :tipping
def initialize(
allow_redisplay: nil,
enable_customer_cancellation: nil,
skip_tipping: nil,
tipping: nil
)
@allow_redisplay = allow_redisplay
@enable_customer_cancellation = enable_customer_cancellation
@skip_tipping = skip_tipping
@tipping = tipping
end
end
# Configuration overrides
attr_accessor :collect_config
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# PaymentIntent ID
attr_accessor :payment_intent
def initialize(collect_config: nil, expand: nil, payment_intent: nil)
@collect_config = collect_config
@expand = expand
@payment_intent = payment_intent
end
end
class ConfirmPaymentIntentParams < Stripe::RequestParams
class ConfirmConfig < Stripe::RequestParams
# The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method's app or site. If you'd prefer to redirect to a mobile application, you can alternatively supply an application URI scheme.
attr_accessor :return_url
def initialize(return_url: nil)
@return_url = return_url
end
end
# Configuration overrides
attr_accessor :confirm_config
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# PaymentIntent ID
attr_accessor :payment_intent
def initialize(confirm_config: nil, expand: nil, payment_intent: nil)
@confirm_config = confirm_config
@expand = expand
@payment_intent = payment_intent
end
end
class ProcessPaymentIntentParams < Stripe::RequestParams
class ProcessConfig < Stripe::RequestParams
class Tipping < Stripe::RequestParams
# Amount used to calculate tip suggestions on tipping selection screen for this transaction. Must be a positive integer in the smallest currency unit (e.g., 100 cents to represent $1.00 or 100 to represent ¥100, a zero-decimal currency).
attr_accessor :amount_eligible
def initialize(amount_eligible: nil)
@amount_eligible = amount_eligible
end
end
# This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow.
attr_accessor :allow_redisplay
# Enables cancel button on transaction screens.
attr_accessor :enable_customer_cancellation
# The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method's app or site. If you'd prefer to redirect to a mobile application, you can alternatively supply an application URI scheme.
attr_accessor :return_url
# Override showing a tipping selection screen on this transaction.
attr_accessor :skip_tipping
# Tipping configuration for this transaction.
attr_accessor :tipping
def initialize(
allow_redisplay: nil,
enable_customer_cancellation: nil,
return_url: nil,
skip_tipping: nil,
tipping: nil
)
@allow_redisplay = allow_redisplay
@enable_customer_cancellation = enable_customer_cancellation
@return_url = return_url
@skip_tipping = skip_tipping
@tipping = tipping
end
end
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# PaymentIntent ID
attr_accessor :payment_intent
# Configuration overrides
attr_accessor :process_config
def initialize(expand: nil, payment_intent: nil, process_config: nil)
@expand = expand
@payment_intent = payment_intent
@process_config = process_config
end
end
class ProcessSetupIntentParams < Stripe::RequestParams
class ProcessConfig < Stripe::RequestParams
# Enables cancel button on transaction screens.
attr_accessor :enable_customer_cancellation
def initialize(enable_customer_cancellation: nil)
@enable_customer_cancellation = enable_customer_cancellation
end
end
# This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow.
attr_accessor :allow_redisplay
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# Configuration overrides
attr_accessor :process_config
# SetupIntent ID
attr_accessor :setup_intent
def initialize(allow_redisplay: nil, expand: nil, process_config: nil, setup_intent: nil)
@allow_redisplay = allow_redisplay
@expand = expand
@process_config = process_config
@setup_intent = setup_intent
end
end
class RefundPaymentParams < Stripe::RequestParams
class RefundPaymentConfig < Stripe::RequestParams
# Enables cancel button on transaction screens.
attr_accessor :enable_customer_cancellation
def initialize(enable_customer_cancellation: nil)
@enable_customer_cancellation = enable_customer_cancellation
end
end
# A positive integer in __cents__ representing how much of this charge to refund.
attr_accessor :amount
# ID of the Charge to refund.
attr_accessor :charge
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
attr_accessor :metadata
# ID of the PaymentIntent to refund.
attr_accessor :payment_intent
# Boolean indicating whether the application fee should be refunded when refunding this charge. If a full charge refund is given, the full application fee will be refunded. Otherwise, the application fee will be refunded in an amount proportional to the amount of the charge refunded. An application fee can be refunded only by the application that created the charge.
attr_accessor :refund_application_fee
# Configuration overrides
attr_accessor :refund_payment_config
# Boolean indicating whether the transfer should be reversed when refunding this charge. The transfer will be reversed proportionally to the amount being refunded (either the entire or partial amount). A transfer can be reversed only by the application that created the charge.
attr_accessor :reverse_transfer
def initialize(
amount: nil,
charge: nil,
expand: nil,
metadata: nil,
payment_intent: nil,
refund_application_fee: nil,
refund_payment_config: nil,
reverse_transfer: nil
)
@amount = amount
@charge = charge
@expand = expand
@metadata = metadata
@payment_intent = payment_intent
@refund_application_fee = refund_application_fee
@refund_payment_config = refund_payment_config
@reverse_transfer = reverse_transfer
end
end
class SetReaderDisplayParams < Stripe::RequestParams
class Cart < Stripe::RequestParams
class LineItem < Stripe::RequestParams
# The price of the item in cents.
attr_accessor :amount
# The description or name of the item.
attr_accessor :description
# The quantity of the line item being purchased.
attr_accessor :quantity
def initialize(amount: nil, description: nil, quantity: nil)
@amount = amount
@description = description
@quantity = quantity
end
end
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_accessor :currency
# Array of line items that were purchased.
attr_accessor :line_items
# The amount of tax in cents.
attr_accessor :tax
# Total balance of cart due in cents.
attr_accessor :total
def initialize(currency: nil, line_items: nil, tax: nil, total: nil)
@currency = currency
@line_items = line_items
@tax = tax
@total = total
end
end
# Cart
attr_accessor :cart
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# Type
attr_accessor :type
def initialize(cart: nil, expand: nil, type: nil)
@cart = cart
@expand = expand
@type = type
end
end
# Cancels the current reader action.
def cancel_action(reader, params = {}, opts = {})
request(
method: :post,
path: format("/v1/terminal/readers/%<reader>s/cancel_action", { reader: CGI.escape(reader) }),
params: params,
opts: opts,
base_address: :api
)
end
# Initiates an input collection flow on a Reader.
def collect_inputs(reader, params = {}, opts = {})
request(
method: :post,
path: format("/v1/terminal/readers/%<reader>s/collect_inputs", { reader: CGI.escape(reader) }),
params: params,
opts: opts,
base_address: :api
)
end
# Initiates a payment flow on a Reader and updates the PaymentIntent with card details before manual confirmation.
def collect_payment_method(reader, params = {}, opts = {})
request(
method: :post,
path: format("/v1/terminal/readers/%<reader>s/collect_payment_method", { reader: CGI.escape(reader) }),
params: params,
opts: opts,
base_address: :api
)
end
# Finalizes a payment on a Reader.
def confirm_payment_intent(reader, params = {}, opts = {})
request(
method: :post,
path: format("/v1/terminal/readers/%<reader>s/confirm_payment_intent", { reader: CGI.escape(reader) }),
params: params,
opts: opts,
base_address: :api
)
end
# Creates a new Reader object.
def create(params = {}, opts = {})
request(
method: :post,
path: "/v1/terminal/readers",
params: params,
opts: opts,
base_address: :api
)
end
# Deletes a Reader object.
def delete(reader, params = {}, opts = {})
request(
method: :delete,
path: format("/v1/terminal/readers/%<reader>s", { reader: CGI.escape(reader) }),
params: params,
opts: opts,
base_address: :api
)
end
# Returns a list of Reader objects.
def list(params = {}, opts = {})
request(
method: :get,
path: "/v1/terminal/readers",
params: params,
opts: opts,
base_address: :api
)
end
# Initiates a payment flow on a Reader.
def process_payment_intent(reader, params = {}, opts = {})
request(
method: :post,
path: format("/v1/terminal/readers/%<reader>s/process_payment_intent", { reader: CGI.escape(reader) }),
params: params,
opts: opts,
base_address: :api
)
end
# Initiates a setup intent flow on a Reader.
def process_setup_intent(reader, params = {}, opts = {})
request(
method: :post,
path: format("/v1/terminal/readers/%<reader>s/process_setup_intent", { reader: CGI.escape(reader) }),
params: params,
opts: opts,
base_address: :api
)
end
# Initiates a refund on a Reader
def refund_payment(reader, params = {}, opts = {})
request(
method: :post,
path: format("/v1/terminal/readers/%<reader>s/refund_payment", { reader: CGI.escape(reader) }),
params: params,
opts: opts,
base_address: :api
)
end
# Retrieves a Reader object.
def retrieve(reader, params = {}, opts = {})
request(
method: :get,
path: format("/v1/terminal/readers/%<reader>s", { reader: CGI.escape(reader) }),
params: params,
opts: opts,
base_address: :api
)
end
# Sets reader display to show cart details.
def set_reader_display(reader, params = {}, opts = {})
request(
method: :post,
path: format("/v1/terminal/readers/%<reader>s/set_reader_display", { reader: CGI.escape(reader) }),
params: params,
opts: opts,
base_address: :api
)
end
# Updates a Reader object by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
def update(reader, params = {}, opts = {})
request(
method: :post,
path: format("/v1/terminal/readers/%<reader>s", { reader: CGI.escape(reader) }),
params: params,
opts: opts,
base_address: :api
)
end
end
end
end