<?php

// HubSpot Deal Button – local config.
// NOTE: Do NOT commit real tokens to public repos.
// Prefer setting these in your server environment when possible.
//
// This file is optional. The script hubspot-create-deal.php will:
// 1) try getenv('NAME'), and
// 2) if not set, fall back to constants defined here.

if (!defined('HUBSPOT_PRIVATE_APP_TOKEN')) {
    $t = getenv('HUBSPOT_PRIVATE_APP_TOKEN');
    define(
        'HUBSPOT_PRIVATE_APP_TOKEN',
        ($t !== false && $t !== '') ? $t : 'pat-na1-e082addd-b7fa-4906-b017-d20e881a5883'
    );
}

if (!defined('HUBSPOT_PIPELINE_ID')) {
    $p = getenv('HUBSPOT_PIPELINE_ID');
    define('HUBSPOT_PIPELINE_ID', ($p !== false && $p !== '') ? $p : 'default');
}

if (!defined('HUBSPOT_DEALSTAGE_ID')) {
    $s = getenv('HUBSPOT_DEALSTAGE_ID');
    // Default is a placeholder; set your "Sale completed" stage internal ID here or via env.
    define('HUBSPOT_DEALSTAGE_ID', ($s !== false && $s !== '') ? $s : 'appointmentscheduled');
}

// Dynamic stage selection for Shopify orders (webhook orders/paid).
// These should be the *internal* HubSpot stage IDs.
if (!defined('HUBSPOT_DEALSTAGE_SALE_COMPLETED_ID')) {
    $v = getenv('HUBSPOT_DEALSTAGE_SALE_COMPLETED_ID');
    define('HUBSPOT_DEALSTAGE_SALE_COMPLETED_ID', ($v !== false && $v !== '') ? $v : '1329275420');
}

if (!defined('HUBSPOT_DEALSTAGE_DRAWING_REQUESTED_ID')) {
    $v = getenv('HUBSPOT_DEALSTAGE_DRAWING_REQUESTED_ID');
    define('HUBSPOT_DEALSTAGE_DRAWING_REQUESTED_ID', ($v !== false && $v !== '') ? $v : '1154519639');
}


if (!defined('HUBSPOT_DEALSTAGE_HARDWARE_ACH_ID')) {
    $v = getenv('HUBSPOT_DEALSTAGE_HARDWARE_ACH_ID');
    define('HUBSPOT_DEALSTAGE_HARDWARE_ACH_ID', ($v !== false && $v !== '') ? $v : '1340568603');
}

if (!defined('HUBSPOT_DEAL_PROPERTY_SHOPIFY_ORDER_ID')) {
    // Internal name of a Deal custom property (string). Create it in HubSpot first:
    // Settings → Data Management → Properties → Deal → Create property (e.g. "Shopify order id").
    define('HUBSPOT_DEAL_PROPERTY_SHOPIFY_ORDER_ID', 'shopify_order_id');
}

if (!defined('HUBSPOT_PORTAL_ID')) {
    // Optional: your HubSpot portal (Hub) ID, used only for building a \"View deal\" link.
    // Example: 12345678
    define('HUBSPOT_PORTAL_ID', '51059215');
}

if (!defined('HUBSPOT_DEAL_PROPERTY_PRODUCT_NAMES')) {
    // Internal name of the Deal multi-line text property where you want to store
    // Shopify product names (e.g. "#1, Door;#2, Handle" on separate lines).
    // Default uses the same property name as hubspot-create-deal.php:
    // "product_configuration_summary".
    define('HUBSPOT_DEAL_PROPERTY_PRODUCT_NAMES', 'product_configuration_summary');
}

// Deal single-line text property: signed PandaDoc document URL (create in HubSpot first).
if (!defined('HUBSPOT_DEAL_PROPERTY_PANDADOC_DOCUMENT_URL')) {
    $u = getenv('HUBSPOT_DEAL_PROPERTY_PANDADOC_DOCUMENT_URL');
    define(
        'HUBSPOT_DEAL_PROPERTY_PANDADOC_DOCUMENT_URL',
        ($u !== false && $u !== '') ? $u : 'pandadoc_document_url'
    );
}

