flamingo.me/flamingo-commerce/v3@v3.11.0/payment/interfaces/webpayment.go (about)

     1  package interfaces
     2  
     3  import (
     4  	"context"
     5  	"net/url"
     6  
     7  	"flamingo.me/flamingo-commerce/v3/cart/domain/cart"
     8  	"flamingo.me/flamingo-commerce/v3/cart/domain/placeorder"
     9  	"flamingo.me/flamingo-commerce/v3/payment/domain"
    10  )
    11  
    12  //go:generate go run github.com/vektra/mockery/v2@v2.42.3 --name WebCartPaymentGateway --case snake
    13  
    14  type (
    15  	// WebCartPaymentGatewayProvider defines the map of providers for payment providers
    16  	WebCartPaymentGatewayProvider func() map[string]WebCartPaymentGateway
    17  
    18  	// WebCartPaymentGateway is an interface offering (online) payment service - most probably against a external payment gateway API
    19  	WebCartPaymentGateway interface {
    20  		// Methods returns the PaymentGateway available Payment Methods
    21  		Methods() []domain.Method
    22  
    23  		// StartFlow returns the data for a new flow
    24  		StartFlow(ctx context.Context, cart *cart.Cart, correlationID string, returnURL *url.URL) (*domain.FlowResult, error)
    25  
    26  		// FlowStatus returns the status of a previously started flow (see StartFlow())
    27  		FlowStatus(ctx context.Context, cart *cart.Cart, correlationID string) (*domain.FlowStatus, error)
    28  
    29  		// ConfirmResult used to finally confirm the result
    30  		ConfirmResult(ctx context.Context, cart *cart.Cart, cartPayment *placeorder.Payment) error
    31  
    32  		// OrderPaymentFromFlow generates a place order payment for a previously created flow
    33  		OrderPaymentFromFlow(ctx context.Context, cart *cart.Cart, correlationID string) (*placeorder.Payment, error)
    34  
    35  		// CancelOrderPayment cancels the place order payment
    36  		CancelOrderPayment(ctx context.Context, cartPayment *placeorder.Payment) error
    37  	}
    38  )