Skip to content

Commit 3b3bdee

Browse files
authored
update GET payment status code and internal language around funcs (#30)
1 parent b64b67d commit 3b3bdee

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

payment_request.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ type PaymentRequestArgs struct {
5252
// PaymentRequestService can be implemented to enforce business rules
5353
// and process in order to fulfil a PaymentRequest.
5454
type PaymentRequestService interface {
55-
CreatePaymentRequest(ctx context.Context, args PaymentRequestArgs) (*PaymentRequest, error)
55+
PaymentRequest(ctx context.Context, args PaymentRequestArgs) (*PaymentRequest, error)
5656
}

service/paymentrequest.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ func NewPaymentRequest(walletCfg *config.Server, destRdr p4.DestinationReader, m
2727
}
2828
}
2929

30-
// CreatePaymentRequest handles setting up a new PaymentRequest response and will validate that we have a paymentID.
31-
func (p *paymentRequest) CreatePaymentRequest(ctx context.Context, args p4.PaymentRequestArgs) (*p4.PaymentRequest, error) {
30+
// PaymentRequest handles setting up a new PaymentRequest response and will validate that we have a paymentID.
31+
func (p *paymentRequest) PaymentRequest(ctx context.Context, args p4.PaymentRequestArgs) (*p4.PaymentRequest, error) {
3232
if err := validator.New().
3333
Validate("paymentID", validator.NotEmpty(args.PaymentID)); err.Err() != nil {
3434
return nil, err

transports/http/payment_request.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ func NewPaymentRequestHandler(svc p4.PaymentRequestService) *paymentRequestHandl
2323

2424
// RegisterRoutes will setup all routes with an echo group.
2525
func (h *paymentRequestHandler) RegisterRoutes(g *echo.Group) {
26-
g.GET(RoutePaymentRequest, h.createPaymentRequest)
26+
g.GET(RoutePaymentRequest, h.buildPaymentRequest)
2727
}
2828

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

0 commit comments

Comments
 (0)