Documentation
¶
Index ¶
- Constants
- Variables
- func Currency(c currencyx.Code) string
- func CurrencyPtr(c *currencyx.Code) *string
- func FromStripeCurrency(c stripe.Currency) currencyx.Code
- func IsAPIKeyLiveMode(apiKey string) bool
- func IsStripeCustomerNotFoundError(err error) bool
- func IsStripeInvoiceCustomerTaxLocationInvalidError(err error) bool
- func IsStripePaymentMethodNotFoundError(err error) bool
- type AddInvoiceLinesInput
- type CreateCheckoutSessionInput
- type CreateInvoiceInput
- type CreatePortalSessionInput
- type CreateStripeCustomerInput
- type DeleteInvoiceInput
- type DeleteWebhookInput
- type FinalizeInvoiceInput
- type GetInvoiceInput
- type PortalSession
- type RemoveInvoiceLinesInput
- type SetupWebhookInput
- type StripeAccount
- type StripeAppClient
- type StripeAppClientConfig
- type StripeAppClientFactory
- type StripeCheckoutSession
- type StripeClient
- type StripeClientConfig
- type StripeClientFactory
- type StripeCustomer
- type StripeCustomerAutomaticTax
- type StripeCustomerNotFoundError
- type StripeCustomerTax
- type StripeInvoiceCustomerTaxLocationInvalidError
- type StripeInvoiceItemWithID
- type StripeInvoiceItemWithLineID
- type StripePaymentMethod
- type StripePaymentMethodNotFoundError
- type StripeWebhookEndpoint
- type UpdateInvoiceInput
- type UpdateInvoiceLinesInput
Constants ¶
const ( StripeMetadataNamespace = "om_namespace" StripeMetadataAppID = "om_app_id" StripeMetadataCustomerID = "om_customer_id" StripeMetadataInvoiceID = "om_invoice_id" )
const ( // Occurs when an SetupIntent has successfully setup a payment method. WebhookEventTypeSetupIntentSucceeded = "setup_intent.succeeded" // Occurs when an SetupIntent has failed to set up a payment method. WebhookEventTypeSetupIntentFailed = "setup_intent.setup_failed" // Occurs when a SetupIntent is in requires_action state. WebhookEventTypeSetupIntentRequiresAction = "setup_intent.requires_action" // Occurs whenever a draft invoice cannot be finalized WebhookEventTypeInvoiceFinalizationFailed = "invoice.finalization_failed" // Occurs whenever an invoice is marked uncollectible WebhookEventTypeInvoiceMarkedUncollectible = "invoice.marked_uncollectible" // Occurs X number of days after an invoice becomes due—where X is determined by Automations WebhookEventTypeInvoiceOverdue = "invoice.overdue" // Occurs whenever an invoice payment attempt succeeds or an invoice is marked as paid out-of-band. WebhookEventTypeInvoicePaid = "invoice.paid" // Occurs whenever an invoice payment attempt requires further user action to complete. WebhookEventTypeInvoicePaymentActionRequired = "invoice.payment_action_required" // Occurs whenever an invoice payment attempt fails, due either to a declined payment or to the lack of a stored payment method. WebhookEventTypeInvoicePaymentFailed = "invoice.payment_failed" // Occurs whenever an invoice payment attempt succeeds. WebhookEventTypeInvoicePaymentSucceeded = "invoice.payment_succeeded" // Occurs whenever an invoice email is sent out. WebhookEventTypeInvoiceSent = "invoice.sent" // Occurs whenever an invoice is voided. WebhookEventTypeInvoiceVoided = "invoice.voided" )
Variables ¶
var SetupIntentReservedMetadataKeys = []string{ StripeMetadataNamespace, StripeMetadataAppID, StripeMetadataCustomerID, }
SetupIntentReservedMetadataKeys are the keys that are reserved for internal use by OpenMeter specifying these keys in the metadata will result in a validation error
Functions ¶
func Currency ¶
Stripe uses lowercase three-letter ISO codes for currency codes. See: https://docs.stripe.com/currencies
func CurrencyPtr ¶
CurrencyPtr is a helper function for pointer currency codes.
func FromStripeCurrency ¶
FromStripeCurrency converts a stripe currency code to a currencyx code.
func IsAPIKeyLiveMode ¶
IsAPIKeyLiveMode checks if the API key is a live mode key
Types ¶
type AddInvoiceLinesInput ¶
type AddInvoiceLinesInput struct {
StripeInvoiceID string
Lines []*stripe.InvoiceItemParams
}
AddInvoiceLinesInput is the input for adding lines to an invoice in Stripe.
func (AddInvoiceLinesInput) Validate ¶
func (i AddInvoiceLinesInput) Validate() error
type CreateCheckoutSessionInput ¶
type CreateCheckoutSessionInput struct {
AppID app.AppID
CustomerID customer.CustomerID
StripeCustomerID string
Options api.CreateStripeCheckoutSessionRequestOptions
}
func (CreateCheckoutSessionInput) Validate ¶
func (i CreateCheckoutSessionInput) Validate() error
type CreateInvoiceInput ¶
type CreateInvoiceInput struct {
AppID app.AppID
CustomerID customer.CustomerID
InvoiceID string
AutomaticTaxEnabled bool
CollectionMethod billing.CollectionMethod
Currency currencyx.Code
DaysUntilDue *int64
StatementDescriptor *string
StripeCustomerID string
StripeDefaultPaymentMethodID *string
}
CreateInvoiceInput is the input for creating a new invoice in Stripe.
func (CreateInvoiceInput) Validate ¶
func (i CreateInvoiceInput) Validate() error
type CreatePortalSessionInput ¶
type CreatePortalSessionInput struct {
StripeCustomerID string
ConfigurationID *string
ReturnURL *string
Locale *string
}
CreatePortalSessionInput is the input for creating a customer portal session.
func (CreatePortalSessionInput) Validate ¶
func (i CreatePortalSessionInput) Validate() error
Validate validates the input for creating a customer portal session.
type CreateStripeCustomerInput ¶
type CreateStripeCustomerInput struct {
AppID app.AppID
CustomerID customer.CustomerID
Name *string
Email *string
}
func (CreateStripeCustomerInput) Validate ¶
func (i CreateStripeCustomerInput) Validate() error
type DeleteInvoiceInput ¶
type DeleteInvoiceInput struct {
StripeInvoiceID string
}
DeleteInvoiceInput is the input for deleting an invoice in Stripe.
func (DeleteInvoiceInput) Validate ¶
func (i DeleteInvoiceInput) Validate() error
type DeleteWebhookInput ¶
func (DeleteWebhookInput) Validate ¶
func (i DeleteWebhookInput) Validate() error
type FinalizeInvoiceInput ¶
FinalizeInvoiceInput is the input for finalizing an invoice in Stripe.
func (FinalizeInvoiceInput) Validate ¶
func (i FinalizeInvoiceInput) Validate() error
type GetInvoiceInput ¶
type GetInvoiceInput struct {
StripeInvoiceID string
}
GetInvoice gets an invoice from Stripe.
func (GetInvoiceInput) Validate ¶
func (i GetInvoiceInput) Validate() error
type PortalSession ¶
type PortalSession struct {
// The ID of the customer portal session.
// See: https://docs.stripe.com/api/customer_portal/sessions/object#portal_session_object-id
ID string
// Configuration Configuration used to customize the customer portal.
// See: https://docs.stripe.com/api/customer_portal/sessions/object#portal_session_object-configuration
Configuration *stripe.BillingPortalConfiguration
CreatedAt time.Time
StripeCustomerID string
// Livemode Livemode.
Livemode bool
// Locale Status.
// The IETF language tag of the locale customer portal is displayed in.
// See: https://docs.stripe.com/api/customer_portal/sessions/object#portal_session_object-locale
Locale string
// ReturnUrl Return URL.
// See: https://docs.stripe.com/api/customer_portal/sessions/object#portal_session_object-return_url
ReturnURL string
// The URL to redirect the customer to after they have completed
// their requested actions.
URL string
}
PortalSession is the response from the Stripe API for a customer portal session.
type RemoveInvoiceLinesInput ¶
RemoveInvoiceLinesInput is the input for deleting lines on an invoice in Stripe.
func (RemoveInvoiceLinesInput) Validate ¶
func (i RemoveInvoiceLinesInput) Validate() error
type SetupWebhookInput ¶
func (SetupWebhookInput) Validate ¶
func (i SetupWebhookInput) Validate() error
type StripeAccount ¶
type StripeAccount struct {
StripeAccountID string
BusinessProfile *stripe.AccountBusinessProfile
Country models.CountryCode
}
type StripeAppClient ¶
type StripeAppClient interface {
DeleteWebhook(ctx context.Context, input DeleteWebhookInput) error
GetAccount(ctx context.Context) (StripeAccount, error)
GetCustomer(ctx context.Context, stripeCustomerID string) (StripeCustomer, error)
CreateCustomer(ctx context.Context, input CreateStripeCustomerInput) (StripeCustomer, error)
CreateCheckoutSession(ctx context.Context, input CreateCheckoutSessionInput) (StripeCheckoutSession, error)
GetPaymentMethod(ctx context.Context, stripePaymentMethodID string) (StripePaymentMethod, error)
CreatePortalSession(ctx context.Context, input CreatePortalSessionInput) (PortalSession, error)
// Invoice
GetInvoice(ctx context.Context, input GetInvoiceInput) (*stripe.Invoice, error)
CreateInvoice(ctx context.Context, input CreateInvoiceInput) (*stripe.Invoice, error)
UpdateInvoice(ctx context.Context, input UpdateInvoiceInput) (*stripe.Invoice, error)
DeleteInvoice(ctx context.Context, input DeleteInvoiceInput) error
FinalizeInvoice(ctx context.Context, input FinalizeInvoiceInput) (*stripe.Invoice, error)
// Invoice Line
ListInvoiceLineItems(ctx context.Context, stripeInvoiceID string) ([]*stripe.InvoiceLineItem, error)
AddInvoiceLines(ctx context.Context, input AddInvoiceLinesInput) ([]StripeInvoiceItemWithLineID, error)
UpdateInvoiceLines(ctx context.Context, input UpdateInvoiceLinesInput) ([]*stripe.InvoiceItem, error)
RemoveInvoiceLines(ctx context.Context, input RemoveInvoiceLinesInput) error
}
StripeAppClient is a client for the stripe API for an installed app. It is useful to call the Stripe API after the app is installed.
func NewStripeAppClient ¶
func NewStripeAppClient(config StripeAppClientConfig) (StripeAppClient, error)
type StripeAppClientConfig ¶
type StripeAppClientConfig struct {
AppService app.Service
AppID app.AppID
APIKey string
Logger *slog.Logger
}
func (*StripeAppClientConfig) Validate ¶
func (c *StripeAppClientConfig) Validate() error
type StripeAppClientFactory ¶
type StripeAppClientFactory = func(config StripeAppClientConfig) (StripeAppClient, error)
StripeAppClientFactory is a factory for creating a StripeAppClient for an installed app.
type StripeCheckoutSession ¶
type StripeCheckoutSession struct {
CancelURL *string
ClientSecret *string
ClientReferenceID *string
CustomerEmail *string
Currency *currencyx.Code
CreatedAt time.Time
ExpiresAt *time.Time
Mode stripe.CheckoutSessionMode
Metadata *map[string]string
ReturnURL *string
SessionID string
SetupIntentID string
Status *stripe.CheckoutSessionStatus
SuccessURL *string
URL *string
}
func (StripeCheckoutSession) Validate ¶
func (o StripeCheckoutSession) Validate() error
type StripeClient ¶
type StripeClient interface {
GetAccount(ctx context.Context) (StripeAccount, error)
SetupWebhook(ctx context.Context, input SetupWebhookInput) (StripeWebhookEndpoint, error)
}
StripeClient is a client for the stripe API without an installed app It is useful to call the Stripe API before the app is installed, for example during the app installation process.
func NewStripeClient ¶
func NewStripeClient(config StripeClientConfig) (StripeClient, error)
type StripeClientConfig ¶
func (*StripeClientConfig) Validate ¶
func (c *StripeClientConfig) Validate() error
type StripeClientFactory ¶
type StripeClientFactory = func(config StripeClientConfig) (StripeClient, error)
StripeClientFactory is a factory function to create a StripeClient.
type StripeCustomer ¶
type StripeCustomer struct {
StripeCustomerID string
Name *string
Currency *string
Email *string
// ID of a payment method that’s attached to the customer,
// to be used as the customer’s default payment method for invoices.
DefaultPaymentMethod *StripePaymentMethod
Tax *StripeCustomerTax
}
type StripeCustomerAutomaticTax ¶
type StripeCustomerAutomaticTax string
https://docs.stripe.com/api/customers/object#customer_object-tax-automatic_tax
const ( // There was an error determining the customer’s location. This is usually caused by a temporary issue. Retrieve the customer to try again. StripeCustomerAutomaticTaxFailed StripeCustomerAutomaticTax = "failed" // The customer is located in a country or state where you’re not registered to collect tax. Also returned when automatic tax calculation is not supported in the customer’s location. StripeCustomerAutomaticTaxNotCollecting StripeCustomerAutomaticTax = "not_collecting" // The customer is located in a country or state where you’re collecting tax StripeCustomerAutomaticTaxSupported StripeCustomerAutomaticTax = "supported" // The customer’s location couldn’t be determined. Make sure the provided address information is valid and supported in the customer’s country. StripeCustomerAutomaticTaxUnrecognizedLocation StripeCustomerAutomaticTax = "unrecognized_location" )
type StripeCustomerNotFoundError ¶
type StripeCustomerNotFoundError struct {
// contains filtered or unexported fields
}
func NewStripeCustomerNotFoundError ¶
func NewStripeCustomerNotFoundError(stripeCustomerID string) *StripeCustomerNotFoundError
func (StripeCustomerNotFoundError) Error ¶
func (e StripeCustomerNotFoundError) Error() string
func (StripeCustomerNotFoundError) Unwrap ¶
func (e StripeCustomerNotFoundError) Unwrap() error
type StripeCustomerTax ¶
type StripeCustomerTax struct {
AutomaticTax StripeCustomerAutomaticTax
}
type StripeInvoiceCustomerTaxLocationInvalidError ¶
type StripeInvoiceCustomerTaxLocationInvalidError struct {
// contains filtered or unexported fields
}
func NewStripeInvoiceCustomerTaxLocationInvalidError ¶
func NewStripeInvoiceCustomerTaxLocationInvalidError(stripeInvoiceID string, stripeMessage string) *StripeInvoiceCustomerTaxLocationInvalidError
func (StripeInvoiceCustomerTaxLocationInvalidError) Error ¶
func (e StripeInvoiceCustomerTaxLocationInvalidError) Error() string
func (StripeInvoiceCustomerTaxLocationInvalidError) Unwrap ¶
func (e StripeInvoiceCustomerTaxLocationInvalidError) Unwrap() error
type StripeInvoiceItemWithID ¶
type StripeInvoiceItemWithID struct {
*stripe.InvoiceItemParams
ID string
}
type StripeInvoiceItemWithLineID ¶
type StripeInvoiceItemWithLineID struct {
*stripe.InvoiceItem
LineID string
}
type StripePaymentMethod ¶
type StripePaymentMethodNotFoundError ¶
type StripePaymentMethodNotFoundError struct {
// contains filtered or unexported fields
}
func NewStripePaymentMethodNotFoundError ¶
func NewStripePaymentMethodNotFoundError(stripePaymentMethodID string) *StripePaymentMethodNotFoundError
func (StripePaymentMethodNotFoundError) Error ¶
func (e StripePaymentMethodNotFoundError) Error() string
func (StripePaymentMethodNotFoundError) Unwrap ¶
func (e StripePaymentMethodNotFoundError) Unwrap() error
type StripeWebhookEndpoint ¶
type UpdateInvoiceInput ¶
type UpdateInvoiceInput struct {
AutomaticTaxEnabled bool
StripeInvoiceID string
StatementDescriptor *string
}
UpdateInvoiceInput is the input for updating an invoice in Stripe.
func (UpdateInvoiceInput) Validate ¶
func (i UpdateInvoiceInput) Validate() error
type UpdateInvoiceLinesInput ¶
type UpdateInvoiceLinesInput struct {
StripeInvoiceID string
Lines []*StripeInvoiceItemWithID
}
UpdateInvoiceLinesInput is the input for updating lines on an invoice in Stripe.
func (UpdateInvoiceLinesInput) Validate ¶
func (i UpdateInvoiceLinesInput) Validate() error