flamingo.me/flamingo-commerce/v3@v3.11.0/checkout/domain/placeorder/states/wait_for_customer.go (about) 1 package states 2 3 import ( 4 "context" 5 6 "flamingo.me/flamingo-commerce/v3/checkout/domain/placeorder/process" 7 "flamingo.me/flamingo-commerce/v3/payment/application" 8 "go.opencensus.io/trace" 9 ) 10 11 type ( 12 // WaitForCustomer state 13 WaitForCustomer struct { 14 paymentService *application.PaymentService 15 validator process.PaymentValidatorFunc 16 } 17 ) 18 19 var _ process.State = WaitForCustomer{} 20 21 // Inject dependencies 22 func (wc *WaitForCustomer) Inject( 23 paymentService *application.PaymentService, 24 validator process.PaymentValidatorFunc, 25 ) *WaitForCustomer { 26 wc.paymentService = paymentService 27 wc.validator = validator 28 29 return wc 30 } 31 32 // Name get state name 33 func (WaitForCustomer) Name() string { 34 return "WaitForCustomer" 35 } 36 37 // Run the state operations 38 func (wc WaitForCustomer) Run(ctx context.Context, p *process.Process) process.RunResult { 39 ctx, span := trace.StartSpan(ctx, "placeorder/state/WaitForCustomer/Run") 40 defer span.End() 41 42 return wc.validator(ctx, p, wc.paymentService) 43 } 44 45 // Rollback the state operations 46 func (wc WaitForCustomer) Rollback(ctx context.Context, _ process.RollbackData) error { 47 return nil 48 } 49 50 // IsFinal if state is a final state 51 func (wc WaitForCustomer) IsFinal() bool { 52 return false 53 }