declare namespace WechatPay {
    type TradeState = 'SUCCESS' | 'REFUND' | 'NOTPAY' | 'CLOSED' | 'REVOKED' | 'USERPAYING' | 'PAYERROR'
    type TradeType = 'JSAPI' | 'NATIVE' | 'APP' | 'MICROPAY' | 'MWEB' | 'FACEPAY'

    interface Amount {
        total: number
        payer_total?: number
        currency: string
        payer_currency?: string
    }

    interface GoodsDetail {
        goods_remark: string
        quantity: number
        discount_amount: number
        goods_id: string
        unit_price: number
    }

    interface PromotionDetail {
        amount: number
        wechatpay_contribute: number
        coupon_id: string
        scope: string
        merchant_contribute: number
        name: string
        other_contribute: number
        currency: string
        stock_id: string
        goods_detail: GoodsDetail[]
    }

    interface Payer {
        openid: string
    }

    interface SceneInfo {
        device_id: string
    }

    interface NotifyData {
        transaction_id: string
        amount: Amount
        mchid: string
        trade_state: TradeState
        bank_type: string
        success_time: Date
        payer: Payer
        out_trade_no: string
        appid: string
        trade_state_desc: string
        trade_type: TradeType
        attach?: string
        scene_info?: any
        promotion_detail?: any
    }

    interface Resource {
        original_type?: string
        algorithm: string
        ciphertext: string
        associated_data: string
        nonce: string
    }
    interface NotifyEvent {
        id: string
        create_time: Date
        resource_type: string
        event_type: string
        summary: string
        resource: Resource
    }

    interface EncryptCertificate {
        algorithm: string
        nonce: string
        associated_data: string
        ciphertext: string
    }

    interface CertData {
        serial_no: string
        effective_time: Date
        expire_time: Date
        encrypt_certificate: EncryptCertificate
    }

    interface GetCertResponse {
        data: CertData[]
    }
}
