diff --git a/api-tests/cart.http b/api-tests/cart.http index 5568ff1..ed78675 100644 --- a/api-tests/cart.http +++ b/api-tests/cart.http @@ -23,7 +23,7 @@ DELETE https://cart.tornberg.me/api/12345/1 ### Set delivery -POST https://cart.tornberg.me/api/12345/delivery +POST https://cart.tornberg.me/api/1002/delivery Content-Type: application/json { diff --git a/cart-grain.go b/cart-grain.go index 06de6a6..27b2390 100644 --- a/cart-grain.go +++ b/cart-grain.go @@ -8,6 +8,7 @@ import ( "time" messages "git.tornberg.me/go-cart-actor/proto" + klarna "github.com/Flaconi/go-klarna" ) type CartId [16]byte @@ -221,6 +222,11 @@ func (c *CartGrain) FindItemWithSku(sku string) (*CartItem, bool) { return nil, false } +func GetTaxAmount(total int, tax int) int { + taxD := 10000 / float64(tax) + return int(float64(total) / float64((1 + taxD))) +} + func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPayload, error) { if message.TimeStamp == nil { now := time.Now().Unix() @@ -384,7 +390,52 @@ func (c *CartGrain) HandleMessage(message *Message, isReplay bool) (*FrameWithPa break } } - + } + case CreateCheckoutOrderType: + msg, ok := message.Content.(*messages.CreateCheckoutOrder) + if !ok { + err = fmt.Errorf("expected CreateCheckoutOrder") + } else { + orderLines := make([]*klarna.Line, 0, len(c.Items)) + totalTax := 0 + for _, item := range c.Items { + total := int(item.Price) * item.Quantity + taxAmount := GetTaxAmount(total, item.Tax) + totalTax += taxAmount + orderLines = append(orderLines, &klarna.Line{ + Type: "physical", + Reference: item.Sku, + Name: item.Name, + Quantity: item.Quantity, + UnitPrice: int(item.Price), + TaxRate: int(item.Tax), + QuantityUnit: "st", + TotalAmount: total, + TotalTaxAmount: taxAmount, + ImageURL: item.Image, + }) + } + order := klarna.CheckoutOrder{ + PurchaseCountry: "SE", + PurchaseCurrency: "SEK", + Locale: "sv-se", + OrderAmount: int(c.TotalPrice), + OrderTaxAmount: totalTax, + OrderLines: orderLines, + MerchantReference1: c.Id.String(), + MerchantURLS: &klarna.CheckoutMerchantURLS{ + Terms: msg.Terms, + Checkout: msg.Checkout, + Confirmation: msg.Confirmation, + Push: msg.Push, + }, + } + orderPayload, err := json.Marshal(order) + if err != nil { + return nil, err + } + result := MakeFrameWithPayload(RemoteCreateOrderReply, 200, orderPayload) + return &result, nil } default: err = fmt.Errorf("unknown message type %d", message.Type) diff --git a/cart-grain_test.go b/cart-grain_test.go index ddafc40..94d2e9d 100644 --- a/cart-grain_test.go +++ b/cart-grain_test.go @@ -16,6 +16,13 @@ func GetMessage(t uint16, data interface{}) *Message { } } +func TestTaxAmount(t *testing.T) { + taxAmount := GetTaxAmount(12500, 2500) + if taxAmount != 2500 { + t.Errorf("Expected 2500, got %d\n", taxAmount) + } +} + func TestAddToCartShortCut(t *testing.T) { grain, err := spawn(ToCartId("kalle")) if err != nil { diff --git a/go.mod b/go.mod index d3ffa02..ddeea29 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( ) require ( + github.com/Flaconi/go-klarna v0.0.0-20230216165926-e2f708c721d9 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect diff --git a/go.sum b/go.sum index 6b193fd..bbada89 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/Flaconi/go-klarna v0.0.0-20230216165926-e2f708c721d9 h1:U5gu3M9/khqtvgg6iRKo0+nxGEfPHWFHRlKrbZvFxIY= +github.com/Flaconi/go-klarna v0.0.0-20230216165926-e2f708c721d9/go.mod h1:+LVFV9FXH5cwN1VcU30WcNYRs5FhkEtL7/IqqTD42cU= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= diff --git a/message-types.go b/message-types.go index ba70e1f..84a9406 100644 --- a/message-types.go +++ b/message-types.go @@ -3,10 +3,11 @@ package main const ( AddRequestType = 1 AddItemType = 2 - //AddDeliveryType = 3 - RemoveItemType = 4 - RemoveDeliveryType = 5 - ChangeQuantityType = 6 - SetDeliveryType = 7 - SetPickupPointType = 8 + + RemoveItemType = 4 + RemoveDeliveryType = 5 + ChangeQuantityType = 6 + SetDeliveryType = 7 + SetPickupPointType = 8 + CreateCheckoutOrderType = 9 ) diff --git a/packet.go b/packet.go index 4146059..58c223c 100644 --- a/packet.go +++ b/packet.go @@ -6,6 +6,7 @@ const ( ResponseBody = FrameType(0x03) RemoteGetStateReply = FrameType(0x04) RemoteHandleMutationReply = FrameType(0x05) + RemoteCreateOrderReply = FrameType(0x06) ) // type CartPacket struct { diff --git a/pool-server.go b/pool-server.go index f8698da..cfc69f9 100644 --- a/pool-server.go +++ b/pool-server.go @@ -1,9 +1,11 @@ package main import ( + "bytes" "encoding/json" "log" "net/http" + "os" "strconv" messages "git.tornberg.me/go-cart-actor/proto" @@ -198,6 +200,50 @@ func (s *PoolServer) HandleAddRequest(w http.ResponseWriter, r *http.Request) er return s.WriteResult(w, reply) } +var ( + APIUsername = os.Getenv("KLARNA_API_USERNAME") + APIPassword = os.Getenv("KLARNA_API_PASSWORD") +) + +func (s *PoolServer) HandleCheckout(w http.ResponseWriter, r *http.Request) error { + id := r.PathValue("id") + + reply, err := s.pool.Process(ToCartId(id), Message{ + Type: CreateCheckoutOrderType, + Content: &messages.CreateCheckoutOrder{ + Terms: "https://tornberg.me/terms", + Checkout: "https://tornberg.me/checkout", + Confirmation: "https://tornberg.me/confirmation", + Push: "https://cart.tornberg.me/push", + }, + }) + if err != nil { + return err + } + if reply.StatusCode != 200 { + return s.WriteResult(w, reply) + } + + req, err := http.NewRequest("POST", "https://api.playground.klarna.com/checkout/v3/orders", bytes.NewReader(reply.Payload)) + if err != nil { + return err + } + + req.Header.Add("Content-Type", "application/json") + req.SetBasicAuth(APIUsername, APIPassword) + + res, err := http.DefaultClient.Do(req) + if nil != err { + return err + } + + buf := new(bytes.Buffer) + buf.ReadFrom(res.Body) + + w.Write(buf.Bytes()) + return nil +} + func (s *PoolServer) Serve() *http.ServeMux { mux := http.NewServeMux() mux.HandleFunc("GET /{id}", ErrorHandler(s.HandleGet)) @@ -208,5 +254,7 @@ func (s *PoolServer) Serve() *http.ServeMux { mux.HandleFunc("POST /{id}/delivery", ErrorHandler(s.HandleSetDelivery)) mux.HandleFunc("DELETE /{id}/delivery/{deliveryId}", ErrorHandler(s.HandleRemoveDelivery)) mux.HandleFunc("PUT /{id}/delivery/{deliveryId}/pickupPoint", ErrorHandler(s.HandleSetPickupPoint)) + mux.HandleFunc("GET /{id}/checkout", ErrorHandler(s.HandleCheckout)) + return mux } diff --git a/proto/messages.pb.go b/proto/messages.pb.go index 6995f0b..5aa0c92 100644 --- a/proto/messages.pb.go +++ b/proto/messages.pb.go @@ -304,6 +304,10 @@ type SetDelivery struct { Provider string `protobuf:"bytes,1,opt,name=Provider,proto3" json:"provider,omitempty"` Items []int64 `protobuf:"varint,2,rep,packed,name=Items,proto3" json:"items,omitempty"` PickupPoint *PickupPoint `protobuf:"bytes,3,opt,name=PickupPoint,proto3,oneof" json:"pickupPoint,omitempty"` + Country string `protobuf:"bytes,4,opt,name=Country,proto3" json:"country,omitempty"` + Zip string `protobuf:"bytes,5,opt,name=Zip,proto3" json:"zip,omitempty"` + Address *string `protobuf:"bytes,6,opt,name=Address,proto3,oneof" json:"address,omitempty"` + City *string `protobuf:"bytes,7,opt,name=City,proto3,oneof" json:"city,omitempty"` } func (x *SetDelivery) Reset() { @@ -357,6 +361,34 @@ func (x *SetDelivery) GetPickupPoint() *PickupPoint { return nil } +func (x *SetDelivery) GetCountry() string { + if x != nil { + return x.Country + } + return "" +} + +func (x *SetDelivery) GetZip() string { + if x != nil { + return x.Zip + } + return "" +} + +func (x *SetDelivery) GetAddress() string { + if x != nil && x.Address != nil { + return *x.Address + } + return "" +} + +func (x *SetDelivery) GetCity() string { + if x != nil && x.City != nil { + return *x.City + } + return "" +} + type SetPickupPoint struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -580,6 +612,75 @@ func (x *RemoveDelivery) GetId() int64 { return 0 } +type CreateCheckoutOrder struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Terms string `protobuf:"bytes,1,opt,name=Terms,proto3" json:"terms,omitempty"` + Checkout string `protobuf:"bytes,2,opt,name=Checkout,proto3" json:"checkout,omitempty"` + Confirmation string `protobuf:"bytes,3,opt,name=Confirmation,proto3" json:"confirmation,omitempty"` + Push string `protobuf:"bytes,4,opt,name=Push,proto3" json:"push,omitempty"` +} + +func (x *CreateCheckoutOrder) Reset() { + *x = CreateCheckoutOrder{} + mi := &file_messages_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateCheckoutOrder) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateCheckoutOrder) ProtoMessage() {} + +func (x *CreateCheckoutOrder) ProtoReflect() protoreflect.Message { + mi := &file_messages_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateCheckoutOrder.ProtoReflect.Descriptor instead. +func (*CreateCheckoutOrder) Descriptor() ([]byte, []int) { + return file_messages_proto_rawDescGZIP(), []int{8} +} + +func (x *CreateCheckoutOrder) GetTerms() string { + if x != nil { + return x.Terms + } + return "" +} + +func (x *CreateCheckoutOrder) GetCheckout() string { + if x != nil { + return x.Checkout + } + return "" +} + +func (x *CreateCheckoutOrder) GetConfirmation() string { + if x != nil { + return x.Confirmation + } + return "" +} + +func (x *CreateCheckoutOrder) GetPush() string { + if x != nil { + return x.Push + } + return "" +} + var File_messages_proto protoreflect.FileDescriptor var file_messages_proto_rawDesc = []byte{ @@ -612,7 +713,7 @@ var file_messages_proto_rawDesc = []byte{ 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x22, 0x8d, 0x01, 0x0a, 0x0b, 0x53, + 0x52, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x22, 0x86, 0x02, 0x0a, 0x0b, 0x53, 0x65, 0x74, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, @@ -620,41 +721,57 @@ var file_messages_proto_rawDesc = []byte{ 0x50, 0x69, 0x63, 0x6b, 0x75, 0x70, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x50, 0x69, 0x63, 0x6b, 0x75, 0x70, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x50, 0x69, 0x63, 0x6b, - 0x75, 0x70, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x88, 0x01, 0x01, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x50, - 0x69, 0x63, 0x6b, 0x75, 0x70, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0xf9, 0x01, 0x0a, 0x0e, 0x53, - 0x65, 0x74, 0x50, 0x69, 0x63, 0x6b, 0x75, 0x70, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1e, 0x0a, - 0x0a, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x0a, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x49, 0x64, 0x12, 0x0e, 0x0a, - 0x02, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, 0x12, 0x17, 0x0a, - 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x4e, - 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x43, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x04, 0x43, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x12, 0x15, - 0x0a, 0x03, 0x5a, 0x69, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x03, 0x52, 0x03, 0x5a, - 0x69, 0x70, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x48, 0x04, 0x52, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, - 0x79, 0x88, 0x01, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x0a, 0x0a, - 0x08, 0x5f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x43, 0x69, - 0x74, 0x79, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x5a, 0x69, 0x70, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x43, - 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x22, 0xd6, 0x01, 0x0a, 0x0b, 0x50, 0x69, 0x63, 0x6b, 0x75, - 0x70, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, + 0x75, 0x70, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x88, 0x01, 0x01, 0x12, 0x18, 0x0a, 0x07, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x43, 0x6f, 0x75, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x5a, 0x69, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x5a, 0x69, 0x70, 0x12, 0x1d, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x43, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x04, 0x43, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x42, 0x0e, + 0x0a, 0x0c, 0x5f, 0x50, 0x69, 0x63, 0x6b, 0x75, 0x70, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x42, 0x0a, + 0x0a, 0x08, 0x5f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x43, + 0x69, 0x74, 0x79, 0x22, 0xf9, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x74, 0x50, 0x69, 0x63, 0x6b, 0x75, + 0x70, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, + 0x72, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x44, 0x65, 0x6c, 0x69, + 0x76, 0x65, 0x72, 0x79, 0x49, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, - 0x1d, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x1d, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x88, 0x01, 0x01, 0x12, 0x17, - 0x0a, 0x04, 0x43, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x04, - 0x43, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x12, 0x15, 0x0a, 0x03, 0x5a, 0x69, 0x70, 0x18, 0x05, + 0x0a, 0x04, 0x43, 0x69, 0x74, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x04, + 0x43, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x12, 0x15, 0x0a, 0x03, 0x5a, 0x69, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x03, 0x52, 0x03, 0x5a, 0x69, 0x70, 0x88, 0x01, 0x01, 0x12, 0x1d, - 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, + 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x48, 0x04, 0x52, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x88, 0x01, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x43, 0x69, 0x74, 0x79, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x5a, 0x69, 0x70, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x22, - 0x20, 0x0a, 0x0e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, - 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x49, - 0x64, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x3b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0xd6, 0x01, 0x0a, 0x0b, 0x50, 0x69, 0x63, 0x6b, 0x75, 0x70, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, + 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, 0x12, + 0x17, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, + 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x07, 0x41, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x43, 0x69, 0x74, 0x79, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x04, 0x43, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, + 0x12, 0x15, 0x0a, 0x03, 0x5a, 0x69, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x03, 0x52, + 0x03, 0x5a, 0x69, 0x70, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, + 0x72, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x04, 0x52, 0x07, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x72, 0x79, 0x88, 0x01, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x4e, 0x61, 0x6d, 0x65, 0x42, + 0x0a, 0x0a, 0x08, 0x5f, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x5f, + 0x43, 0x69, 0x74, 0x79, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x5a, 0x69, 0x70, 0x42, 0x0a, 0x0a, 0x08, + 0x5f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x20, 0x0a, 0x0e, 0x52, 0x65, 0x6d, 0x6f, + 0x76, 0x65, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x49, 0x64, 0x22, 0x7f, 0x0a, 0x13, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x6f, 0x75, 0x74, 0x4f, 0x72, 0x64, 0x65, + 0x72, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x65, 0x72, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x54, 0x65, 0x72, 0x6d, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x6f, 0x75, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x50, 0x75, 0x73, 0x68, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x50, 0x75, 0x73, 0x68, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, + 0x3b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -669,16 +786,17 @@ func file_messages_proto_rawDescGZIP() []byte { return file_messages_proto_rawDescData } -var file_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_messages_proto_goTypes = []any{ - (*AddRequest)(nil), // 0: messages.AddRequest - (*AddItem)(nil), // 1: messages.AddItem - (*RemoveItem)(nil), // 2: messages.RemoveItem - (*ChangeQuantity)(nil), // 3: messages.ChangeQuantity - (*SetDelivery)(nil), // 4: messages.SetDelivery - (*SetPickupPoint)(nil), // 5: messages.SetPickupPoint - (*PickupPoint)(nil), // 6: messages.PickupPoint - (*RemoveDelivery)(nil), // 7: messages.RemoveDelivery + (*AddRequest)(nil), // 0: messages.AddRequest + (*AddItem)(nil), // 1: messages.AddItem + (*RemoveItem)(nil), // 2: messages.RemoveItem + (*ChangeQuantity)(nil), // 3: messages.ChangeQuantity + (*SetDelivery)(nil), // 4: messages.SetDelivery + (*SetPickupPoint)(nil), // 5: messages.SetPickupPoint + (*PickupPoint)(nil), // 6: messages.PickupPoint + (*RemoveDelivery)(nil), // 7: messages.RemoveDelivery + (*CreateCheckoutOrder)(nil), // 8: messages.CreateCheckoutOrder } var file_messages_proto_depIdxs = []int32{ 6, // 0: messages.SetDelivery.PickupPoint:type_name -> messages.PickupPoint @@ -704,7 +822,7 @@ func file_messages_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_messages_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 9, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/messages.proto b/proto/messages.proto index 1481331..6ce97e6 100644 --- a/proto/messages.proto +++ b/proto/messages.proto @@ -62,3 +62,10 @@ message PickupPoint { message RemoveDelivery { int64 Id = 1; } + +message CreateCheckoutOrder { + string Terms = 1; + string Checkout = 2; + string Confirmation = 3; + string Push = 4; +} \ No newline at end of file