Skip to content

Commit a68901e

Browse files
committed
Fix bug with saving transactions in order
1 parent 85c5e87 commit a68901e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

api/payments.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ func (a *API) PaymentCreate(w http.ResponseWriter, r *http.Request) error {
234234
// PaymentConfirm allows client to confirm if a pending transaction has been completed. Updates transaction and order
235235
func (a *API) PaymentConfirm(w http.ResponseWriter, r *http.Request) error {
236236
ctx := r.Context()
237+
log := getLogEntry(r)
237238

238239
payID := chi.URLParam(r, "payment_id")
239240
trans, httpErr := a.getTransaction(payID)
@@ -252,10 +253,12 @@ func (a *API) PaymentConfirm(w http.ResponseWriter, r *http.Request) error {
252253
}
253254
}
254255

255-
log := getLogEntry(r)
256-
order, httpErr := queryForOrder(a.db, trans.OrderID, log)
257-
if httpErr != nil {
258-
return httpErr
256+
order := &models.Order{}
257+
if rsp := a.db.Find(order, "id = ?", trans.OrderID); rsp.Error != nil {
258+
if rsp.RecordNotFound() {
259+
return notFoundError("Order not found")
260+
}
261+
return internalServerError("Error while querying for order").WithInternalError(rsp.Error)
259262
}
260263
if order.PaymentProcessor == "" {
261264
return badRequestError("Order does not specify a payment provider")

0 commit comments

Comments
 (0)