payments

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// StripeProvider is the string identifier for the Stripe payment provider.
	StripeProvider = "stripe"
	// PayPalProvider is the string identifier for the PayPal payment provider.
	PayPalProvider = "paypal"
)

Variables

This section is empty.

Functions

func NewPaymentConfirmFailError added in v1.7.1

func NewPaymentConfirmFailError(msg string) error

NewPaymentConfirmFailError creates an error to use when a payment confirmation fails

func NewPaymentPendingError added in v1.7.1

func NewPaymentPendingError(metadata map[string]interface{}) error

NewPaymentPendingError creates an error for a pending action on a payment

Types

type Charger

type Charger func(amount uint64, currency string, order *models.Order, invoiceNumber int64) (string, error)

Charger wraps the Charge method which creates new payments with the provider.

type Confirmer added in v1.7.1

type Confirmer func(paymentID string) error

Confirmer wraps a confirm method used for checking two-step payments in a synchronous flow

type PaymentConfirmFailError added in v1.7.1

type PaymentConfirmFailError struct {
	// contains filtered or unexported fields
}

PaymentConfirmFailError is returned when the confirmation request got a negative response

func (*PaymentConfirmFailError) Error added in v1.7.1

func (p *PaymentConfirmFailError) Error() string

type PaymentPendingError added in v1.7.1

type PaymentPendingError struct {
	// contains filtered or unexported fields
}

PaymentPendingError is returned when the payment provider requests additional action e.g. 2-step authorization through 3D secure

func (*PaymentPendingError) Error added in v1.7.1

func (p *PaymentPendingError) Error() string

func (*PaymentPendingError) Metadata added in v1.7.1

func (p *PaymentPendingError) Metadata() map[string]interface{}

Metadata returns fields that should be passed to the client for use in additional actions

type PreauthorizationResult

type PreauthorizationResult struct {
	ID string `json:"id"`
}

PreauthorizationResult contains the data returned from a Preauthorization.

type Preauthorizer

type Preauthorizer func(amount uint64, currency string, description string) (*PreauthorizationResult, error)

Preauthorizer wraps the Preauthorize method which pre-authorizes a payment with the provider.

type Provider

type Provider interface {
	Name() string
	NewCharger(ctx context.Context, r *http.Request, log logrus.FieldLogger) (Charger, error)
	NewRefunder(ctx context.Context, r *http.Request, log logrus.FieldLogger) (Refunder, error)
	NewPreauthorizer(ctx context.Context, r *http.Request, log logrus.FieldLogger) (Preauthorizer, error)
	NewConfirmer(ctx context.Context, r *http.Request, log logrus.FieldLogger) (Confirmer, error)
}

Provider represents a payment provider that can optionally charge, refund, preauthorize payments.

type Refunder

type Refunder func(transactionID string, amount uint64, currency string) (string, error)

Refunder wraps the Refund method which refunds payments with the provider.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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