paymentlinksrv

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WebhookValidationErr    = errors.New("webhook referenced invalid invoice id, must be positive integer")
	WebhookRefIdMismatchErr = errors.New("webhook reference_id differes from paylink reference_id")
)
View Source
var NowFunc = time.Now

Functions

This section is empty.

Types

type Impl

type Impl struct {
	Now func() time.Time
}
func (i *Impl) CreatePaymentLink(ctx context.Context, data cncrdapi.PaymentLinkRequestDto) (cncrdapi.PaymentLinkDto, uint, error)
func (i *Impl) DeletePaymentLink(ctx context.Context, id uint) error
func (i *Impl) GetPaymentLink(ctx context.Context, id uint) (cncrdapi.PaymentLinkDto, error)

func (*Impl) HandleWebhook

func (i *Impl) HandleWebhook(ctx context.Context, webhook cncrdapi.WebhookEventDto) error

func (*Impl) SendErrorNotifyMail

func (i *Impl) SendErrorNotifyMail(ctx context.Context, operation string, referenceId string, status string) error

func (*Impl) ValidatePaymentLinkRequest

func (i *Impl) ValidatePaymentLinkRequest(ctx context.Context, data cncrdapi.PaymentLinkRequestDto) url.Values

type PaymentLinkService

type PaymentLinkService interface {
	// ValidatePaymentLinkRequest checks the cncrdapi.PaymentLinkRequestDto for validity.
	//
	// The returned url.Values contains detailed error messages that can be used to construct a meaningful response.
	// It is nil if no validation errors were encountered. Any errors encountered are also logged.
	ValidatePaymentLinkRequest(ctx context.Context, data cncrdapi.PaymentLinkRequestDto) url.Values

	// CreatePaymentLink expects an already validated cncrdapi.PaymentLinkRequestDto, and makes a downstream
	// request to create a payment link, returning the cncrdapi.PaymentLinkDto with all its information and the
	// id under which to manage the payment link.
	CreatePaymentLink(ctx context.Context, request cncrdapi.PaymentLinkRequestDto) (cncrdapi.PaymentLinkDto, uint, error)

	// GetPaymentLink obtains the payment link information from the downstream api.
	GetPaymentLink(ctx context.Context, id uint) (cncrdapi.PaymentLinkDto, error)

	// DeletePaymentLink asks the downstream api to delete the given payment link.
	DeletePaymentLink(ctx context.Context, id uint) error

	// HandleWebhook requests the payment link referenced in the webhook data and reacts to any new payments
	HandleWebhook(ctx context.Context, webhook cncrdapi.WebhookEventDto) error

	// SendErrorNotifyMail notifies us about unexpected conditions in this service so we can look at the logs
	SendErrorNotifyMail(ctx context.Context, operation string, referenceId string, status string) error
}

func New

func New() PaymentLinkService

Jump to

Keyboard shortcuts

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