<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

class EpayNotify extends Datamodul
{
  public $id;
  public $processing_status;
  public $initial_step_status;
  public $final_step_status;
  public $name;
  public $vorname;
  public $strasse;
  public $ort;
  public $zusatz;
  public $zusatz2;
  public $payonline;
  public $epay_tid;
  public $epay_state;
  public $epay_amount;
  public $epay_type;
  public $epay_institution;
  public $epay_expiry;
  public $epay_cardholder;
  public $epay_blz;
  public $epay_bank;
  public $epay_bic;
  public $epay_iban;
  public $epay_kontoinhaber;
  public $epay_kontonr;
  public $epay_ordertime;
  public $epay_payerid;
  public $epay_feeamount;
  public $epay_pendingreason;
  public $epay_tid_merchant;
  public $epay_statechange;
  public $epay_payment_date;
  public $lock_id;
  public $erfasstvon;
  public $erfasstam;
  public $bearbeiter;
  public $bearbdatum;
  public $epay_order_id;
  public $epay_authorizationid;
  public $epay_capture_id;
  public $epay_processing_mode;

  public static function getEpayNotifyFromEpayInfo(int $payonline, EPayInfo $epayInfo)
  {
    $epn = new EpayNotify();
    $epn->processing_status = '0';
    $epn->initial_step_status = '0';
    $epn->final_step_status = '0';
    $epn->payonline = $payonline;
    $epn->epay_state = $epayInfo->paymentState;
    $epn->epay_payment_date = $epayInfo->paymentDate;
    $epn->epay_tid = $epayInfo->tid;
    $epn->epay_tid_merchant = $epayInfo->tidMerchant;
    $epn->epay_amount = $epayInfo->amount;
    $epn->epay_payerid = $epayInfo->payerid;

    $epn->epay_order_id = $epayInfo->order_id;
    $epn->epay_authorizationid = $epayInfo->authorizationid;
    $epn->epay_capture_id = $epayInfo->capture_id;

    $epn->epay_processing_mode = $epayInfo->processingMode;

    return $epn;
  }

  public function getTyp($pFieldName)
  {
    switch ($pFieldName) {
      default:
        return parent::getTyp($pFieldName);
      case 'epay_ordertime':
      case 'epay_payment_date':
      case 'erfasstam':
      case 'bearbdatum':
        return \DatamodulVarType::TYPE_DATE;
      case 'processing_status':
      case 'initial_step_status':
      case 'final_step_status':
      case 'epay_processing_mode':
        return \DatamodulVarType::TYPE_INT;
      case 'epay_amount':
      case 'epay_feeamount':
        return \DatamodulVarType::TYPE_FLOAT;
    }
  }
}