Setting un invoice pdf microservice

This commit is contained in:
2024-08-26 22:49:10 +02:00
parent 6547b6ac85
commit 08fb20d7be
10 changed files with 382 additions and 14 deletions

View File

@ -33,7 +33,7 @@ type stripePayload struct {
LastName string `json:"last_name"`
}
type jsonResponse struct {
type JSONResponse struct {
OK bool `json:"ok"`
Message string `json:"message,omitempty"`
Content string `json:"content,omitempty"`
@ -63,7 +63,7 @@ func (app *application) GetPaymentIntent(w http.ResponseWriter, r *http.Request)
pi, msg, err := card.Charge(payload.Currency, amount)
if err != nil {
j := jsonResponse{
j := JSONResponse{
OK: false,
Message: msg,
Content: "",
@ -190,7 +190,7 @@ func (app *application) CreateCustomerAndSubscribeToPlan(w http.ResponseWriter,
}
}
resp := jsonResponse{
resp := JSONResponse{
OK: okay,
Message: txnMsg,
}
@ -340,7 +340,7 @@ func (app *application) CheckAuthentication(w http.ResponseWriter, r *http.Reque
}
// valid user
var payload jsonResponse
var payload JSONResponse
payload.OK = true
payload.Message = fmt.Sprintf("authenticated user %s", user.Email)
app.writeJSON(w, http.StatusOK, payload)
@ -423,7 +423,7 @@ func (app *application) SendPasswordResetEmail(w http.ResponseWriter, r *http.Re
// verify that email exists
_, err = app.DB.GetUserByEmail(payload.Email)
if err != nil {
resp := jsonResponse{
resp := JSONResponse{
OK: false,
Message: "No matching email found on our system",
}
@ -458,7 +458,7 @@ func (app *application) SendPasswordResetEmail(w http.ResponseWriter, r *http.Re
return
}
resp := jsonResponse{
resp := JSONResponse{
OK: true,
}
@ -509,7 +509,7 @@ func (app *application) ResetPassword(w http.ResponseWriter, r *http.Request) {
return
}
resp := jsonResponse{
resp := JSONResponse{
OK: true,
Message: "Password reset.",
}
@ -649,7 +649,7 @@ func (app *application) RefundCharge(w http.ResponseWriter, r *http.Request) {
return
}
var resp jsonResponse
var resp JSONResponse
resp.OK = true
resp.Message = "Charge refunded"
@ -696,7 +696,7 @@ func (app *application) CancelSubscription(w http.ResponseWriter, r *http.Reques
return
}
var resp jsonResponse
var resp JSONResponse
resp.OK = true
resp.Message = "Subscription canceled"
@ -775,7 +775,7 @@ func (app *application) EditUser(w http.ResponseWriter, r *http.Request) {
}
}
var resp jsonResponse
var resp JSONResponse
resp.OK = true
app.writeJSON(w, http.StatusOK, resp)
}
@ -789,7 +789,7 @@ func (app *application) DeleteUser(w http.ResponseWriter, r *http.Request) {
app.badRequest(w, r, err)
return
}
var resp jsonResponse
var resp JSONResponse
resp.OK = true
app.writeJSON(w, http.StatusOK, resp)
}