<?php

defined( 'ABSPATH' ) || exit;

// Read the version directly from the plugin header so there's a single
// source of truth (the Version: line of pay4all-for-mypos.php).
define( 'PAY4ALL_FOR_MYPOS_PLUGIN_VERSION', ( static function () {
    $file   = dirname( dirname( __FILE__ ) ) . '/pay4all-for-mypos.php';
    $header = function_exists( 'get_file_data' )
        ? get_file_data( $file, [ 'Version' => 'Version' ] )
        : [ 'Version' => '' ];
    return ! empty( $header['Version'] ) ? $header['Version'] : '1.0.0';
} )() );

define( 'PAY4ALL_FOR_MYPOS_DB_VERSION', '1.0.0' );

define( 'PAY4ALL_FOR_MYPOS_PLUGIN_NAME',         'Pay4All for myPOS' );
define( 'PAY4ALL_FOR_MYPOS_PLUGIN_DISPLAY_NAME', 'Pay4All for myPOS' );

define( 'PAY4ALL_FOR_MYPOS_DEBUG',  true );
// When set, Journal writes every info() / error() call to a per-day .log
// file under wp-content/uploads/pay4all_for_mypos/. Accepted values :
//   'all'   = log everything (info + error)  ← flip here for a debug session
//   'error' = errors only
//   'off'   = disable (default when constant is absent)
define( 'PAY4ALL_FOR_MYPOS_DEBUG_LOG', 'all' );
define( 'PAY4ALL_FOR_MYPOS_PREFIX', 'pay4all_for_mypos' );

define( 'PAY4ALL_FOR_MYPOS_PLUGIN_DIRNAME',  basename( dirname( dirname( __FILE__ ) ) ) );
define( 'PAY4ALL_FOR_MYPOS_OPENSSL_ACTIVE',  extension_loaded( 'openssl' ) );

define( 'PAY4ALL_FOR_MYPOS_PLUGIN_PATH', dirname( dirname( __FILE__ ) ) );
define( 'PAY4ALL_FOR_MYPOS_PLUGIN_URL',  plugin_dir_url( __DIR__ ) );
define( 'PAY4ALL_FOR_MYPOS_PLUGIN_FILE', dirname( dirname( __FILE__ ) ) . '/pay4all-for-mypos.php' );
define( 'PAY4ALL_FOR_MYPOS_UPLOAD_DIR',  wp_upload_dir()['basedir'] . '/pay4all_for_mypos/' );

// Logs
define( 'PAY4ALL_FOR_MYPOS_MAX_NUM_LOG_FILES', 30 );
define( 'PAY4ALL_FOR_MYPOS_DELETE_LOGS_AFTER', get_option( 'pay4all_for_mypos_delete_logs_after' ) ?: 30 ); // days

// Default WC order statuses after successful myPOS payment.
define( 'PAY4ALL_FOR_MYPOS_DEFAULT_STATUS_ORDER',    'processing' );
define( 'PAY4ALL_FOR_MYPOS_DEFAULT_STATUS_VIRTUAL',  'completed' );
define( 'PAY4ALL_FOR_MYPOS_DEFAULT_STATUS_DEFERRED', 'on-hold' );

define( 'PAY4ALL_FOR_MYPOS_DEFAULT_CONNECTION_TIMEOUT', 25 );
define( 'PAY4ALL_FOR_MYPOS_WEBHOOK_TIMEOUT', 60 * 10 ); // 10 min

define( 'PAY4ALL_FOR_MYPOS_TEMPLATES_PATH', PAY4ALL_FOR_MYPOS_PLUGIN_PATH . '/templates/' );

