> ## Documentation Index
> Fetch the complete documentation index at: https://docs.payallglobal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 实时余额查询



## OpenAPI

````yaml post /api/mapi/v1/payments/open/api/currentBalanceQuery
openapi: 3.1.0
info:
  version: '1.0'
  title: PayAllGlobal开放平台接口文档
  summary: ''
  termsOfService: ''
  contact:
    name: 技术支持
    email: support@payallglobal.com
    url: ''
  license:
    url: https://www.apache.org/licenses/LICENSE-2.0.html
    name: Apache 2.0
servers:
  - url: https://mpgwpre.payallglobal.com/mp-gateway/
    description: 开发环境
  - url: https://mpgw.payallglobal.com/mp-gateway/
    description: 正式生产环境
security:
  - signature: []
tags:
  - name: 收单
  - name: 其他交易类型
  - name: 商户管理
  - name: 文件下载
  - name: 付款
paths:
  /api/mapi/v1/payments/open/api/currentBalanceQuery:
    post:
      tags:
        - 多币种资金管理
      summary: 实时余额查询
      operationId: post-aggregate-pay-api-gateway-currentBalanceQuery
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CurrentBalanceQueryRequest'
      responses:
        '200':
          description: 查询成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CurrentBalanceQueryResponse'
      security:
        - signature: []
      servers:
        - url: https://mpgwpre.payallglobal.com/mp-gateway/
          description: 开发环境
        - url: https://mpgw.payallglobal.com/mp-gateway/
          description: 正式生产环境
components:
  schemas:
    CurrentBalanceQueryRequest:
      allOf:
        - $ref: '#/components/schemas/BalanceBaseRequest'
        - type: object
          properties:
            requestTime:
              type: string
              description: 请求时间，符合rfc3339规范，格式：yyyy-MM-dd'T'HH:mm:ss.SSSXXX 时间需要在当前时间两分钟内
              maxLength: 32
              example: '2025-04-05T12:00:00.000+08:00'
            data:
              $ref: '#/components/schemas/CurrentBalanceQueryRequestData'
          required:
            - requestTime
            - appId
            - data
    CurrentBalanceQueryResponse:
      type: object
      required:
        - data
        - code
        - msg
      properties:
        code:
          type: string
          description: 返回码，’00000000’代表成功
          example: '00000000'
        msg:
          type: string
          description: 返回描述，’Success’
          example: Success
        data:
          $ref: '#/components/schemas/CurrentBalanceQueryResponseData'
    BalanceBaseRequest:
      type: object
      properties:
        charset:
          type: string
          description: 交互数据的编码【utf-8】
          default: UTF-8
          examples:
            - UTF-8
        version:
          type: string
          description: "接口版本，当前版本为【2.0.0】,目前只能传2.0.0，不能不传\t"
          examples:
            - 2.0.0
        transType:
          type: string
          enum:
            - PAY
            - CREDIT_CARD
            - 3D_PREAUTH_VOIDS
            - 3D_PREAUTH_COMPLETION
            - REFUND
            - VOIDS
            - QUERY
            - TRANSFER
            - DOWNLOAD
            - REGISTRATION
            - FILEUPLOAD
            - INQUIRYREGISTRATIONSTATUS
            - AUTHORIZE
            - BALANCE_QUERY
          description: 交易类型
          default: BALANCE_QUERY
        accessType:
          type: string
          description: "接口访问类型\t"
          default: s2s
          examples:
            - s2s
        signType:
          type: string
          description: 报文签名类型
          examples:
            - RSA
        memberId:
          type: string
          description: "机构号\t"
          examples:
            - '2023010558663764'
        merchantId:
          type: string
          description: "商户号\t"
          examples:
            - '2023010558663764'
      required:
        - charset
        - version
        - transType
        - accessType
        - signType
        - memberId
        - merchantId
      x-examples:
        Example 1:
          charset: UTF-8
          version: 2.0.0
          transType: string
          accessType: PAY
          signType: RSA
          memberId: stringstri
          merchantId: stringstri
    CurrentBalanceQueryRequestData:
      type: object
      title: 请求数据体
      properties:
        accountType:
          type: array
          description: >-
            账户类型,ACQUIRING 收单账户 FREEZE 冻结账户 SETTLE 待结算账户 REVERSE 保证金账户
            当未指定账户类型时，返回所有账户
          items:
            type: string
            maxLength: 32
            examples:
              - AVAILABLE
          example:
            - ACQUIRING
            - SETTLE
        accountCurrency:
          type: string
          description: 币种代码,符合ISO 4217规范. 当未指定币种时，返回所有账户
          maxLength: 3
          example: USD
    CurrentBalanceQueryResponseData:
      type: object
      title: 返回数据体
      required:
        - accountRealTimeTypes
        - inquiryTime
      properties:
        accountRealTimeTypes:
          type: array
          items:
            $ref: '#/components/schemas/AccountBalanceItem'
          example:
            - balance: 0.59
              accountType: ACQUIRING
              currency: AED
            - balance: 776.34
              accountType: ACQUIRING
              currency: USD
        inquiryTime:
          type: string
          description: 查询时间,符合rfc3339规范，格式：yyyy-MM-dd’T’HH:mm:ss.SSSXXX
          maxLength: 64
          example: '2025-04-05T12:00:00.000+08:00'
    AccountBalanceItem:
      type: object
      required:
        - balance
        - accountType
        - currency
      properties:
        balance:
          type: number
          title: 金额
          description: 单位元
          format: double
          examples:
            - 9998.11
        accountType:
          type: string
          title: 账户类型
          maxLength: 32
          examples:
            - AVAILABLE
        currency:
          type: string
          title: 3位币种代码
          description: 符合ISO 4217规范.
          maxLength: 3
          examples:
            - USD
  securitySchemes:
    signature:
      type: apiKey
      description: >-
        Example: MIIEpQIBAAKCAQEA...（Base64编码的签名字符串）

        ## 加签

        加签是开放平台和商户对于交互消息完整性的校验。加签行为主要发生两个部分：

        1. 商户服务器端针对向PayAllGlobal开放平台发送的请求报文进行加签；

        2. PayAllGlobal开放平台针对通知商户的异步消息进行加签。

        PayAllGlobal平台要求使用 RSA 私钥进行加签， 使用 RSA 公钥进行验签。 因此，在以上两部分描述的交互中，
        存在商户公私钥、PayAllGlobal 公私钥，开发者需要使用商户私钥，对第一部分报文进行加签，使用 PayAllGlobal
        公钥对第二部分消息进行验签。

        ### 加签规则如下: 

        使用商户私钥对请求体进行 SHA256withRSA 签名后，再进行 Base64 编码的结果。

        1. 使用 商户私钥对待 `request.body` 进行签名（SHA256WithRSA 计算原始数据的SHA-256哈希值。
        使用私钥对哈希值进行签名，即使用私钥对哈希值进行RSA加密。此时得到的加密结果就是数字签名。）；

        ```java

        Signature signature = Signature.getInstance("SHA256withRSA");

        signature.initSign(privateKey);

        // 计算 SHA256withRSA 签名时，需要以 utf-8 的编码转换 byte 流，否则可能导致含中文参数的签名计算不正确

        signature.update(request.body);

        byte[] signedHash = signature.sign();

        ```

        2. 将加签内容进行 Base64 编码；

        ```java

        String signature = Base64.getEncoder().encodeToString(signedHash);


        ```

        3. 将编码后的内容放在请求头部 signature 参数中。

        注意，加签是对 request.body 进行签名，当查询等 request.body 为空时，则无需加签。
      name: signature
      in: header

````