syntax = "proto3";

package com.wixpress.appservice.api.upstream.wix.psp.v1;
option java_package = "com.wixpress.appservice.api.upstream.wix.psp.v1";

import "wix/api/annotations.proto";
import "wix/api/validations.proto";
import "wix/spi/definitions.proto";
import "google/protobuf/wrappers.proto";

// Configuration for the payment service SPI implementor
message PaymentServiceProviderConfig {
    option (.wix.api.decomposite_of) = "wix.psp.v1.PaymentServiceProviderConfig";
  // Payment service provider to display on Accept payments tab in Business manager
  string title = 1 [(.wix.api.minLength) = 1];
  // SPI base url
  string base_url = 2 [(.wix.spi.base_uri) = true];
  // Available payment methods
  repeated PaymentMethod payment_methods = 3;
  // Provider authentication methods
  repeated PaymentServiceProviderCredentialsField credentials_fields = 4;
}

message PaymentMethod {
    option (.wix.api.decomposite_of) = "wix.psp.v1.PaymentMethod";
  oneof method {
    // Information about hosted page payment method
    HostedPage hosted_page = 1;
  }
}

message HostedPage {
    option (.wix.api.decomposite_of) = "wix.psp.v1.HostedPage";
  // The payment method title to be will be displayed on accept payments tab in business manager as well as on the checkout
  string title = 1 [(.wix.api.minLength) = 1];
  // Url to images in different formats and colors
  Logos logos = 2;
  // Billing address fields that buyer needs to fill in order to process payment with the specified payment method
  repeated MandatoryField billing_address_mandatory_fields = 3;
}

message Logos {
    option (.wix.api.decomposite_of) = "wix.psp.v1.Logos";
  // white theme logos
  Color white = 1;
  // colored theme logos
  Color colored = 2;
}

message Color {
    option (.wix.api.decomposite_of) = "wix.psp.v1.Color";
  // URL to SVG image
  string svg = 1 [(.wix.api.format) = WEB_URL];
  // URL to PNG image
  string png = 2 [(.wix.api.format) = WEB_URL];
}

enum MandatoryField {
  ZIPCODE = 0;
  CITY = 1;
  STATE = 2;
  ADDRESS = 3;
  COUNTRY_CODE = 4;
  EMAIL = 5;
  PHONE = 6;
  FIRST_NAME = 7;
  LAST_NAME = 8;
  STREET = 9;
  HOUSE_NUMBER = 10;
  TAX_IDENTIFIER = 11;
}

message PaymentServiceProviderCredentialsField {
    option (.wix.api.decomposite_of) = "wix.psp.v1.PaymentServiceProviderCredentialsField";
  oneof field {
    // text field
    SimpleField simple_field = 1;
    // checkbox field
    CheckboxField checkbox_field = 2;
    // dropdown field
    DropdownField dropdown_field = 3;
  }
}

message SimpleField {
    option (.wix.api.decomposite_of) = "wix.psp.v1.SimpleField";
  // field name
  string name = 1 [(.wix.api.minLength) = 1];
  // field label
  string label = 2 [(.wix.api.minLength) = 1];
}

message CheckboxField {
    option (.wix.api.decomposite_of) = "wix.psp.v1.CheckboxField";
  // field name
  string name = 1 [(.wix.api.minLength) = 1];
  // field label
  string label = 2 [(.wix.api.minLength) = 1];
  // field tooltip
  google.protobuf.StringValue tooltip = 3;
}

message DropdownField {
    option (.wix.api.decomposite_of) = "wix.psp.v1.DropdownField";
  // field name
  string name = 1 [(.wix.api.minLength) = 1];
  // field label
  string label = 2 [(.wix.api.minLength) = 1];
  // specific options
  repeated DropdownFieldOption options = 3;
}

message DropdownFieldOption {
    option (.wix.api.decomposite_of) = "wix.psp.v1.DropdownFieldOption";
  // option key
  string key = 1 [(.wix.api.minLength) = 1];
  // option value
  string value = 2 [(.wix.api.minLength) = 1];
}
