/**
 * The Payment Intent you would like to checkout.
 * Refer to [Airwallex Client API](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/)
 *
 * ***Hint***:
 * This interface only contains information necessary for a checkout via UI elements.
 * For detailed information on each field refer to the API Reference.
 */
import { Billing } from './airwallex';

/**
 * A PaymentIntent guides you through the process of collecting a payment from your customer.
 * It tracks a payment when your customer first checks out, through to when payment is successfully paid by your customer.
 * A PaymentIntent transitions through a number of states throughout the customer's payment journey.
 */
export interface Intent {
  /**
   * The ID of the Payment Intent.
   */
  id: string;
  /**
   * The `client_secret` of the Payment Intent when Payment Intent is provided. Otherwise, this should be the `client_secret` of the Customer object.
   */
  client_secret?: string;
  /**
   * Unique request ID specified by the merchant.
   */
  request_id?: string;
  amount?: number;
  currency?: string;
  merchant_order_id?: string;
  customer_id?: string;
  status?: string;
  created_at?: string;
  updated_at?: string;
  payment_consent_id?: string;
  customer_payment_consents?: {
    id: string;
    next_triggered_by: 'merchant' | 'customer';
    status: 'PENDING_VERIFICATION' | 'VERIFIED' | 'DISABLED';
    payment_method: {
      id?: string;
      type: 'card' | 'ach_direct_debit' | 'becs_direct_debit';
      ach_direct_debit?: {
        aba_routing_number: string;
        account_number: string;
        owner_name: string;
        owner_email: string;
      };
      becs_direct_debit?: {
        bsb_number: string;
        account_number: string;
        owner_name: string;
        owner_email: string;
      };
      card?: {
        brand: string;
        bin: string;
        last4: string;
        number_type: 'AIRWALLEX_NETWORK_TOKEN' | 'EXTERNAL_NETWORK_TOKEN' | 'PAN';
        fingerprint: string;
      };
    };
  }[];
  customer_payment_methods?: {
    id: string;
    card?: {
      brand: string;
      bin: string;
      last4: string;
      number_type: 'AIRWALLEX_NETWORK_TOKEN' | 'EXTERNAL_NETWORK_TOKEN' | 'PAN';
      fingerprint: string;
    };
  }[];
}

/**
 * Interface for Payment Method returned to the merchant when provided in createPaymentConsent.
 * Refer to the type description: https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Methods/_api_v1_pa_payment_methods_create/post
 */
export interface PaymentMethodBasicInfo {
  id: string;
  created_at: string;
  customer_id: string;
  status: 'CREATED' | 'VERIFIED' | 'DISABLED';
  type:
    | 'card'
    | 'applepay'
    | 'googlepay'
    | 'ach_direct_debit'
    | 'bacs_direct_debit'
    | 'becs_direct_debit'
    | 'sepa_direct_debit'
    | 'eft_direct_debit';
  updated_at: string;
  card: {
    avs_check?: string;
    billing?: Billing;
    bin?: string;
    brand?: string;
    card_type?: string;
    cvc_check?: string;
    expiry_month?: string;
    expiry_year?: string;
    fingerprint?: string;
    is_commercial: boolean;
    issuer_country_code?: string;
    issuer_name?: string;
    last4?: string;
    name?: string;
    number_type?: string;
  };
}
