concardis

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoSuchID404Error = errors.New("payment link id not found")
	DownstreamError  = errors.New("downstream unavailable - see log for details")
	NotSuccessful    = errors.New("response body status field did not indicate success")
)
View Source
var FixedSignatureValue string

FixedSignatureValue set for automated contract testing only

Functions

func Create

func Create() (err error)

Types

type ConcardisDownstream

type ConcardisDownstream interface {
	CreatePaymentLink(ctx context.Context, request PaymentLinkCreateRequest) (PaymentLinkCreated, error)
	QueryPaymentLink(ctx context.Context, id uint) (PaymentLinkQueryResponse, error)
	DeletePaymentLink(ctx context.Context, id uint) error

	QueryTransactions(ctx context.Context, timeGreaterThan time.Time, timeLessThan time.Time) ([]TransactionData, error)
}

func Get

func Get() ConcardisDownstream

func NewTestingClient

func NewTestingClient(verifierClient aurestclientapi.Client) ConcardisDownstream

type Impl

type Impl struct {
	// contains filtered or unexported fields
}
func (i *Impl) CreatePaymentLink(ctx context.Context, request PaymentLinkCreateRequest) (PaymentLinkCreated, error)
func (i *Impl) DeletePaymentLink(ctx context.Context, id uint) error
func (i *Impl) QueryPaymentLink(ctx context.Context, id uint) (PaymentLinkQueryResponse, error)

func (*Impl) QueryTransactions

func (i *Impl) QueryTransactions(ctx context.Context, timeGreaterThan time.Time, timeLessThan time.Time) ([]TransactionData, error)

type Invoice

type Invoice struct {
	ReferenceID      string `json:"referenceId"`
	PaymentRequestId uint   `json:"paymentRequestId"` // the payment link id
	Currency         string `json:"currency"`         // "EUR"
	OriginalAmount   int64  `json:"originalAmount"`
	RefundedAmount   int64  `json:"refundedAmount"`
}

type Mock

type Mock interface {
	ConcardisDownstream

	Reset()
	Recording() []string
	SimulateError(err error)
	InjectTransaction(tx TransactionData)
	ManipulateStatus(paylinkId uint, status string)
}

func CreateMock

func CreateMock() Mock

type Payment

type Payment struct {
	Brand string `json:"brand"`
}

type PaymentLinkCreateRequest

type PaymentLinkCreateRequest struct {
	Title       string  `json:"title"`
	Description string  `json:"description"`
	PSP         uint64  `json:"psp"`
	ReferenceId string  `json:"referenceId"`
	OrderId     string  `json:"concardisOrderId"`
	Purpose     string  `json:"purpose"`
	Amount      int64   `json:"amount"`  // in cents
	VatRate     float64 `json:"vatRate"` // in %
	Currency    string  `json:"currency"`
	SKU         string  `json:"sku"`
	Email       string  `json:"email"`

	SuccessRedirectUrl string `json:"successRedirectUrl"` // optional - leave empty
	FailedRedirectUrl  string `json:"failedRedirectUrl"`  // optional - leave empty
}

PaymentLinkCreateRequest contains the data to construct the paylink create request body.

Note that the json field names are not actually used because the Concardis API doesn't accept JSON, and instead insists on a slightly unusual XWwwFormUrlencoded request.

type PaymentLinkCreated

type PaymentLinkCreated struct {
	ID          uint   `json:"id"`
	ReferenceID string `json:"referenceId"`
	Link        string `json:"link"`
}

type PaymentLinkInvoice

type PaymentLinkInvoice struct {
	ReferenceID      string            `json:"referenceId"`
	PaymentRequestId uint              `json:"paymentRequestId"` // the payment link id
	Currency         string            `json:"currency"`
	Amount           int64             `json:"amount"`
	Transactions     []TransactionData `json:"transactions"`
}

type PaymentLinkQueryResponse

type PaymentLinkQueryResponse struct {
	ID          uint                 `json:"id"` // not the payment link id!
	Status      string               `json:"status"`
	ReferenceID string               `json:"referenceId"`
	Link        string               `json:"link"`
	Invoices    []PaymentLinkInvoice `json:"invoices"`
	Name        string               `json:"name"`
	Purpose     map[string]string    `json:"purpose"`
	Amount      int64                `json:"amount"`
	Currency    string               `json:"currency"`
	CreatedAt   int64                `json:"createdAt"`
	VatRate     float64              `json:"vatRate"`
}

type TransactionData

type TransactionData struct {
	ID          int64   `json:"id"`
	UUID        string  `json:"uuid"` // sent as merchantOrderId
	Amount      int64   `json:"amount"`
	Status      string  `json:"status"` // react to declined, confirmed, authorized, what else?
	Time        string  `json:"time"`   // take effective date from first 10 chars (ISO Date)
	Lang        string  `json:"lang"`   // ISO 639-1 of shopper language (de, en)
	PageUUID    string  `json:"pageUuid"`
	Payment     Payment `json:"payment"`
	Psp         string  `json:"psp"`   // Name of the payment service provider used, for example "ConCardis_PayEngine_3"
	PspID       int64   `json:"pspId"` // ID of the Psp
	Mode        string  `json:"mode"`  // "LIVE", "TEST"
	ReferenceID string  `json:"referenceId"`
	Invoice     Invoice `json:"invoice"`
}

Jump to

Keyboard shortcuts

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