Skip to content

Commit

Permalink
update GET payment status code and internal language around funcs (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
tigh-latte authored Oct 14, 2021
1 parent b64b67d commit 3b3bdee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion payment_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ type PaymentRequestArgs struct {
// PaymentRequestService can be implemented to enforce business rules
// and process in order to fulfil a PaymentRequest.
type PaymentRequestService interface {
CreatePaymentRequest(ctx context.Context, args PaymentRequestArgs) (*PaymentRequest, error)
PaymentRequest(ctx context.Context, args PaymentRequestArgs) (*PaymentRequest, error)
}
4 changes: 2 additions & 2 deletions service/paymentrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func NewPaymentRequest(walletCfg *config.Server, destRdr p4.DestinationReader, m
}
}

// CreatePaymentRequest handles setting up a new PaymentRequest response and will validate that we have a paymentID.
func (p *paymentRequest) CreatePaymentRequest(ctx context.Context, args p4.PaymentRequestArgs) (*p4.PaymentRequest, error) {
// PaymentRequest handles setting up a new PaymentRequest response and will validate that we have a paymentID.
func (p *paymentRequest) PaymentRequest(ctx context.Context, args p4.PaymentRequestArgs) (*p4.PaymentRequest, error) {
if err := validator.New().
Validate("paymentID", validator.NotEmpty(args.PaymentID)); err.Err() != nil {
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions transports/http/payment_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func NewPaymentRequestHandler(svc p4.PaymentRequestService) *paymentRequestHandl

// RegisterRoutes will setup all routes with an echo group.
func (h *paymentRequestHandler) RegisterRoutes(g *echo.Group) {
g.GET(RoutePaymentRequest, h.createPaymentRequest)
g.GET(RoutePaymentRequest, h.buildPaymentRequest)
}

// createPaymentRequest will setup and return a new payment request.
// buildPaymentRequest will setup and return a new payment request.
// @Summary Request to pay an invoice and receive back outputs to use when constructing the payment transaction
// @Description Creates a payment request based on a payment id (the identifier for an invoice).
// @Tags Payment
Expand All @@ -38,14 +38,14 @@ func (h *paymentRequestHandler) RegisterRoutes(g *echo.Group) {
// @Failure 400 {object} validator.ErrValidation "returned if the user input is invalid, usually an issue with the paymentID"
// @Failure 500 {string} string "returned if there is an unexpected internal error"
// @Router /api/v1/payment/{paymentID} [GET].
func (h *paymentRequestHandler) createPaymentRequest(e echo.Context) error {
func (h *paymentRequestHandler) buildPaymentRequest(e echo.Context) error {
var args p4.PaymentRequestArgs
if err := e.Bind(&args); err != nil {
return errors.Wrap(err, "failed to bind request")
}
resp, err := h.svc.CreatePaymentRequest(e.Request().Context(), args)
resp, err := h.svc.PaymentRequest(e.Request().Context(), args)
if err != nil {
return errors.WithStack(err)
}
return e.JSON(http.StatusCreated, resp)
return e.JSON(http.StatusOK, resp)
}

0 comments on commit 3b3bdee

Please sign in to comment.