pay

package
v0.1591.0-weblatepr.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package pay provides a client for GOV.UK's Pay service.

Index

Constants

This section is empty.

Variables

View Source
var EvidenceDeliveryValues = EvidenceDeliveryOptions{
	Upload: Upload,
	Post:   Post,
}
View Source
var FeeTypeValues = FeeTypeOptions{
	FullFee:              FullFee,
	HalfFee:              HalfFee,
	NoFee:                NoFee,
	HardshipFee:          HardshipFee,
	RepeatApplicationFee: RepeatApplicationFee,
}
View Source
var PreviousFeeValues = PreviousFeeOptions{
	Full:      PreviousFeeFull,
	Half:      PreviousFeeHalf,
	Exemption: PreviousFeeExemption,
	Hardship:  PreviousFeeHardship,
}

Functions

func Cost added in v0.795.0

func Cost(feeType FeeType, previousFee PreviousFee, costOfRepeatApplication CostOfRepeatApplication) int

Types

type AmountPence added in v0.1311.0

type AmountPence int

func (AmountPence) Pence added in v0.1311.0

func (a AmountPence) Pence() int

func (AmountPence) String added in v0.1311.0

func (a AmountPence) String() string

type AuthorisationSummary

type AuthorisationSummary struct {
	ThreeDSecure ThreeDSecure `json:"three_d_secure"`
}

type BillingAddress

type BillingAddress struct {
	Line1    string `json:"line1"`
	Line2    string `json:"line2"`
	Postcode string `json:"postcode"`
	City     string `json:"city"`
	Country  string `json:"country"`
}

type CardDetails

type CardDetails struct {
	CardBrand             string         `json:"card_brand"`
	CardType              string         `json:"card_type"`
	LastDigitsCardNumber  string         `json:"last_digits_card_number"`
	FirstDigitsCardNumber string         `json:"first_digits_card_number"`
	ExpiryDate            string         `json:"expiry_date"`
	CardholderName        string         `json:"cardholder_name"`
	BillingAddress        BillingAddress `json:"billing_address"`
}

type Client

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

func New added in v0.1183.0

func New(logger Logger, doer Doer, baseURL, apiKey string) *Client

func (*Client) CanRedirect added in v0.1226.0

func (c *Client) CanRedirect(url string) bool

func (*Client) CreatePayment

func (c *Client) CreatePayment(ctx context.Context, lpaUID string, body CreatePaymentBody) (*CreatePaymentResponse, error)

func (*Client) GetPayment

func (c *Client) GetPayment(ctx context.Context, paymentID string) (GetPaymentResponse, error)

type CostOfRepeatApplication added in v0.1569.0

type CostOfRepeatApplication uint8
const (
	CostOfRepeatApplicationNoFee CostOfRepeatApplication = iota + 1
	CostOfRepeatApplicationHalfFee
)

func ParseCostOfRepeatApplication added in v0.1569.0

func ParseCostOfRepeatApplication(s string) (CostOfRepeatApplication, error)

func (CostOfRepeatApplication) Empty added in v0.1569.0

func (i CostOfRepeatApplication) Empty() bool

func (CostOfRepeatApplication) IsHalfFee added in v0.1569.0

func (i CostOfRepeatApplication) IsHalfFee() bool

func (CostOfRepeatApplication) IsNoFee added in v0.1569.0

func (i CostOfRepeatApplication) IsNoFee() bool

func (CostOfRepeatApplication) MarshalText added in v0.1569.0

func (i CostOfRepeatApplication) MarshalText() ([]byte, error)

func (CostOfRepeatApplication) String added in v0.1569.0

func (i CostOfRepeatApplication) String() string

func (*CostOfRepeatApplication) UnmarshalText added in v0.1569.0

func (i *CostOfRepeatApplication) UnmarshalText(text []byte) error

type CostOfRepeatApplicationOptions added in v0.1569.0

type CostOfRepeatApplicationOptions struct {
	NoFee   CostOfRepeatApplication
	HalfFee CostOfRepeatApplication
}

type CreatePaymentBody

type CreatePaymentBody struct {
	Amount      int    `json:"amount"`
	Reference   string `json:"reference"`
	Description string `json:"description"`
	ReturnURL   string `json:"return_url"`
	Email       string `json:"email"`
	Language    string `json:"language"`
}

type CreatePaymentResponse

type CreatePaymentResponse struct {
	CreatedDate     time.Time       `json:"created_date"`
	State           State           `json:"State"`
	Links           map[string]Link `json:"_links"`
	Amount          int             `json:"amount"`
	Reference       string          `json:"reference"`
	Description     string          `json:"description"`
	ReturnURL       string          `json:"return_url"`
	PaymentID       string          `json:"payment_id"`
	PaymentProvider string          `json:"payment_provider"`
	ProviderID      string          `json:"provider_id"`
}

type Doer

type Doer interface {
	Do(r *http.Request) (*http.Response, error)
}

type EvidenceDelivery added in v0.795.0

type EvidenceDelivery uint8
const (
	Upload EvidenceDelivery = iota + 1 // upload
	Post                               // post
)

func ParseEvidenceDelivery added in v0.795.0

func ParseEvidenceDelivery(s string) (EvidenceDelivery, error)

func (EvidenceDelivery) Empty added in v0.795.0

func (i EvidenceDelivery) Empty() bool

func (EvidenceDelivery) IsPost added in v0.795.0

func (i EvidenceDelivery) IsPost() bool

func (EvidenceDelivery) IsUpload added in v0.795.0

func (i EvidenceDelivery) IsUpload() bool

func (EvidenceDelivery) MarshalText added in v0.912.0

