syntax = "proto3";

package wix.payment.api.pay.v3;

import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "wix/common/address.proto";
import "wix/payment/api/pay/v3/resources/payment-details.proto";
import "wix/api/validations.proto";

option java_package = "com.wix.payment.api.pay.v3";

message Order {
    string id                                                       = 1;

    // Wix app order ID
    string wix_app_order_id                                         = 2;

    // Wix app buyer ID
    google.protobuf.StringValue wix_app_buyer_id                    = 3;

    // Items included in the order
    repeated OrderItem items                                        = 4;

    // total number of items in order
    // items_total_count > `items`.size if `items` doesn't contain all items
    int32 items_total_count                                         = 5;

    // Additional charges to the order - e.g., tax, shipping or discount (optional)
    OrderAdditionalCharges additional_charges                       = 6;

    // Customer's shipping address (optional)
    wix.common.Address shipping_address                             = 7;

    // Customer's shipping address details (optional)
    wix.common.FullAddressContactDetails shipping_address_contacts  = 8;

    // Order creation date
    google.protobuf.Timestamp created_at                            = 9;

    // External data which is stored with the order
    map<string, string> external_data                               = 10;

    // Vertical invoice ID
    google.protobuf.StringValue vertical_invoice_id                 = 11 [(wix.api.maxLength) = 200];

    // the part of total amount taken by platform from the amount sent to merchant
    google.protobuf.DoubleValue platform_fee                        = 12 [(.wix.api.min) = 0];
}

// Describing any additional charges in the order. They are not required, but can't be added later.
message OrderAdditionalCharges {
    // Absolute taxes charged to the order
    double tax      = 1;
    // Shipping cost charged to the order
    double shipping = 2;
    // Discount amount applied to the order
    double discount = 4;
    // Application fee
    double application_fee = 5;
}

// Item included in order
message OrderItem {
    // Order item ID (required)
    string id                   = 1;
    // Order item name (required)
    string name                 = 2;
    // Quantity (required)
    int32 quantity              = 3;
    // Total price charged for this item in the order - quantity * price (required)
    double price                = 4;
    // Order item description
    string description          = 5;
    // Weight of one item
    double weight_in_kg         = 6;
    // Whether the item is a physical a digital product
    OrderItemCategory category  = 7;

    // Order item type
    enum OrderItemCategory {
        UNDEFINED         = 0;
        // Physical product
        PHYSICAL          = 1;
        // Digital product
        DIGITAL           = 2;
    }
}
