square

package
v1.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SquareSupportedCurrencies

func SquareSupportedCurrencies() []currency.Type

SquareSupportedCurrencies returns currencies Square supports

Types

type Config

type Config struct {
	AccessToken   string
	LocationID    string
	WebhookSecret string
	Environment   string // "sandbox" or "production"
}

Config holds Square processor configuration

type SquareProcessor

type SquareProcessor struct {
	*processor.BaseProcessor
	// contains filtered or unexported fields
}

SquareProcessor implements the processor.PaymentProcessor interface

func NewProcessor

func NewProcessor(cfg Config) *SquareProcessor

NewProcessor creates a new Square processor

func (*SquareProcessor) AddPaymentMethod added in v1.36.4

func (sp *SquareProcessor) AddPaymentMethod(ctx context.Context, customerID, token string) (string, error)

AddPaymentMethod attaches a card nonce (token) to an existing Square customer. Returns the card-on-file ID.

func (*SquareProcessor) Authorize

Authorize authorizes a payment without capturing

func (*SquareProcessor) CancelAuthorization added in v1.37.0

func (sp *SquareProcessor) CancelAuthorization(ctx context.Context, paymentID string) error

CancelAuthorization voids a previously authorized (uncaptured) payment. Call this immediately after a successful pre-auth to release the hold.

func (*SquareProcessor) Capture

func (sp *SquareProcessor) Capture(ctx context.Context, transactionID string, amount currency.Cents) (*processor.PaymentResult, error)

Capture captures a previously authorized payment

func (*SquareProcessor) Charge

Charge processes a payment

func (*SquareProcessor) CreateCustomer added in v1.36.4

func (sp *SquareProcessor) CreateCustomer(ctx context.Context, email, name string, metadata map[string]interface{}) (string, error)

CreateCustomer creates a customer profile in Square. Returns the Square customer ID on success.

func (*SquareProcessor) DeleteCustomer added in v1.36.4

func (sp *SquareProcessor) DeleteCustomer(ctx context.Context, customerID string) error

DeleteCustomer removes a Square customer profile.

func (*SquareProcessor) GetCustomer added in v1.36.4

func (sp *SquareProcessor) GetCustomer(ctx context.Context, customerID string) (map[string]interface{}, error)

GetCustomer retrieves a Square customer profile by ID.

func (*SquareProcessor) GetTransaction

func (sp *SquareProcessor) GetTransaction(ctx context.Context, txID string) (*processor.Transaction, error)

GetTransaction retrieves transaction details

func (*SquareProcessor) IsAvailable

func (sp *SquareProcessor) IsAvailable(ctx context.Context) bool

IsAvailable checks if the processor is configured and available

func (*SquareProcessor) Refund

Refund processes a refund

func (*SquareProcessor) RemovePaymentMethod added in v1.36.4

func (sp *SquareProcessor) RemovePaymentMethod(ctx context.Context, customerID, paymentMethodID string) error

RemovePaymentMethod disables (deletes) a card on file from a Square customer.

func (*SquareProcessor) Type

Type returns the processor type

func (*SquareProcessor) UpdateCustomer added in v1.36.4

func (sp *SquareProcessor) UpdateCustomer(ctx context.Context, customerID string, updates map[string]interface{}) error

UpdateCustomer updates mutable fields on a Square customer profile. Recognised keys: email, name, note.

func (*SquareProcessor) ValidateWebhook

func (sp *SquareProcessor) ValidateWebhook(ctx context.Context, payload []byte, signature string) (*processor.WebhookEvent, error)

ValidateWebhook validates an incoming webhook and parses the event.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL