# Part of Odoo. See LICENSE file for full copyright and licensing details.

API_BASE_URL = 'https://services.poynt.net'
API_VERSION = '1.2'

# Poynt test/sandbox environment
API_BASE_URL_TEST = 'https://services-eu.poynt.net'

TOKEN_ENDPOINT = '/token'

# Poynt OAuth authorization URL for merchant onboarding
OAUTH_AUTHORIZE_URL = 'https://poynt.net/applications/authorize'
OAUTH_SIGNOUT_URL = 'https://services.poynt.net/auth/signout'

# Poynt public key URL for JWT verification
POYNT_PUBLIC_KEY_URL = 'https://poynt.net'

DEFAULT_PAYMENT_METHOD_CODES = {
    'card',
    'visa',
    'mastercard',
    'amex',
    'discover',
}

# Mapping of Poynt transaction statuses to Odoo payment transaction states.
STATUS_MAPPING = {
    'authorized': ('AUTHORIZED',),
    'done': ('CAPTURED', 'SETTLED'),
    'cancel': ('VOIDED', 'CANCELED'),
    'error': ('DECLINED', 'FAILED', 'REFUND_FAILED'),
    'refund': ('REFUNDED',),
}

# Poynt transaction actions
TRANSACTION_ACTION = {
    'authorize': 'AUTHORIZE',
    'capture': 'CAPTURE',
    'refund': 'REFUND',
    'void': 'VOID',
    'sale': 'SALE',
}

# Webhook event types we handle
HANDLED_WEBHOOK_EVENTS = [
    'TRANSACTION_AUTHORIZED',
    'TRANSACTION_CAPTURED',
    'TRANSACTION_VOIDED',
    'TRANSACTION_REFUNDED',
    'TRANSACTION_DECLINED',
    'TRANSACTION_UPDATED',
    'ORDER_COMPLETED',
    'ORDER_CANCELLED',
]

# Card brand mapping from Poynt scheme to Odoo payment method codes
CARD_BRAND_MAPPING = {
    'VISA': 'visa',
    'MASTERCARD': 'mastercard',
    'AMERICAN_EXPRESS': 'amex',
    'DISCOVER': 'discover',
    'DINERS_CLUB': 'diners_club',
    'JCB': 'jcb',
}

# Terminal statuses
TERMINAL_STATUS = {
    'online': 'ONLINE',
    'offline': 'OFFLINE',
    'unknown': 'UNKNOWN',
}

# Poynt amounts are in cents (minor currency units)
CURRENCY_DECIMALS = {
    'JPY': 0,
    'KRW': 0,
}

# Sensitive keys that should be masked in logs
SENSITIVE_KEYS = {
    'poynt_private_key',
    'accessToken',
    'refreshToken',
}
