AbstractPaymentCard:
  description: A representation of an abstract payment card such as a MasterCard credit card or a VISA debit card
  type: object
  required:
    - expiry_month
    - expiry_year
  properties:
    expiry_month:
      description: The payment card's expiry month
      type: integer
      format: int32
      minimum: 1
      maximum: 12
      example: 9
    expiry_year:
      description: The payment card's expiry year expressed as 2-digits
      type: integer
      format: int32
      minimum: 21
      maximum: 99
      example: 22
    card_holder_name:
      description: The card holder's full name 
      type: string
      minLength: 2
      maxLength: 45
      example: John Doe
  allOf:
    - $ref: './payment-details_v1.yaml#/PaymentDetails'

PaymentCard:
  description: A representation of a payment made using a payment card such as a MasterCard credit card or a VISA debit card
  type: object
  required:
    - card_number
  properties:
    card_number:
      description: The 12 - 19 digit card number or primary account number
      type: integer
      format: int64
      minimum: 100000000000
      maximum: 9223372036854775807
      example: 5402187812345678
    cvv:
      description: |
        The payment card's Card Verification Code (CVC) / Card Verification Value (CVV).
        This is generally a 3-digits number except for American Express cards which use a 4-digits number.
      type: integer
      format: int32
      minimum: 0
      maximum: 9999
      example: 123
    cryptogram:
      description: |
        The cryptogram that was returned by Strong Consumer Authentication (SCA) using 3D Secure.
        Providing a cryptogram as part of the payment authorization for a payment transaction is required to obtain liability shift
        and comply with EU's PSD2 directive.
      type: string
      format: byte
      minLength: 1
      example: eyJhY3NPcGVyYXRvcklEIjoiM2RzZWN1cmVpby1zdGFuZGluLWFjcyIsImFjc1JlZmVyZW5jZU51bWJlciI6IjNkc2VjdXJlaW8tc3RhbmRpbi1hY3MiLCJhY3NUcmFuc0lEIjoiOGIwMWE1NmEtNTZlMS00MzAyLThhNzQtNzNkNGFjYzVhOTlkIiwiYXV0aGVudGljYXRpb25WYWx1ZSI6ImtqaUp1TXkyTGJzamRWU1RQODdzMGxZOFBPcz0iLCJkc1JlZmVyZW5jZU51bWJlciI6IjNkc2VjdXJlaW8tc3RhbmRpbi1kcyIsImRzVHJhbnNJRCI6ImM2YmEwZGE3LTgyNzQtNDMyMS1iZjAwLTZkNzhkNzVmNTdlNiIsImVjaSI6IjA1IiwibWVzc2FnZVR5cGUiOiJBUmVzIiwibWVzc2FnZVZlcnNpb24iOiIyLjIuMCIsInRocmVlRFNTZXJ2ZXJUcmFuc0lEIjoiMDUzMTUwMDItZTgzYi00OGRlLTllN2ItMDM5ZThlYmJkYjUwIiwidHJhbnNTdGF0dXMiOiJZIn0=
    save:
      description: |
        Boolean flag indicating whether the provided payment card details should be tokenized and saved in Transpayrent's secure vault.
        The saved payment card will automatically be added to Transpayrent's consumer wallet if a `consumer_id` was provided when the payment session was created.
      type: boolean
      default: false
      example: true
  allOf:
    - $ref: '#/AbstractPaymentCard'
  discriminator:
    propertyName: payment_method_id
    mapping:
      101: '#/PaymentCard'  # AMEX
      102: '#/PaymentCard'  # DANKORT
      103: '#/PaymentCard'  # VISA_DANKORT
      104: '#/PaymentCard'  # DINERS_CLUB
      105: '#/PaymentCard'  # DISCOVER
      106: '#/PaymentCard'  # JCB
      107: '#/PaymentCard'  # MAESTRO
      108: '#/PaymentCard'  # MASTERCARD
      109: '#/PaymentCard'  # VISA
      110: '#/PaymentCard'  # VISA_ELECTRON
      111: '#/PaymentCard'  # ELO
      112: '#/PaymentCard'  # HIPERCARD
      200: './saved-payment-card_v1.yaml#/SavedPaymentCard'       # SAVED_CARD
      201: './consumer-wallet_v1.yaml#/ConsumerWalletSavedCard'   # CONSUMER_WALLET
      202: '#/PaymentCard'  # MOBILEPAY_ONLINE
      203: '#/PaymentCard'  # GOOGLE_PAY
      204: '#/PaymentCard'  # APPLE_PAY

MaskedPaymentCard:
  description: A representation of a masked payment card, such as a MasterCard credit card or a VISA debit card, that was used by the consumer to complete a payment
  type: object
  required:
    - masked_card_number
    - fingerprint
  properties:
    masked_card_number:
      description: |
        The masked card number for the payment card as specified by the 8-digit BIN standard as specified by (ISO-7812)[https://en.wikipedia.org/wiki/ISO/IEC_7812].
      type: string
      minLength: 14
      maxLength: 23
      example: 1234 5678 **** 1234
    fingerprint:
      $ref: '../payment-method-fingerprint/payment-method-fingerprint_v1.yaml#/PaymentMethodFingerprint'
  allOf:
    - $ref: '#/AbstractPaymentCard'
  discriminator:
    propertyName: payment_method_id
    mapping:
      101: '#/MaskedPaymentCard'  # AMEX
      102: '#/MaskedPaymentCard'  # DANKORT
      103: '#/MaskedPaymentCard'  # VISA_DANKORT
      104: '#/MaskedPaymentCard'  # DINERS_CLUB
      105: '#/MaskedPaymentCard'  # DISCOVER
      106: '#/MaskedPaymentCard'  # JCB
      107: '#/MaskedPaymentCard'  # MAESTRO
      108: '#/MaskedPaymentCard'  # MASTERCARD
      109: '#/MaskedPaymentCard'  # VISA
      110: '#/MaskedPaymentCard'  # VISA_ELECTRON
      111: '#/MaskedPaymentCard'  # ELO
      112: '#/MaskedPaymentCard'  # HIPERCARD
      200: './saved-payment-card_v1.yaml#/SavedMaskedPaymentCard' # SAVED_CARD
      201: './consumer-wallet_v1.yaml#/ConsumerWalletMaskedCard'  # CONSUMER_WALLET