feat: notify supplier and client after payment is done

This commit is contained in:
2023-07-19 21:01:35 +02:00
parent b426a36570
commit e80e75cb8c
9 changed files with 161 additions and 39 deletions

View File

@@ -28,16 +28,18 @@ func (o *Order) WithExpiration(expiration time.Duration) *Order {
return o
}
func (o *Order) NewOrder(ctx context.Context, OrderID string, ClientID string, amount float64) (*domain.Order, error) {
func (o *Order) NewOrder(ctx context.Context, orderID, clientID, email string, amount float64) (*domain.Order, error) {
order := domain.Order{
ID: primitive.NewObjectID(),
OrderID: OrderID,
ClientID: ClientID,
OrderID: orderID,
ClientID: clientID,
Amount: amount,
PaidAt: time.Time{},
CreatedAt: time.Now(),
ExpiresAt: time.Now().Add(o.expiration),
Email: email,
}
_, err := o.repo.Insert(ctx, &order)
if err != nil {
return nil, err
@@ -49,6 +51,6 @@ func (o *Order) FromAmount(ctx context.Context, amount float64, timestamp time.T
return o.repo.FromAmount(ctx, amount, timestamp)
}
func (o *Order) OrderCompleted(ctx context.Context, order *domain.Order) error {
func (o *Order) OrderCompleted(ctx context.Context, order *domain.Order) (*domain.Order, error) {
return o.repo.OrderCompleted(ctx, order)
}