Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OrderResponse ¶
type OrderResponse struct {
Order SquareOrder `json:"order"`
}
type Payment ¶
type Payment interface { // CreateOrder creates a new order with the payment provider and returns the external order ID // and optional URL to the payment page CreateOrder(order types.Order) (string, *url.URL, error) // ValidateOrderPaid checks if the order with the provided external ID has been paid for ValidateOrderPaid(externalOrderID string) (bool, error) }
type PaymentLinkResponse ¶
type PaymentLinkResponse struct { PaymentLink struct { ID string `json:"id"` Version int `json:"version"` OrderID string `json:"order_id"` CheckoutOptions struct { AllowTipping bool `json:"allow_tipping"` RedirectURL string `json:"redirect_url"` AskForShippingAddress bool `json:"ask_for_shipping_address"` ShippingFee struct { Name string `json:"name"` Charge struct { Amount int `json:"amount"` Currency string `json:"currency"` } `json:"charge"` } `json:"shipping_fee"` } `json:"checkout_options"` URL string `json:"url"` LongURL string `json:"long_url"` CreatedAt time.Time `json:"created_at"` } `json:"payment_link"` RelatedResources struct { Orders []SquareOrder `json:"orders"` } `json:"related_resources"` }
type Square ¶
type Square struct {
// contains filtered or unexported fields
}
func NewSquare ¶
func NewSquare(token string, domain string, redirectUrl url.URL, locationID string) (*Square, error)
NewSquare creates a new Square payment handler configured to use the provided token for authentication and the provided domain for the Square API. This should be _just_ the domain name, not the full URL. Will fail if the URL can't parse.
Redirect URL is the URL that the user will be redirected to after they complete their order and location ID is the ID of the square location to use for the order
func NewSquareFromEnv ¶
NewSquareFromEnv is a helper function to create a new Square payment handler from configuration given by environment variable
func (*Square) CreateOrder ¶
type SquareErrorResponse ¶
type SquareOrder ¶
type SquareOrder struct { ID string `json:"id"` LocationID string `json:"location_id"` ReferenceID string `json:"reference_id"` CustomerID string `json:"customer_id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` State string `json:"state"` Version int `json:"version"` }
SquareOrder is the abbreviated struct for the Square Order API, only including the fields we actually need