syntax = "proto3";

package wix.payment.api.pay.v2;

import "google/protobuf/timestamp.proto";
import public "wix/payment/api/pay/v2/resources/subscription-frequency.proto";
import public "wix/payment/api/pay/v2/resources/subscription-trial-period.proto";

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

// Recurring payment is described by `frequency` (day, week, month) and `interval`.
//
// For example, to create a recurring payment every 14 days, just set `interval` to 14 and frequency to `DAY`.
//
// In some cases there should be a trial period for the order, after which payments start to occur.
// Trial period is also defined as `frequency` and `interval` pair.
//
// So one can define a monthly 'subscription' with a 14 days trial period.
message Subscription {
    // frequency of recurring payment (required)
    SubscriptionFrequency frequency = 1;
    // interval of recurring payment (required)
    int32 interval                  = 2;

    // trial period for recurring payment (optional)
    SubscriptionTrialPeriod trial   = 3;

    // how many billing cycles should be done before subscription finishes
    // (optional, 0 by default means endless subscription)
    int32 billing_cycles            = 4;

    // date in the future or in the past when the first billing cycle begins
    // (the first off-session payment is performed when it ends)
    google.protobuf.Timestamp first_cycle_start_date = 5;
}
