Documentation
¶
Index ¶
- Variables
- type BridgeDescription
- type CardDetails
- type CardToken
- type CardTokenType
- type ChargeParams
- type ChargeToken
- type Company
- type Cost
- type Currency
- type Customer
- type Date
- type DeliveryChannel
- type Discount
- type DiscountCode
- type DiscountType
- type DiscountUseRecord
- type EncodedCardDetails
- type FlowType
- type ID
- type Location
- type NewDiscountCode
- type PaymentBridge
- type Product
- type ProductList
- type ProviderType
- type Quantity
- type RefundParams
- type RefundToken
- type Repository
- type Sale
- type SaleRepresentation
- type SaleState
- type SalesEngine
- func (e *SalesEngine) ChargeSale(c context.Context, req *proto.ChargeSaleRequest) (*proto.ChargeToken, error)
- func (e *SalesEngine) ChargeSaleAuto(c context.Context, req *proto.ChargeSaleAutoRequest) (*proto.ChargeToken, error)
- func (e *SalesEngine) ChargeSaleWithNativeToken(c context.Context, req *proto.ChargeWithNativeToken) (*proto.ChargeToken, error)
- func (e *SalesEngine) CreateDiscountCode(c context.Context, req *proto.DiscountCodeRequest) (*proto.DiscountCode, error)
- func (e *SalesEngine) DeleteCardToken(c context.Context, req *proto.CardTokenByID) (*proto.CardToken, error)
- func (e *SalesEngine) DeleteDiscountCode(c context.Context, req *proto.DiscountCodeID) (*proto.DiscountCodes, error)
- func (e *SalesEngine) DeliverSale(c context.Context, req *proto.DeliverSaleRequest) (*proto.DeliverChannelResponse, error)
- func (e *SalesEngine) DoneSale(c context.Context, req *proto.SaleIDRequest) (*proto.Sale, error)
- func (e *SalesEngine) GetActiveDiscountCodes(c context.Context, req *proto.ActiveDiscountsRequest) (*proto.DiscountCodes, error)
- func (e *SalesEngine) GetCardTokenOfCustomerByID(c context.Context, req *proto.CardTokenByID) (*proto.CardToken, error)
- func (e *SalesEngine) GetDiscountCode(c context.Context, req *proto.DiscountCodeID) (*proto.DiscountCode, error)
- func (e *SalesEngine) GetSale(c context.Context, req *proto.SaleIDRequest) (*proto.Sale, error)
- func (e *SalesEngine) GetSales(c context.Context, req *proto.SalesFilterRequest) (*proto.Sales, error)
- func (e *SalesEngine) NewCardToken(c context.Context, req *proto.NewCardTokenRequest) (*proto.CardToken, error)
- func (e *SalesEngine) NewCardTokenAuto(c context.Context, req *proto.NewCardTokenAutoRequest) (*proto.CardToken, error)
- func (e *SalesEngine) NewCardTokenFromNative(c context.Context, req *proto.NewCardTokenNativeRequest) (*proto.CardToken, error)
- func (e *SalesEngine) NewFastSale(c context.Context, req *proto.FastSale) (*proto.Sale, error)
- func (e *SalesEngine) NewSale(c context.Context, req *proto.NewSaleRequest) (*proto.Sale, error)
- func (e *SalesEngine) UpdateSale(c context.Context, req *proto.SaleUpdateRequest) (*proto.Sale, error)
- func (e *SalesEngine) ValidateDiscountCode(c context.Context, req *proto.DiscountCodeValue) (*proto.DiscountCodeExist, error)
- type SupportContact
- type Transaction
- type TransactionSnapshot
- type TransactionState
Constants ¶
This section is empty.
Variables ¶
AvailableCurrencies is a map with available currencies
var ErrInvalidBridge error = errors.New("your bridge are invalid, please choose a valid bridge")
var ErrNotAvailableBridges error = errors.New("unavailable bridges, please configure one less bridge")
var PEN = &Currency{
Name: "PEN",
Code: "PEN",
Symbol: "s/",
}
PEN represents a Peruvian Currency
var USD = &Currency{
Name: "USD",
Code: "USD",
Symbol: "$",
}
USD represents an American Dollar
Functions ¶
This section is empty.
Types ¶
type BridgeDescription ¶
type BridgeDescription struct {
Name string
Version string
Type ProviderType
CanGenerateCardToken bool
CanMakeCharge bool
CanMakeRefund bool
}
BridgeDescription is used to describe a bridge, it's a fast overview the capabilities of this bridge
type CardDetails ¶
CardDetails represents a minimal details to encode your card sensible deatils
func (*CardDetails) Validate ¶
func (card *CardDetails) Validate(mods ...string) bool
type CardToken ¶
type CardToken struct {
ID string
Value string
Type CardTokenType
Provider ProviderType
WithCard EncodedCardDetails
CreatedAt time.Time
}
CardToken represents a basic token generated by the charger service
type CardTokenType ¶
type CardTokenType string
CardTokenType represents a type of token from your charger service
var OneUseToken CardTokenType = "one_use"
OneUseToken is a one use token from your charger
var RecurrentToken CardTokenType = "recurrent"
RecurrentToken is a saved card to recurrent use in your charger service
type ChargeParams ¶
type ChargeParams struct {
Amount float64
Email string
Details string
Currency *Currency
ExtraInfo *Customer
}
ChargeParams represents a minimal params to make a charge with your bridge
type ChargeToken ¶
type ChargeToken struct {
ID string
Value string
Message string
Provider ProviderType
WithCardToken CardToken
CreatedAt time.Time
}
ChargeToken is the reponse from your payment bridge
type Company ¶
type Company struct {
Name string
OfficialWeb string
Support SupportContact
Custom map[string]interface{}
}
Company serves to describe your company
type Customer ¶
type Customer struct {
ID string
Person string
Name string
Email string
Phone string
Location *Location
}
Customer represents a customer minimal information
type DeliveryChannel ¶
type DeliveryChannel interface {
Name() string
DeliverSale(from *Company, sale *Sale, metadata ...map[string]string) (*SaleRepresentation, error)
}
DeliveryChannel a delivery channel is a way to represent and send a voucher of yourtransaction. examples of delivery channel are: SMTP, SMS, ThermalPrint, etc...
type Discount ¶
type Discount struct {
Type DiscountType
Percent float64
Amount float64
Currency *Currency
}
Discount is a discount value
type DiscountCode ¶
type DiscountCode struct {
ID string `storm:"id"`
Start time.Time
End time.Time
MaxUses int
Uses []DiscountUseRecord
Code string
Value *Discount
}
DiscountCode represents a discount promotional code
type DiscountType ¶
type DiscountType string
DiscountType is a type of discount, actually plutus support static or percentual types
var PercentDiscount DiscountType = "percent"
PercentDiscount is a static discount (e.g. 20%)
var StaticDiscount DiscountType = "static"
StaticDiscount is a static discount (e.g. 100PEN)
type DiscountUseRecord ¶
DiscountUseRecord is a record of discount code use
type EncodedCardDetails ¶
EncodedCardDetails represents a encoded card details (hidden complete number and expiration year too)
type FlowType ¶
type FlowType string
FlowType is how the flow of resources (money in this case) is propagated
var Charge FlowType = "charge"
Charge represents a money flow from your customer to you
type NewDiscountCode ¶
type NewDiscountCode struct {
Code string
Start *time.Time
End time.Time
MaxUses int
Value Discount
}
NewDiscountCode is a wrapper to create a new discount code
type PaymentBridge ¶
type PaymentBridge interface {
Description() *BridgeDescription
NewToken(details CardDetails, kind CardTokenType) (*CardToken, error)
MakeCharge(source CardToken, params ChargeParams) (*ChargeToken, error)
MakeRefund(source ChargeToken, params RefundParams) (*RefundToken, error)
}
PaymentBridge is an abstraction layer for your charger ends
type ProductList ¶
ProductList is a quantized list of products
type ProviderType ¶
type ProviderType int
const CULQI ProviderType = 0
const DUMMY ProviderType = 4
const PAYPAL ProviderType = 1
const STRIPE ProviderType = 3
const VISANET ProviderType = 2
type RefundParams ¶
RefundParams represents a minimal params to make a refund with your bridge
type RefundToken ¶
type RefundToken struct {
ID string `storm:"id"`
Value string `storm:"unique"`
CreatedAt time.Time
}
RefundToken is the reponse from your payment bridge
type Repository ¶
type Repository interface {
SaveCustomer(c context.Context, customer *Customer) (*Customer, error)
GetCustomer(c context.Context, ID string) (*Customer, error)
UpdateCustomer(c context.Context, ID string, updatePayload Customer) (*Customer, error)
RemoveCustomer(c context.Context, ID string) (*Customer, error)
SaveCardToken(c context.Context, cardToken *CardToken) (*CardToken, error)
GetCardToken(c context.Context, ID string) (*CardToken, error)
UpdateCardToken(c context.Context, ID string, updatePayload CardToken) (*CardToken, error)
RemoveCardToken(c context.Context, ID string) (*CardToken, error)
SaveChargeToken(c context.Context, chargeToken *ChargeToken) (*ChargeToken, error)
GetChargeToken(c context.Context, ID string) (*ChargeToken, error)
UpdateChargeToken(c context.Context, ID string, updatePayload ChargeToken) (*ChargeToken, error)
RemoveChargeToken(c context.Context, ID string) (*ChargeToken, error)
SaveSale(c context.Context, sale *Sale) (*Sale, error)
GetSale(c context.Context, ID string) (*Sale, error)
UpdateSale(c context.Context, ID string, updatePayload Sale) (*Sale, error)
RemoveSale(c context.Context, ID string) (*Sale, error)
}
Repository represents a bag where you can to put your basic objects
type Sale ¶
type Sale struct {
ID string `storm:"id"`
CreatedAt time.Time
UpdatedAt time.Time
State SaleState
Customer *Customer
Products []Product
DiscountCodes []DiscountCode
CardToken *CardToken
Charge *ChargeToken
CurrencyToPay *Currency
}
Sale is a bidirectional transaction
type SaleRepresentation ¶
SaleRepresentation is a representation of one sale
type SaleState ¶
type SaleState string
SaleState represents the state of any sale
var Done SaleState = "done"
Done is a done sale
var Draft SaleState = "draft"
Draft is the earliest state of sale
var Null SaleState = "null"
Null is a null sale, only for debug porpuses
var PaidOut SaleState = "pay_out"
PaidOut is a charged sale
var Signed SaleState = "signed"
Signed is a signed and final modeling sale
type SalesEngine ¶
type SalesEngine struct {
Company *Company
Bridges []PaymentBridge
Repository Repository
DeliveryChannels []DeliveryChannel
}
SalesEngine is the core engine of plutus
func (*SalesEngine) ChargeSale ¶
func (e *SalesEngine) ChargeSale(c context.Context, req *proto.ChargeSaleRequest) (*proto.ChargeToken, error)
func (*SalesEngine) ChargeSaleAuto ¶
func (e *SalesEngine) ChargeSaleAuto(c context.Context, req *proto.ChargeSaleAutoRequest) (*proto.ChargeToken, error)
func (*SalesEngine) ChargeSaleWithNativeToken ¶
func (e *SalesEngine) ChargeSaleWithNativeToken(c context.Context, req *proto.ChargeWithNativeToken) (*proto.ChargeToken, error)
func (*SalesEngine) CreateDiscountCode ¶
func (e *SalesEngine) CreateDiscountCode(c context.Context, req *proto.DiscountCodeRequest) (*proto.DiscountCode, error)
func (*SalesEngine) DeleteCardToken ¶
func (e *SalesEngine) DeleteCardToken(c context.Context, req *proto.CardTokenByID) (*proto.CardToken, error)
func (*SalesEngine) DeleteDiscountCode ¶
func (e *SalesEngine) DeleteDiscountCode(c context.Context, req *proto.DiscountCodeID) (*proto.DiscountCodes, error)
func (*SalesEngine) DeliverSale ¶
func (e *SalesEngine) DeliverSale(c context.Context, req *proto.DeliverSaleRequest) (*proto.DeliverChannelResponse, error)
func (*SalesEngine) DoneSale ¶
func (e *SalesEngine) DoneSale(c context.Context, req *proto.SaleIDRequest) (*proto.Sale, error)
func (*SalesEngine) GetActiveDiscountCodes ¶
func (e *SalesEngine) GetActiveDiscountCodes(c context.Context, req *proto.ActiveDiscountsRequest) (*proto.DiscountCodes, error)
func (*SalesEngine) GetCardTokenOfCustomerByID ¶
func (e *SalesEngine) GetCardTokenOfCustomerByID(c context.Context, req *proto.CardTokenByID) (*proto.CardToken, error)
func (*SalesEngine) GetDiscountCode ¶
func (e *SalesEngine) GetDiscountCode(c context.Context, req *proto.DiscountCodeID) (*proto.DiscountCode, error)
func (*SalesEngine) GetSale ¶
func (e *SalesEngine) GetSale(c context.Context, req *proto.SaleIDRequest) (*proto.Sale, error)
func (*SalesEngine) GetSales ¶
func (e *SalesEngine) GetSales(c context.Context, req *proto.SalesFilterRequest) (*proto.Sales, error)
func (*SalesEngine) NewCardToken ¶
func (e *SalesEngine) NewCardToken(c context.Context, req *proto.NewCardTokenRequest) (*proto.CardToken, error)
func (*SalesEngine) NewCardTokenAuto ¶
func (e *SalesEngine) NewCardTokenAuto(c context.Context, req *proto.NewCardTokenAutoRequest) (*proto.CardToken, error)
func (*SalesEngine) NewCardTokenFromNative ¶
func (e *SalesEngine) NewCardTokenFromNative(c context.Context, req *proto.NewCardTokenNativeRequest) (*proto.CardToken, error)
func (*SalesEngine) NewFastSale ¶
func (*SalesEngine) NewSale ¶
func (e *SalesEngine) NewSale(c context.Context, req *proto.NewSaleRequest) (*proto.Sale, error)
func (*SalesEngine) UpdateSale ¶
func (e *SalesEngine) UpdateSale(c context.Context, req *proto.SaleUpdateRequest) (*proto.Sale, error)
func (*SalesEngine) ValidateDiscountCode ¶
func (e *SalesEngine) ValidateDiscountCode(c context.Context, req *proto.DiscountCodeValue) (*proto.DiscountCodeExist, error)
type SupportContact ¶
SupportContact wraps the support contact of your company
type Transaction ¶
type Transaction struct {
ID string
Type FlowType
State TransactionState
Snapshots []*TransactionSnapshot
Give ProductList
Expected ProductList
}
Transaction represents a transaction of money
type TransactionSnapshot ¶
type TransactionSnapshot struct {
At time.Time
Snapshot Transaction
}
TransactionSnapshot is a snapshot of one time transaction
type TransactionState ¶
type TransactionState string
TransactionState is the state of a transaction
var Created TransactionState = "created"
Created is when the transaction eas early created