Documentation
¶
Index ¶
- func SquareSupportedCurrencies() []currency.Type
- type Config
- type SquareProcessor
- func (sp *SquareProcessor) AddPaymentMethod(ctx context.Context, customerID, token string) (string, error)
- func (sp *SquareProcessor) Authorize(ctx context.Context, req processor.PaymentRequest) (*processor.PaymentResult, error)
- func (sp *SquareProcessor) CancelAuthorization(ctx context.Context, paymentID string) error
- func (sp *SquareProcessor) Capture(ctx context.Context, transactionID string, amount currency.Cents) (*processor.PaymentResult, error)
- func (sp *SquareProcessor) Charge(ctx context.Context, req processor.PaymentRequest) (*processor.PaymentResult, error)
- func (sp *SquareProcessor) CreateCustomer(ctx context.Context, email, name string, metadata map[string]interface{}) (string, error)
- func (sp *SquareProcessor) DeleteCustomer(ctx context.Context, customerID string) error
- func (sp *SquareProcessor) GetCustomer(ctx context.Context, customerID string) (map[string]interface{}, error)
- func (sp *SquareProcessor) GetTransaction(ctx context.Context, txID string) (*processor.Transaction, error)
- func (sp *SquareProcessor) IsAvailable(ctx context.Context) bool
- func (sp *SquareProcessor) Refund(ctx context.Context, req processor.RefundRequest) (*processor.RefundResult, error)
- func (sp *SquareProcessor) RemovePaymentMethod(ctx context.Context, customerID, paymentMethodID string) error
- func (sp *SquareProcessor) Type() processor.ProcessorType
- func (sp *SquareProcessor) UpdateCustomer(ctx context.Context, customerID string, updates map[string]interface{}) error
- func (sp *SquareProcessor) ValidateWebhook(ctx context.Context, payload []byte, signature string) (*processor.WebhookEvent, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SquareSupportedCurrencies ¶
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 ¶
func (sp *SquareProcessor) Authorize(ctx context.Context, req processor.PaymentRequest) (*processor.PaymentResult, error)
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 ¶
func (sp *SquareProcessor) Charge(ctx context.Context, req processor.PaymentRequest) (*processor.PaymentResult, error)
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 ¶
func (sp *SquareProcessor) Refund(ctx context.Context, req processor.RefundRequest) (*processor.RefundResult, error)
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 ¶
func (sp *SquareProcessor) Type() processor.ProcessorType
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.