<?php

namespace Sibs\Sibs\Model;

use Magento\Sales\Model\Order;

class SibsConstants
{
    /* MODULE */
    const MODULE_NAME = 'Sibs_Sibs';

    /* SIBS API METHODS */
    const SIBS_API_METHOD_CREDITCARD        = 'CARD';
    const SIBS_API_METHOD_BLIK              = 'BLIK';
    const SIBS_API_METHOD_PAY_BY_LINK       = 'PAY_BY_LINK';
    const SIBS_API_METHOD_PAY_BY_LINK_KEVIN = 'PBLKV';
    const SIBS_API_METHOD_XPAY              = 'XPAY';

    /* SIBS PAYMENT METHODS */
    const SIBS_PAYMENT_METHOD_CREDITCARD  = 'sibs_creditcard';
    const SIBS_PAYMENT_METHOD_BLIK        = 'sibs_blik';
    const SIBS_PAYMENT_METHOD_PAY_BY_LINK = 'sibs_pbl';
    const SIBS_PAYMENT_METHOD_XPAY        = 'sibs_xpay';

    /* SIBS API STATUSES */
    const SIBS_API_STATUS_SUCCESS    = 'Success';
    const SIBS_API_STATUS_PARTIAL    = 'Partial';
    const SIBS_API_STATUS_PROCESSING = 'InProcessing';
    const SIBS_API_STATUS_PENDING    = 'Pending';
    const SIBS_API_STATUS_DECLINED   = 'Declined';
    const SIBS_API_STATUS_TIMEOUT    = 'Timeout';
    const SIBS_API_STATUS_ERROR      = 'Error';

    /* CRON WEBHOOK KNOWN PROCESSING API STATUSES */
    const SIBS_KNOWN_API_STATUSES = [
        self::SIBS_API_STATUS_SUCCESS,
        self::SIBS_API_STATUS_PARTIAL,
        self::SIBS_API_STATUS_PROCESSING,
        self::SIBS_API_STATUS_PENDING,
        self::SIBS_API_STATUS_DECLINED,
        self::SIBS_API_STATUS_TIMEOUT,
        self::SIBS_API_STATUS_ERROR
    ];

    /* SIBS PAYMENT TYPE */
    const SIBS_PAYMENT_TYPE_AUTH = 'AUTH';
    const SIBS_PAYMENT_TYPE_PURS = 'PURS';
    const SIBS_PAYMENT_TYPE_CAPT = 'CAPT';
    const SIBS_PAYMENT_TYPE_CAUT = 'CAUT';
    const SIBS_PAYMENT_TYPE_RFND = 'RFND';
    const SIBS_PAYMENT_TYPE_RVSL = 'RVSL';

    /* MAGENTO STATUSES */
    const MAGENTO_STATE_NEW             = Order::STATE_NEW;
    const MAGENTO_STATE_PENDING_PAYMENT = Order::STATE_PENDING_PAYMENT;
    const MAGENTO_STATE_PROCESSING      = Order::STATE_PROCESSING;
    const MAGENTO_STATE_COMPLETE        = Order::STATE_COMPLETE;
    const MAGENTO_STATE_CLOSED          = Order::STATE_CLOSED;
    const MAGENTO_STATE_CANCELED        = Order::STATE_CANCELED;
    const MAGENTO_STATE_HOLDED          = Order::STATE_HOLDED;
    const MAGENTO_STATE_PAYMENT_REVIEW  = Order::STATE_PAYMENT_REVIEW;

    /* SIBS STATUSES */
    const SIBS_STATUS_NEW             = self::MAGENTO_STATE_NEW;
    const SIBS_STATUS_PENDING_PAYMENT = self::MAGENTO_STATE_PENDING_PAYMENT;
    const SIBS_STATUS_PROCESSING      = self::MAGENTO_STATE_PROCESSING;
    const SIBS_STATUS_AUTHORIZED      = 'authorized';
    const SIBS_STATUS_COMPLETE        = self::MAGENTO_STATE_COMPLETE;
    const SIBS_STATUS_CLOSED          = self::MAGENTO_STATE_CLOSED;
    const SIBS_STATUS_REFUNDED        = 'refunded';
    const SIBS_STATUS_CANCELED        = self::MAGENTO_STATE_CANCELED;
    const SIBS_STATUS_HOLDED          = self::MAGENTO_STATE_HOLDED;
    const SIBS_STATUS_CAPTURE_HOLDED  = 'capture_holded';
    const SIBS_STATUS_REFUND_HOLDED   = 'refund_holded';
    const SIBS_STATUS_PAYMENT_REVIEW  = self::MAGENTO_STATE_PAYMENT_REVIEW;