func (i EvidenceDelivery) MarshalText() ([]byte, error)

func (EvidenceDelivery) String added in v0.795.0

func (i EvidenceDelivery) String() string

func (*EvidenceDelivery) UnmarshalText added in v0.1095.0

func (i *EvidenceDelivery) UnmarshalText(text []byte) error

type EvidenceDeliveryOptions added in v0.795.0

type EvidenceDeliveryOptions struct {
	Upload EvidenceDelivery
	Post   EvidenceDelivery
}

type FeeType added in v0.795.0

type FeeType uint8
const (
	FullFee FeeType = iota
	HalfFee
	NoFee
	HardshipFee
	RepeatApplicationFee
)

func ParseFeeType added in v0.795.0

func ParseFeeType(s string) (FeeType, error)

func (FeeType) IsFullFee added in v0.795.0

func (i FeeType) IsFullFee() bool

func (FeeType) IsHalfFee added in v0.795.0

func (i FeeType) IsHalfFee() bool

func (FeeType) IsHardshipFee added in v0.795.0

func (i FeeType) IsHardshipFee() bool

func (FeeType) IsNoFee added in v0.795.0

func (i FeeType) IsNoFee() bool

func (FeeType) IsRepeatApplicationFee added in v0.795.0

func (i FeeType) IsRepeatApplicationFee() bool

func (FeeType) MarshalText added in v0.912.0

func (i FeeType) MarshalText() ([]byte, error)

func (FeeType) String added in v0.795.0

func (i FeeType) String() string

func (*FeeType) UnmarshalText added in v0.1095.0

func (i *FeeType) UnmarshalText(text []byte) error

type FeeTypeOptions added in v0.795.0

type FeeTypeOptions struct {
	FullFee              FeeType
	HalfFee              FeeType
	NoFee                FeeType
	HardshipFee          FeeType
	RepeatApplicationFee FeeType
}

type GetPaymentResponse

type GetPaymentResponse struct {
	CreatedDate time.Time   `json:"created_date"`
	AmountPence AmountPence `json:"amount"`
	State       State       `json:"State"`
	Description string      `json:"description"`
	Reference   string      `json:"reference"`
	Language    string      `json:"language"`
	//May be useful but until we define if/what we send in CreatePayment we can't marshal the response
	//
	//Metadata    struct {
	//	LedgerCode                string `json:"ledger_code"`
	//	AnInternalReferenceNumber int    `json:"an_internal_reference_number"`
	//} `json:"metadata"`
	Email                  string               `json:"email"`
	CardDetails            CardDetails          `json:"card_details"`
	PaymentID              string               `json:"payment_id"`
	AuthorisationSummary   AuthorisationSummary `json:"authorisation_summary"`
	RefundSummary          RefundSummary        `json:"refund_summary"`
	SettlementSummary      SettlementSummary    `json:"settlement_summary"`
	DelayedCapture         bool                 `json:"delayed_capture"`
	Moto                   bool                 `json:"moto"`
	CorporateCardSurcharge int                  `json:"corporate_card_surcharge"`
	TotalAmount            int                  `json:"total_amount"`
	Fee                    int                  `json:"fee"`
	NetAmount              int                  `json:"net_amount"`
	PaymentProvider        string               `json:"payment_provider"`
	ProviderID             string               `json:"provider_id"`
	ReturnURL              string               `json:"return_url"`
}
type Link struct {
	Href   string `json:"href"`
	Method string `json:"method"`
}

type Logger added in v0.1183.0

type Logger interface {
	ErrorContext(ctx context.Context, msg string, args ...any)
}

type PreviousFee added in v0.795.0

type PreviousFee uint8
const (
	PreviousFeeFull PreviousFee = iota + 1
	PreviousFeeHalf
	PreviousFeeExemption
	PreviousFeeHardship
)

func ParsePreviousFee added in v0.795.0

func ParsePreviousFee(s string) (PreviousFee, error)

func (PreviousFee) Empty added in v0.795.0

func (i PreviousFee) Empty() bool

func (PreviousFee) IsExemption added in v0.1569.0

func (i PreviousFee) IsExemption() bool

func (PreviousFee) IsFull added in v0.1569.0

func (i PreviousFee) IsFull() bool

func (PreviousFee) IsHalf added in v0.1569.0

func (i PreviousFee) IsHalf() bool

func (PreviousFee) IsHardship added in v0.1569.0

func (i PreviousFee) IsHardship() bool

func (PreviousFee) MarshalText added in v0.912.0

func (i PreviousFee) MarshalText() ([]byte, error)

func (PreviousFee) String added in v0.795.0

func (i PreviousFee) String() string

func (*PreviousFee) UnmarshalText added in v0.1095.0

func (i *PreviousFee) UnmarshalText(text []byte) error

type PreviousFeeOptions added in v0.795.0

type PreviousFeeOptions struct {
	Full      PreviousFee
	Half      PreviousFee
	Exemption PreviousFee
	Hardship  PreviousFee
}

type RefundSummary

type RefundSummary struct {
	Status          string      `json:"status"`
	AmountAvailable AmountPence `json:"amount_available"`
}

type SettlementSummary

type SettlementSummary struct {
	CaptureSubmitTime time.Time `json:"capture_submit_time"`
	CapturedDate      date.Date `json:"captured_date"`
	SettledDate       date.Date `json:"settled_date"`
}

type State

type State struct {
	Status   string `json:"status"`
	Finished bool   `json:"finished"`
}

type ThreeDSecure

type ThreeDSecure struct {
	Required bool `json:"required"`
}

Jump to

Keyboard shortcuts

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