split cart and checkout and checkout vs payments
This commit is contained in:
28
pkg/checkout/mutation_payment_declined.go
Normal file
28
pkg/checkout/mutation_payment_declined.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package checkout
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
messages "git.k6n.net/go-cart-actor/proto/checkout"
|
||||
)
|
||||
|
||||
func asPointer[T any](value T) *T {
|
||||
return &value
|
||||
}
|
||||
|
||||
var ErrPaymentNotFound = errors.New("payment not found")
|
||||
|
||||
func HandlePaymentDeclined(g *CheckoutGrain, m *messages.PaymentDeclined) error {
|
||||
|
||||
payment, found := g.FindPayment(m.PaymentId)
|
||||
if !found {
|
||||
return ErrPaymentNotFound
|
||||
}
|
||||
|
||||
payment.CompletedAt = asPointer(time.Now())
|
||||
payment.Status = "failed"
|
||||
g.PaymentInProgress--
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user