common.v2.common

io.token.proto.common.v2.common common/src/main/proto/v2/common.proto


syntax = "proto3";
package io.token.proto.common.v2.common;

option java_outer_classname = "CommonProtos";

import "extensions/field.proto";
import "extensions/message.proto";
import "money.proto";


// LocalInstrument to account identifiers correspondence (* means required):
// SEPA / SEPA_INSTANT => iban* + bic
// SWIFT => iban*/account_number* + bic*
// FASTER_PAYMENTS / CHAPS => account_number* + sort_code*
// ELIXIR / EXPRESS_ELIXIR / BLUE_CASH / SORBNET=> iban*/account_number* + bic
// BANKGIRO => bankgiro_number* + bic
// PLUSGIRO => plusgiro_number* + bic;
// EU_DOMESTIC_NON_EURO / EU_DOMESTIC_NON_EURO_INSTANT => iban*/bban* + bic OR bban* + clearing_number
message DebtorInformation {
  string name = 1 [(io.token.proto.extensions.field.redact) = true]; // owner name for the debtor account
  string ultimate_debtor_name = 2 [(io.token.proto.extensions.field.redact) = true]; // ultimate debtor name
  Address address = 3; // optional, used in international payments only; TODO: review if this is actually required
  // bank identifiers: bic, sort_code, clearing_number below  (only one present depending on the local instrument)
  string bic = 4 [(io.token.proto.extensions.field.redact) = true];
  string sort_code = 5  [(io.token.proto.extensions.field.redact) = true];
  // account identifiers (only one present depending on the local instrument)
  string iban = 6 [(io.token.proto.extensions.field.redact) = true];
  string account_number = 7  [(io.token.proto.extensions.field.redact) = true];
  string bankgiro_number = 8  [(io.token.proto.extensions.field.redact) = true];
  string plusgiro_number = 9  [(io.token.proto.extensions.field.redact) = true];
  string bban = 10 [(io.token.proto.extensions.field.redact) = true];
  // one more bank identifier
  string clearing_number = 11 [(io.token.proto.extensions.field.redact) = true];
}

message CreditorInformation {
  string name = 1 [(io.token.proto.extensions.field.redact) = true]; // owner name for the creditor account
  string ultimate_creditor_name = 2 [(io.token.proto.extensions.field.redact) = true]; // ultimate creditor name
  string bank_name = 3; // optional, needed in international payment and for web-app
  Address address = 4; // optional, used in international payments only; TODO: review if this is actually required
  // bank identifiers: bic, sort_code, clearing_number below  (only one present depending on the local instrument)
  string bic = 5 [(io.token.proto.extensions.field.redact) = true];
  string sort_code = 6  [(io.token.proto.extensions.field.redact) = true];
  // account identifiers (only one present depending on the local instrument)
  string iban = 7 [(io.token.proto.extensions.field.redact) = true];
  string account_number = 8  [(io.token.proto.extensions.field.redact) = true];
  string bankgiro_number = 9  [(io.token.proto.extensions.field.redact) = true];
  string plusgiro_number = 10  [(io.token.proto.extensions.field.redact) = true];
  string bban = 11 [(io.token.proto.extensions.field.redact) = true];
  // one more bank identifier
  string clearing_number = 12 [(io.token.proto.extensions.field.redact) = true];
}

message RefundAccount {
  string name = 1 [(io.token.proto.extensions.field.redact) = true];
  // bank identifiers (only one present depending on the local instrument)
  string bic = 5 [(io.token.proto.extensions.field.redact) = true];
  string sort_code = 6  [(io.token.proto.extensions.field.redact) = true];
  // account identifiers (only one present depending on the local instrument)
  string iban = 7 [(io.token.proto.extensions.field.redact) = true];
  string account_number = 8  [(io.token.proto.extensions.field.redact) = true];
  string bankgiro_number = 9  [(io.token.proto.extensions.field.redact) = true];
  string plusgiro_number = 10  [(io.token.proto.extensions.field.redact) = true];
  string bban = 11 [(io.token.proto.extensions.field.redact) = true];
  string clearing_number = 12 [(io.token.proto.extensions.field.redact) = true];
}

message Address {
  repeated string address_line = 1 [(io.token.proto.extensions.field.redact) = true];
  string street_name = 2 [(io.token.proto.extensions.field.redact) = true];
  string building_number = 3 [(io.token.proto.extensions.field.redact) = true];
  string post_code = 4 [(io.token.proto.extensions.field.redact) = true];
  string town_name = 5 [(io.token.proto.extensions.field.redact) = true];
  repeated string country_sub_division = 6;
  string country = 7;
}