// myPOS Virtual Merchant Portal (IPC) endpoints. Both modes accept POSTs
// of the same shape ; the merchant's Configuration Pack decides which
// side the signature is validated against.
//   Production : real payment authorization, funds actually settle
//   Developer  : sandbox, no real money, use test cards from
//                https://developers.mypos.com/en/doc/online_payments/v1_4/226-test-data
define( 'PAY4ALL_FOR_MYPOS_IPC_URL_LIVE', 'https://mypos.com/vmp/checkout' );
// Same host as prod (no www.) - matches what myPOS' own official plugin
// posts to. Using www.mypos.com triggers a 301 that some browsers strip
// the POST body from, which returns E_INVALID_PARAMS.
define( 'PAY4ALL_FOR_MYPOS_IPC_URL_TEST', 'https://mypos.com/vmp/checkout-test' );

// Supported IPC methods handled by the plugin. Anything else in the notify
// payload is rejected with HTTP 200 + "Unsupported IPC method" (myPOS
// requires a 200 to consider the notification acknowledged - a 4xx would
// trigger a retry loop).
define( 'PAY4ALL_FOR_MYPOS_SUPPORTED_IPC_METHODS', [
    'IPCPurchaseNotify',
    'IPCPurchaseRollback',
    'IPCPurchaseCancel',
    'IPCPurchaseOK',
    'IPCSignatureVerify',
] );

// Default shared Configuration Pack (test/developer) - the public sandbox
// credentials published by myPOS at:
//   https://developers.mypos.com/apis/checkout-api/checkout-getting-started/test-credentials
// SID 000000000000010 / Wallet 61938166610 / Key Index 1. Lets a merchant
// try the plugin end-to-end without creating their own myPOS account. The
// wizard's "Use default test Pack" toggle pre-fills the textarea with this
// value. Never used for real charges (test endpoint refuses live payments).
define( 'PAY4ALL_FOR_MYPOS_DEFAULT_TEST_PACK', 'eyJzaWQiOiIwMDAwMDAwMDAwMDAwMTAiLCJjbiI6IjYxOTM4MTY2NjEwIiwicGsiOiItLS0tLUJFR0lOIFJTQSBQUklWQVRFIEtFWS0tLS0tXHJcbk1JSUNYQUlCQUFLQmdRQ2YwVGRjVHVwaGI3WCtad2VrdDFYS0VXWkRjelNHZWNmbzZ2UWZxdnJhZjVWUHpjbkpcclxuMk1jNUo3MkhCbTB1OThFSkhhbitubGUyV09aTVZHSXRUYVwvMmsxRlJXd2J0N2lRNWR6RGg1UEVlWkFTZzJVV2VcclxuaG9SOEw4TXBOQnFINmg3WklUd1ZUZlJTNExzQnZsRWZUN1B6aG01WUpLZk0rQ2R6RE0rTDlXVkVHd0lEQVFBQlxyXG5Bb0dBWWZLeHdVdEVicTh1bFZyRDNubldoRitoazFrNktlamRVcTBkTFlOMjl3OFdqYkNNS2I5SWFva21xV2lRXHJcbjVpWkdFcll4aDdHNEJEUDhBV1wvK005SFhNNG9xbTVTRWtheGhiVGxna3MrRTFzOWRUcGRGUXZMNzZUdm9kcVN5XHJcbmwyRTJCZ2hWZ0xMZ2tkaFJuOWJ1YUZ6WXRhOTVKS2ZneUtHb25OeHNRQTM5UHdFQ1FRREtiRzBLcDZLRWtOZ0Jcclxuc3JDcTNDeDJvZDVPZmlQREc4ZzNSWVpLeFwvTzlkTXk1Q00xNjBEd3VzVkpwdXl3YnBSaGNXcjNna3owUWdSTWRcclxuSVJWd3l4TmJBa0VBeWgzc2lwbWNnTjdTRDh4QkdcL010QllQcVdQMXZ4aFNWWVBmSnp1UFUzZ1M1TVJKelFIQnpcclxuc1ZDTGhUQlk3aEhTb3FpcWxxV1lhc2k4MUp6QkV3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