Added support for stripe

This commit is contained in:
Borna Rajković committed 2023-07-26 09:51:29 +02:00
1 parent 3de5c8b0f1
commit cefc5314f2
16 files changed
+365 -72

No files matched your search

+2 -18
View File
@@ -2,26 +2,10 @@ package wspay
import (
"github.com/google/uuid"
"payment-poc/state"
"time"
)
type PaymentState string
const (
// initial state
StateInitialized PaymentState = "initialized"
// state on response
StateAccepted PaymentState = "accepted"
StateError PaymentState = "error"
StateCanceledInitialization PaymentState = "canceled_initialization"
// state after confirmation
StateCompleted PaymentState = "completed"
StateVoided PaymentState = "voided"
StateCanceled PaymentState = "canceled"
)
type WsPayDb struct {
Id uuid.UUID `db:"id"`
ShopID string `db:"shop_id"`
@@ -53,5 +37,5 @@ type WsPayDb struct {
ErrorMessage string `db:"error_message"`
ErrorCodes string `db:"error_codes"`
State PaymentState `db:"payment_state"`
State state.PaymentState `db:"payment_state"`
}
+2 -1
View File
@@ -6,6 +6,7 @@ import (
"errors"
"github.com/google/uuid"
"github.com/jmoiron/sqlx"
"payment-poc/state"
"strconv"
)
@@ -20,7 +21,7 @@ func (s *Service) CreateEntry(shopId string, totalAmount int64) (WsPayDb, error)
ShopID: shopId,
ShoppingCartID: id.String(),
TotalAmount: totalAmount,
State: StateInitialized,
State: state.StateInitialized,
}
_, err := s.DB.Exec(`INSERT INTO "wspay" ("id", "shop_id", "shopping_card_id", "total_amount", "payment_state") VALUES ($1, $2, $3, $4, $5)`,
&entry.Id, &entry.ShopID, &entry.ShoppingCartID, &entry.TotalAmount, &entry.State,