/**
 * All the local instruments are used in Payments v2 but not in payout. Payout service will
 * validate if a local Instrument is supported on service level.
 */
enum LocalInstrument {
  INVALID_LOCAL_INSTRUMENT = 0;
  SEPA = 1;
  SEPA_INSTANT = 2;
  SWIFT = 3;
  // UK domestic payment rails
  FASTER_PAYMENTS = 4;
  CHAPS = 5;
  // Polish domestic payment rails
  ELIXIR = 7;
  EXPRESS_ELIXIR = 8;
  BLUE_CASH = 9;
  SORBNET = 10;
  // Swedish domestic
  BANKGIRO = 11;
  PLUSGIRO = 12;
  // EU domestic
  EU_DOMESTIC_NON_EURO = 13;
  EU_DOMESTIC_NON_EURO_INSTANT = 14;
}

message Refund {
   PaymentRefundStatus payment_refund_status = 1;
   io.token.proto.common.money.Money settled_refund_amount = 2; // total amount of settled refunds (with status INITIATION_COMPLETED)
   io.token.proto.common.money.Money remaining_refund_amount = 3; // remaining amount to be refunded (total payment amount - total amount of non-failed refunds)
   RefundAccount refund_account = 4; // mandatory: a refund object will be returned
   string refund_state_updated_at = 5;
}

// basically same as payout.TransferRefundStatus but with "payment" name, in accordance with V2 style
enum PaymentRefundStatus {
  INVALID = 0;
  NONE = 1;
  PARTIAL = 2;
  FULL = 3;
}

message OnBehalfOf {
  option deprecated = true;
  string id = 1;  // Renamed from the v1 ActingAs ref_id
  string name = 2;
}

message Risk {
  string psu_id = 1; // The unique customer identifier of the PSU with the merchant
  PaymentContextCode payment_context_code = 2; // Specifies the payment context
  string payment_purpose_code = 3; // Category code conforming to ISO 20022, related to the type of services or goods corresponding to the underlying purpose of the payment.
  string merchant_category_code = 4; // Category code conforming to ISO 18245, related to the type of services or goods provided by the merchant.
  Address delivery_address = 5;
  BeneficiaryAccountType beneficiary_account_type = 6; // To be provided if the AccountType is known.
  bool contract_present_inidicator = 7 [deprecated = true];
  bool beneficiary_prepopulated_indicator = 8; // Indicates if PISP has immutably prepopulated payment details in for the PSU.
  bool contract_present_indicator = 9; // Indicates if Payee has a contractual relationship with the PISP.
}

enum PaymentContextCode {
  INVALID_PAYMENT_CONTEXT_CODE = 0;
  BILL_PAYMENT = 1;
  ECOMMERCE_GOODS = 2;
  ECOMMERCE_SERVICES = 3;
  OTHER = 4;
  PARTY_TO_PARTY = 5;
  // all fields below are hidden for now - until we update cma9 adaptor to accept them
  BILLING_GOODS_AND_SERVICES_IN_ADVANCE = 6;
  BILLING_GOODS_AND_SERVICES_IN_ARREARS = 7;
  PISP_PAYEE = 8;
  ECOMMERCE_MERCHANT_INITIATED_PAYMENT = 9;
  FACE_TO_FACE_POINT_OF_SALE = 10;
  TRANSFER_TO_SELF = 11;
  TRANSFER_TO_THIRD_PARTY = 12;
}

enum BeneficiaryAccountType {
  INVALID_BENEFICIARY_ACCOUNT_TYPE = 0;
  PERSONAL = 1;
  JOINT_PERSONAL = 2;
  PERSONAL_SAVINGS_ACCOUNT = 3;
  BUSINESS = 4;
  BUSINESS_SAVINGS_ACCOUNT = 5;
  CHARITY = 6;
  COLLECTION = 7;
  CORPORATE = 8;
  GOVERNMENT = 9;
  EWALLET = 10;
  INVESTMENT = 11;
  ISA = 12;
  PREMIER = 13;
  WEALTH = 14;
  PENSION = 15;
}

enum FlowType {
  UNKNOWN = 0;
  API = 1;
  WEB_APP = 2;
  WEB_APP_CREDENTIAL = 3;
}