Documentation ¶
Overview ¶
Package service contains the controllers used by the the API endpoints.
Index ¶
- Constants
- Variables
- func GetCompanyName(companyNumber string, req *http.Request) (string, error)
- func GetPaymentInformation(id string, req *http.Request) (*validators.PaymentInformation, error)
- func GetTransactionForPenalty(companyNumber, penaltyNumber string) (*models.TransactionListItem, error)
- func MarkTransactionsAsPaid(svc *PayableResourceService, client *e5.Client, ...) error
- func SendEmailKafkaMessage(payableResource models.PayableResource, req *http.Request) error
- type PayableResourceService
- func (s *PayableResourceService) GetPayableResource(req *http.Request, companyNumber string, reference string) (*models.PayableResource, ResponseType, error)
- func (s *PayableResourceService) RecordE5CommandError(resource models.PayableResource, action e5.Action) error
- func (s *PayableResourceService) UpdateAsPaid(resource models.PayableResource, payment validators.PaymentInformation) error
- type PaymentDetailsService
- type ResponseType
- type TransactionType
Constants ¶
const ProducerSchemaName = "email-send"
ProducerSchemaName is the schema which will be used to send the email-send kafka message with
const ProducerTopic = "email-send"
ProducerTopic is the topic to which the email-send kafka message is sent
Variables ¶
var ( // ErrPaymentNotFulfilled represents the scenario that the payment resource itself is not paid ErrPaymentNotFulfilled = errors.New("the resource you are trying to pay for has not been paid") // ErrAlreadyPaid represents when the LFP payable resource is already paid ErrAlreadyPaid = errors.New("the LFP has already been paid") // ErrLFPNotFound represents when the payable resource does not exist in the db ErrLFPNotFound = errors.New("the LFP does not exist") // ErrPayment represents an error when the payable resource amount does not match the amount in the payment resource ErrPayment = errors.New("there was a problem validating the payment") )
Functions ¶
func GetCompanyName ¶
GetCompanyName will attempt to get the company name from the CompanyProfileAPI.
func GetPaymentInformation ¶
func GetPaymentInformation(id string, req *http.Request) (*validators.PaymentInformation, error)
GetPaymentInformation will attempt to get the payment resource from the payment platform. this can then be used to validate the state of a payment.
func GetTransactionForPenalty ¶
func GetTransactionForPenalty(companyNumber, penaltyNumber string) (*models.TransactionListItem, error)
GetTransactionForPenalty returns a single, specified, transaction from e5 for a specific company
func MarkTransactionsAsPaid ¶
func MarkTransactionsAsPaid(svc *PayableResourceService, client *e5.Client, resource models.PayableResource, payment validators.PaymentInformation) error
MarkTransactionsAsPaid will update the transactions in E5 as paid. resource - is the payable resource from the db representing the late filing penalty(ies) payment - is the information about the payment session
func SendEmailKafkaMessage ¶
func SendEmailKafkaMessage(payableResource models.PayableResource, req *http.Request) error
SendEmailKafkaMessage sends a kafka message to the email-sender to send an email
Types ¶
type PayableResourceService ¶
PayableResourceService contains the DAO for db access
func (*PayableResourceService) GetPayableResource ¶
func (s *PayableResourceService) GetPayableResource(req *http.Request, companyNumber string, reference string) (*models.PayableResource, ResponseType, error)
GetPayableResource retrieves the payable resource with the given company number and reference from the database
func (*PayableResourceService) RecordE5CommandError ¶
func (s *PayableResourceService) RecordE5CommandError(resource models.PayableResource, action e5.Action) error
RecordE5CommandError will mark the resource as having failed to update E5.
func (*PayableResourceService) UpdateAsPaid ¶
func (s *PayableResourceService) UpdateAsPaid(resource models.PayableResource, payment validators.PaymentInformation) error
UpdateAsPaid will update the resource as paid and persist the changes in the database
type PaymentDetailsService ¶
type PaymentDetailsService struct {
PayableResourceService *PayableResourceService // needed when implemnting PATCH endpoint from payment-processed-consumer
}
PaymentDetailsService contains the PayableResourceService for updating the resource with payment details after a successful/failed payment
func (*PaymentDetailsService) GetPaymentDetailsFromPayableResource ¶
func (service *PaymentDetailsService) GetPaymentDetailsFromPayableResource(req *http.Request, payable *models.PayableResource) (*models.PaymentDetails, ResponseType, error)
GetPaymentDetailsFromPayableResource transforms a PayableResource into its corresponding Payment details resource
type ResponseType ¶
type ResponseType int
ResponseType enumerates the types of authentication supported
const ( // InvalidData response InvalidData ResponseType = iota // Error response Error // Forbidden response Forbidden // NotFound response NotFound // Success response Success )
func GetPenalties ¶
func GetPenalties(companyNumber string) (*models.TransactionListResponse, ResponseType, error)
GetPenalties is a function that: 1. makes a request to e5 to get a list of transactions for the specified company 2. takes the results of this request and maps them to a format that the lfp-pay-web can consume
func (ResponseType) String ¶
func (a ResponseType) String() string
String representation of `ResponseType`
type TransactionType ¶
type TransactionType int
TransactionType Enum Type
const ( Penalty TransactionType = 1 + iota Other )
Enumeration containing all possible types when mapping e5 transactions
func (TransactionType) String ¶
func (transactionType TransactionType) String() string