flamingo.me/flamingo-commerce/v3@v3.11.0/checkout/domain/placeorder/states/show_iframe.go (about)

     1  package states
     2  
     3  import (
     4  	"context"
     5  	"encoding/gob"
     6  	"net/url"
     7  
     8  	"flamingo.me/flamingo-commerce/v3/checkout/domain/placeorder/process"
     9  	"flamingo.me/flamingo-commerce/v3/payment/application"
    10  	"go.opencensus.io/trace"
    11  )
    12  
    13  type (
    14  	// ShowIframe state
    15  	ShowIframe struct {
    16  		paymentService *application.PaymentService
    17  		validator      process.PaymentValidatorFunc
    18  	}
    19  )
    20  
    21  var _ process.State = ShowIframe{}
    22  
    23  func init() {
    24  	gob.Register(&url.URL{})
    25  }
    26  
    27  // NewShowIframeStateData creates new state data for this state
    28  func NewShowIframeStateData(url *url.URL) process.StateData {
    29  	return process.StateData(url)
    30  }
    31  
    32  // Inject dependencies
    33  func (si *ShowIframe) Inject(
    34  	paymentService *application.PaymentService,
    35  	validator process.PaymentValidatorFunc,
    36  ) *ShowIframe {
    37  	si.paymentService = paymentService
    38  	si.validator = validator
    39  
    40  	return si
    41  }
    42  
    43  // Name get state name
    44  func (ShowIframe) Name() string {
    45  	return "ShowIframe"
    46  }
    47  
    48  // Run the state operations
    49  func (si ShowIframe) Run(ctx context.Context, p *process.Process) process.RunResult {
    50  	ctx, span := trace.StartSpan(ctx, "placeorder/state/ShowIframe/Run")
    51  	defer span.End()
    52  
    53  	return si.validator(ctx, p, si.paymentService)
    54  }
    55  
    56  // Rollback the state operations
    57  func (si ShowIframe) Rollback(ctx context.Context, _ process.RollbackData) error {
    58  	return nil
    59  }
    60  
    61  // IsFinal if state is a final state
    62  func (si ShowIframe) IsFinal() bool {
    63  	return false
    64  }