package
1.25.0
Repository: https://github.com/stripe/stripe-cli.git
Documentation: pkg.go.dev

# Functions

ActivateTerminalRPCSession calls Rabbit Service for a new reader session and returns the resulting session token.
AttemptRegisterReader prompt the user for their p400 registration code, and tries to register the reader via Stripe API it tries three times before returning an error returns the registered reader's IP address if successful.
CallRabbitService takes a TerminalSessionContext and method information and calls that Rabbit Service RPC method.
CapturePaymentIntent manually captures the Payment Intent after a Payment Method is attached which is the required flow for collecting payments on the Terminal platform.
ClearReaderDisplay calls Rabbit Service and sets the reader display back to the splash screen and ends any payment collection status.
CollectPaymentMethod calls Rabbit Service to put reader in payment collection state.
CompleteTestPayment sets the reader into collect payment mode, waits for the payment, confirms the payment, then finally captures the Payment Intent.
ConfirmPayment calls Rabbit Service to confirm the payment that it collected, using Payment Intent and Payment Method to do so.
CreatePaymentIntent calls the Stripe API to create a new Payment Intent in order to later attach a collected P400 payment to it returns the Payment Intent Id.
CreateRabbitServicePayload serializes the required information into a JSON payload used in calls to RabbitService.
DiscoverReaders calls the Stripe API to get a list of currently registered P400 readers on the account it returns a map of Reader types.
GeneratePOSDeviceID creates a pseudorandom alpha string id for a point-of-sale quasi-unique identifier mostly used for TransactionContext related tracking / tracing and is semi-persistent to a machine but not determinant.
GetNewConnectionToken calls the Stripe API and requests a new connection token in order to start a new reader session it returns the connection token when successful.
GetOSString finds which operating system the user is running and creates the correct string name for it to report to Rabbit Service when making a call this is mostly used by the TransactionContext properties.
QueryPaymentMethod calls Rabbit Service to query the status of a payment currently being collected.
ReaderChargeAmountPrompt prompts the user to enter a monetary amount to charge as a test payment it converts the string the user entered into an integer and returns that.
ReaderChargeCurrencyPrompt prompts the user for the currency they want to take a test payment in it returns the currency code that the user entered.
ReaderNewOrExistingPrompt prompts the user to choose to set up a new reader, or continue with an already registered reader it returns their choice.
ReaderRegistrationCodePrompt prompts the user to generate a new registration code on their P400 and asks them to enter it at the prompt it returns the code that the user typed in.
RegisterAndActivateReader prompts the user to either add a new reader or choose an existing reader on their account it then calls the appropriate method to set them up and activate a reader session for them to take a test payment it returns an updated TerminalSessionContext containing the session's connection token and rpc session token.
RegisteredReaderChoicePrompt takes a list of registered p400 readers and prompts the reader to choose one to use it returns the IP address of the chosen reader.
RegisterReader calls the Stripe API to register a new P400 reader to an account it returns the IP address of the reader if successful.
SetParentTraceID creates a string in a specific format for other methods to use for communicating which transaction a Rabbit Service call is concerning it returns the created trace id string.
SetReaderDisplay calls Rabbit Service to set a cart's contents on the reader display.
SetTransactionContext creates a new transaction context with a baked in start time and unique id.
SetUpTestPayment asks the user for their payment amount / currency, then updates the reader display, then creates a new Payment Intent.
StartNewRPCSession calls the Stripe API for a new RPC session token for interacting with a P400 reader returns a session token when successful.
SummarizeQuickstartCompletion is the success text that is output once the quickstart flow is completed.
WaitForPaymentCollection is a recursive function that calls Rabbit Service to query the status of the payment that is waiting to be collected (ie.

# Constants

this is a lookup for ActivationTypeLabels.
this is a lookup for ActivationTypeLabels.

# Variables

ActivationTypeLabels defines the string values offered as options to the user to prompt them to choose a new or registered reader We use these strings in a few places so defining them here cuts down on brittleness if they change.
ErrActivateReaderFailed is for when a new RPC session could not be created for the reader.
ErrCapturePaymentIntentFailed is for when you need to manually collect the Payment Intent after a Payment Method is attached and it failed.
ErrClearReaderDisplayFailed is for when you're canceling a payment collection and need to reset the display back to default splash but it failed.
ErrCollectPaymentFailed is for when the Rabbit call for the reader to go into collect payment state failed.
ErrCollectPaymentTimeout is for when the user didn't boop the card on the reader in a reasonable time.
ErrConfirmPaymentFailed is for when the Rabbit call to confirm the payment method collected has failed.
ErrConnectionTokenFailed is for when the call to Stripe for a new Terminal connection token went wonky.
ErrDiscoverReadersFailed is for when the call to Stripe failed for listing the readers registered to user's account.
ErrDNSFailed is for when a reader's address could not be resolved by DNS while attempting to contact it via Rabbit Service.
ErrNewPaymentIntentFailed is for when calling Stripe for a new shiny Payment Intent failed.
ErrNewRPCSessionFailed is for when a new RPC Session (via the Stripe API not Rabbit) could not be created.
ErrNoReadersRegistered is for when a user has elected to use a registered reader but the list for their account returns empty.
ErrQueryPaymentFailed is for when you're polling Rabbit to see if the user has booped their card on the reader yet but something went wrong.
ErrRabbitRequestCreationFailed is for when a Rabbit Service request is being rolled and the first stage of setting it up with the http client instance fails.
ErrReaderSelectionFailed is for when the user quit the CLI at the reader choice prompt.
ErrRegisterReaderFailed is for when adding the reader via the Stripe API could not be completed (likely bad reg code).
ErrSetReaderDisplayFailed is for when the Rabbit call to update the reader display didn't work as planned.
ErrStripeForbiddenResponse is for when a Stripe API call fails due to Terminal resource calls not supporting restricted keys.
ErrStripeGenericResponse is for when any non status code happens for a Stripe call that isn't a 200 or a 403.

# Structs

AppModel belongs to the Rabbit Service RPC call payload shape.
Cart belongs to the ReaderDisplayContent protobuf sent to Rabbit Service that updates the reader display.
ChargeAmount belongs to the ReaderCollectPaymentContent protobuf send to Rabbit Service for collecting a specific payment after the Payment Intent is created.
ConfirmedPaymentIntent belongs to ReaderConfirmPaymentResponse.
DeviceInfo belongs to the Rabbit Service RPC call payload shape.
HardwareModel belongs to the Rabbit Service RPC call payload shape.
LineItem belongs to the Cart protobuf shape for updating the reader display via Rabbit Service.
Metadata belongs to the Stripe P400 reader object we don't currently make use of it directly for quickstart.
PaymentMethod exists only so that you can pass a pointer reference of it to generate an actual empty payment method object when using JSON serialization and have it not be serialized as null.
POSInfo belongs to the Rabbit Service RPC call payload shape.
POSSoftwareInfo belongs to the Rabbit Service RPC call payload shape.
RabbitServicePayload represents the JSON shape of all request bodies when calling Rabbit Service.
RabbitServiceResponse is the response body from the Rabbit Service call.
Reader represents the Stripe P400 reader object shape.
ReaderActivateContent represents the shape of the serialized protobuf sent to Rabbit Service for activating a terminal session.
ReaderActivateResponse is the RPC response from calling the activateTerminal method.
ReaderCollectPaymentContent represents the shape of the serialized protobuf sent to Rabbit Service for collecting a payment for a specific Payment Intent.
ReaderConfirmPaymentContent represents the shape of the serialized protobuf sent to Rabbit Service for confirming a payment after it is collectedf.
ReaderConfirmPaymentResponse is the decoded RPC response from calling the processPayment reader method.
ReaderDisplayClearContent represents the shape of the serialized protobuf sent to Rabbit Service for clearing the reader display.
ReaderDisplayContent represents the shape of the serialized protobuf sent to Rabbit Service for updating the reader display.
ReaderQueryPaymentContent represents the shape of the serialized protobuf sent to Rabbit Service for querying a payment for its collection state.
ReaderQueryPaymentResponse is the decoded RPC response from calling the queryPaymentMethod reader method.
TerminalSessionContext is a type that contains important context most methods need to know to complete the quickstart flow one copy of this is passed around a lot and is mutable for whenever a property needs to change.
TransactionContext belongs to each Rabbit Service protobuf payload and communicates the state and identity of the current transaction.
Transport is used when we're tracing a Rabbit Service call, in order to surface DNS and connectivity related data / errors it helps provide a more specific / succinct error to the user in order to be more helpful when they run into trouble.