Skip to content

汇率查询

商户网站的商品以外币标价时,通过该接口可以实时查询到微信使用的转换汇率。汇率更新时间为北京时间上午10:00,一天更新一次。

请求参数类型描述
noncelesstrue声明请求的XML无随机字符串参数
xmlobject声明请求的XML数据结构
appidstring公众账号ID
mch_idstring商户号
fee_typestring币种
datestring日期
php
$instance->v2->pay->queryexchagerate->postAsync([
  'nonceless' => true,
  'xml' => [
    'appid'    => 'wxd678efh567hg6787',
    'mch_id'   => '1230000109',
    'fee_type' => 'USD',
    'date'     => '20150807',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/pay/queryexchagerate')->postAsync([
  'nonceless' => true,
  'xml' => [
    'appid'    => 'wxd678efh567hg6787',
    'mch_id'   => '1230000109',
    'fee_type' => 'USD',
    'date'     => '20150807',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/pay/queryexchagerate']->postAsync([
  'nonceless' => true,
  'xml' => [
    'appid'    => 'wxd678efh567hg6787',
    'mch_id'   => '1230000109',
    'fee_type' => 'USD',
    'date'     => '20150807',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->pay->queryexchagerate->post([
  'nonceless' => true,
  'xml' => [
    'appid'    => 'wxd678efh567hg6787',
    'mch_id'   => '1230000109',
    'fee_type' => 'USD',
    'date'     => '20150807',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/pay/queryexchagerate')->post([
  'nonceless' => true,
  'xml' => [
    'appid'    => 'wxd678efh567hg6787',
    'mch_id'   => '1230000109',
    'fee_type' => 'USD',
    'date'     => '20150807',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/pay/queryexchagerate']->post([
  'nonceless' => true,
  'xml' => [
    'appid'    => 'wxd678efh567hg6787',
    'mch_id'   => '1230000109',
    'fee_type' => 'USD',
    'date'     => '20150807',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
SUCCESS | FAIL 枚举值之一
return_msgstring返回信息
appidstring公众账号ID
mch_idstring商户号
sub_mch_idstring子商户号
fee_typestring币种
rate_timestring汇率时间
ratestring现汇卖出价(汇率)
signstring签名

参阅 官方文档

Published on the GitHub by TheNorthMemory