    /* SEND MAIL STATUSES */
    const SIBS_SEND_MAIL_STATUSES = [
        self::SIBS_STATUS_PROCESSING,
        self::SIBS_STATUS_AUTHORIZED,
        self::SIBS_STATUS_COMPLETE,
        self::SIBS_STATUS_REFUNDED,
        self::SIBS_STATUS_CANCELED
    ];

    /* CAN PURCHASE STATUSES */
    const SIBS_CAN_PURCHASE_STATUSES = [
        self::SIBS_STATUS_NEW,
        self::SIBS_STATUS_PENDING_PAYMENT,
        self::SIBS_STATUS_HOLDED,
        self::SIBS_STATUS_PAYMENT_REVIEW
    ];

    /* CAN AUTHORIZE STATUSES */
    const SIBS_CAN_AUTHORIZE_STATUSES = [
        self::SIBS_STATUS_NEW,
        self::SIBS_STATUS_PENDING_PAYMENT,
        self::SIBS_STATUS_HOLDED,
        self::SIBS_STATUS_PAYMENT_REVIEW
    ];

    /* CAN CAPTURE STATUSES */
    const SIBS_CAN_CAPTURE_STATUSES = [
        self::SIBS_STATUS_AUTHORIZED,
        self::SIBS_STATUS_CAPTURE_HOLDED,
        self::MAGENTO_STATE_HOLDED
    ];

    /* CAN REFUND STATUSES */
    const SIBS_CAN_REFUND_STATUSES = [
        self::MAGENTO_STATE_PROCESSING,
        self::MAGENTO_STATE_COMPLETE,
        self::SIBS_STATUS_REFUND_HOLDED,
        self::MAGENTO_STATE_HOLDED,
        self::MAGENTO_STATE_PAYMENT_REVIEW
    ];

    /* ACK NOK */
    const SIBS_ACK = 'ACK';
    const SIBS_NOK = 'NOK';

    const SIBS_ACK_CODES = ['000'];

    /* PAYMENT FUNCTIONS */
    const SIBS_PAYMENTS = [
        self::SIBS_PAYMENT_METHOD_CREDITCARD,
        self::SIBS_PAYMENT_METHOD_BLIK,
        self::SIBS_PAYMENT_METHOD_PAY_BY_LINK,
        self::SIBS_PAYMENT_METHOD_XPAY,
    ];

    const SIBS_PAYMENTS_CAPTURE = [
        self::SIBS_PAYMENT_METHOD_CREDITCARD,
    ];

    const SIBS_PAYMENTS_REFUND = [
        self::SIBS_PAYMENT_METHOD_CREDITCARD,
        self::SIBS_PAYMENT_METHOD_BLIK,
        self::SIBS_PAYMENT_METHOD_PAY_BY_LINK,
        self::SIBS_PAYMENT_METHOD_XPAY,
    ];

    /* BLIK RETRY */
    const SIBS_NUMBER_OF_RETRIES_BLIK = 30;
    const SIBS_RETRY_DELAY_BLIK = 1;

    /* PAYMENT EXPIRATION */
    const SIBS_PAYMENT_EXPIRATION_DATE_VALUE = 5;
    const SIBS_PAYMENT_EXPIRATION_DATE_UNIT = 'minute';

    /* DATE */
    const DATE_FORMAT_API = 'Y-m-d\TH:i:s.v\Z';

    /* CURRENCIES */
    const EUR = 'EUR';
    const PLN = 'PLN';

    const ALLOWED_CURRENCIES = [
        self::EUR,
        self::PLN,
    ];

    /* LANGUAGES */
    const LNG_EN = 'en';
    const LNG_PT = 'pt';
    const LNG_PL = 'pl';

    const ALLOWED_LANGUAGES = [
        self::LNG_EN,
        self::LNG_PT,
        self::LNG_PL,
    ];

    /* SIBS LOGS */
    const SIBS_LOG = 'sibs_log';
    const SIBS_LOG_INSTALL = 'sibs_log_install';
    const SIBS_LOG_WEBHOOK = 'sibs_log_webhook';
    const SIBS_LOG_SBO = 'sibs_log_sbo';
    const SIBS_LOG_CRON = 'sibs_log_cron';

    /* SIBS WEBHOOK */
    const SIBS_WEBHOOK_RETRY_QTY = 3;
    const SIBS_WEBHOOK_TEST = 'WebhookTest';
}
