syntax = "proto3";

package wix.payment.api.pay.v2;

import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";

import "wix/api/annotations.proto";
import "wix/api/validations.proto";
import "wix/payment/api/pay/v2/resources/address.proto";
import "wix/payment/api/pay/v2/resources/order-additional-charges.proto";
import "wix/payment/api/pay/v2/resources/order-buyer-info.proto";
import "wix/payment/api/pay/v2/resources/order-item.proto";
import "wix/payment/api/pay/v2/resources/subscription.proto";

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

// Describing the order:
// * what is bought (items, shipping, tax)
// * payment type (one-time, subscription)
// * info about the buyer
// * billing and shipping addresses
// * external references
message OrderDescription {
  // total amount of this order for `ONE_TIME` order or one payment amount for `SUBSCRIPTION` order (required). Only positive values.
  double amount                     = 1;
  // Currency of the order (required). Supported values are:
  // `AFN`, `USD`, `EUR`, `BMD`, `BGN`, `BIF`, `CVE`, `KMF`, `CDF`, `DJF`,
  // `ERN`, `FKP`, `GHS`, `GNF`, `LAK`, `LSL`, `LYD`, `MWK`, `MRO`, `MZN`,
  // `PAB`, `RON`, `RUB`, `SHP`, `RSD`, `SLL`, `SBD`, `SOS`, `SZL`, `TJS`,
  // `TOP`, `TMT`, `YER`, `ZMW`, `GIP`, `ZAR`, `XPF`, `XOF`, `XCD`, `XAF`,
  // `WST`, `VUV`, `VND`, `VEF`, `UZS`, `UYU`, `UGX`, `UAH`, `TZS`, `TWD`,
  // `TTD`, `TRY`, `TND`, `THB`, `STD`, `SGD`, `SEK`, `SCR`, `SAR`, `RWF`,
  // `QAR`, `PYG`, `PLN`, `PKR`, `PHP`, `PGK`, `PEN`, `OMR`, `NZD`, `NPR`,
  // `NOK`, `NIO`, `NGN`, `MYR`, `MXN`, `MVR`, `MUR`, `MOP`, `MNT`, `MMK`,
  // `MKD`, `MDL`, `MAD`, `LRD`, `LKR`, `LBP`, `KZT`, `KYD`, `KWD`, `KRW`,
  // `KHR`, `KGS`, `KES`, `JPY`, `JOD`, `JMD`, `ISK`, `INR`, `ILS`, `IDR`,
  // `HUF`, `HTG`, `HRK`, `HNL`, `HKD`, `GYD`, `GTQ`, `GMD`, `GEL`, `GBP`,
  // `FJD`, `ETB`, `EGP`, `DZD`, `DOP`, `DKK`, `CZK`, `CRC`, `COP`, `CNY`,
  // `CLP`, `CHF`, `CAD`, `BZD`, `BYN`, `BWP`, `BTN`, `BSD`, `BRL`, `BOB`,
  // `BND`, `BHD`, `BDT`, `BBD`, `BAM`, `AZN`, `AWG`, `AUD`, `ARS`, `AOA`,
  // `ANG`, `AMD`, `ALL`, `AED`, `MGA`, `MZN`, `NAD`, `RON`, `GHS`, `SRD`,
  // `TMT`, `ZMW`, `IQD`
  string currency                   = 2;
  // order type (optional, default: `ONE_TIME`)
  OrderType type                    = 3;

  // items which are included in the order (required)
  repeated OrderItem items          = 10;
  // billing address of the order (optional)
  Address billing_address           = 11;
  // shipping address of the order (optional)
  Address shipping_address          = 12;
  // additional charges which are included in the order, like tax, shipping or discount (optional)
  OrderAdditionalCharges charges    = 13;
  // indicate that shipping is not needed for the order (optional)
  bool noShipping                   = 14;
  // the part of total amount taken by platform from the amount sent to merchant
  //flynt-disable field-type-breaking-change
  google.protobuf.DoubleValue platform_fee = 15 [(.wix.api.min) = 0];

  // information about subscription (required for `SUBSCRIPTION` order, not allowed for `ONE_TIME` order)
  Subscription subscription         = 20;

  // should this order during its payment setup the Payment Agreement entity to allow other payments in future using this Payment Agreement
  google.protobuf.BoolValue setup_future_usages = 21;

  // the id of Payment Agreement which is suggested for payment for this order
  google.protobuf.StringValue suggested_payment_agreement_id = 25;

  // order reference in third party system (required)
  string vertical_order_id          = 40;
  // buyer information which can use to provide better service (optional)
  OrderBuyerInfo buyer_info         = 41;
  // any external data which is stored with the order on cashier side
  // and can be used in future by third party system
  // Well-known keys:
  // providers.square.orderId - value to pass as [order_id][1] if payment is made via Square
  // [1]: https://developer.squareup.com/reference/square/payments-api/create-payment#request__property-order_id
  map<string, string> external_data = 42;

  // timestamp on which event/delivery/ect. happens and order is considered fulfilled
  google.protobuf.Timestamp fulfillment_date = 43;

  // Complete description that appears on the customers' statements.
  google.protobuf.StringValue soft_descriptor = 44;

  // Vertical invoice id
  google.protobuf.StringValue vertical_invoice_id = 45;

  // indicate that order is created by merchant
  bool merchant_initiated = 46;

  // List of allowed payment providers the order can be paid with
  repeated string allowed_payment_provider_ids = 47;

  // Type of the order
  enum OrderType {
    UNDEFINED    = 0;
    ONE_TIME     = 1;
    SUBSCRIPTION = 2;
  }

  // Capture method
  CaptureMethod capture_method = 48;
  enum CaptureMethod {
    UNKNOWN_CAPTURE_METHOD = 0 [(.wix.api.enum_maturity) = NOT_IMPLEMENTED];
    IMMEDIATE = 1;
    DELAYED = 2;
    FORCE_MANUAL = 3 [deprecated = true]; // Will deprecate after migrate sbs
    AUTOMATIC = 4 [deprecated = true]; // Will be removed
    PREFER_MANUAL = 5 [deprecated = true]; // Will be removed
  }

  DelayedCaptureOptions delayed_capture_options = 49;

  // indicate that saving payment method for merchant use is enabled
  bool merchant_use_save_enabled = 50;

  // Request transaction uses strong customer authentication, such as 3-D Secure.
  bool sca_requested = 51;
}

message DelayedCaptureOptions {
  // If auth & capture is not supported by the provider, capture immediately.
  bool allow_immediate = 1;

  // Specifies the automatic action (void/capture) for authorized transaction after the specified duration
  ScheduledAction scheduled_action = 2;
}

message ScheduledAction {
  Action action = 1;
  Duration delay = 2;

  enum Action {
    UNKNOWN_ACTION = 0 [(.wix.api.enum_maturity) = NOT_IMPLEMENTED];
    VOID = 1;
    CAPTURE = 2;
  }

  message Duration {
    // Duration unit: MINUTE, HOUR and DAY
    DurationUnitEnum.DurationUnit unit = 1;

    // Amount of units. For example,  30 MINUTE, 1 HOUR, 7 DAY, etc. Optional.
    google.protobuf.Int32Value count = 2;

    message DurationUnitEnum {
      enum DurationUnit {
        UNKNOWN_DURATION_UNIT = 0;
        MINUTE = 1;
        HOUR = 2;
        DAY = 3;
      }
    }
  }
}