// Optional: also store PandaDoc document id (single-line text). Empty = do not send (avoid unknown property errors).
if (!defined('HUBSPOT_DEAL_PROPERTY_PANDADOC_DOCUMENT_ID')) {
    $u = getenv('HUBSPOT_DEAL_PROPERTY_PANDADOC_DOCUMENT_ID');
    define(
        'HUBSPOT_DEAL_PROPERTY_PANDADOC_DOCUMENT_ID',
        ($u !== false && $u !== '') ? trim((string) $u) : ''
    );
}

// --- HubSpot Order object (Commerce CRM) — PandaDoc link is written here by default ---

// Internal name of an Order custom property that stores the numeric Shopify order id (string).
// Create under Settings → Properties → Order (or match your Shopify→HubSpot sync field).
if (!defined('HUBSPOT_ORDER_PROPERTY_SHOPIFY_ORDER_ID')) {
    $u = getenv('HUBSPOT_ORDER_PROPERTY_SHOPIFY_ORDER_ID');
    define(
        'HUBSPOT_ORDER_PROPERTY_SHOPIFY_ORDER_ID',
        ($u !== false && $u !== '') ? trim((string) $u) : 'hs_external_order_id'
    );
}

// Order single-line text: signed PandaDoc document URL.
if (!defined('HUBSPOT_ORDER_PROPERTY_PANDADOC_DOCUMENT_URL')) {
    $u = getenv('HUBSPOT_ORDER_PROPERTY_PANDADOC_DOCUMENT_URL');
    define(
        'HUBSPOT_ORDER_PROPERTY_PANDADOC_DOCUMENT_URL',
        ($u !== false && $u !== '') ? trim((string) $u) : 'pandadoc_document_url'
    );
}

// Optional Order property for PandaDoc document id. Empty = do not send.
if (!defined('HUBSPOT_ORDER_PROPERTY_PANDADOC_DOCUMENT_ID')) {
    $u = getenv('HUBSPOT_ORDER_PROPERTY_PANDADOC_DOCUMENT_ID');
    define(
        'HUBSPOT_ORDER_PROPERTY_PANDADOC_DOCUMENT_ID',
        ($u !== false && $u !== '') ? trim((string) $u) : ''
    );
}


// --- HubSpot Order object (Commerce CRM) — Stripe checkout link + payment status ---

// Order single-line text: Stripe Checkout Session URL.
if (!defined('HUBSPOT_ORDER_PROPERTY_STRIPE_CHECKOUT_URL')) {
    $u = getenv('HUBSPOT_ORDER_PROPERTY_STRIPE_CHECKOUT_URL');
    define(
        'HUBSPOT_ORDER_PROPERTY_STRIPE_CHECKOUT_URL',
        ($u !== false && $u !== '') ? trim((string) $u) : 'stripe_checkout_url'
    );
}

// Order single-line text: Stripe Checkout Session id (cs_...).
if (!defined('HUBSPOT_ORDER_PROPERTY_STRIPE_CHECKOUT_SESSION_ID')) {
    $u = getenv('HUBSPOT_ORDER_PROPERTY_STRIPE_CHECKOUT_SESSION_ID');
    define(
        'HUBSPOT_ORDER_PROPERTY_STRIPE_CHECKOUT_SESSION_ID',
        ($u !== false && $u !== '') ? trim((string) $u) : 'stripe_checkout_session_id'
    );
}

// Order single-select/status text: payment status for ACH orders (link_created, paid, failed, expired...).
if (!defined('HUBSPOT_ORDER_PROPERTY_PAYMENT_STATUS')) {
    $u = getenv('HUBSPOT_ORDER_PROPERTY_PAYMENT_STATUS');
    define(
        'HUBSPOT_ORDER_PROPERTY_PAYMENT_STATUS',
        ($u !== false && $u !== '') ? trim((string) $u) : 'stripe_payment_status'
    );
}

