Skip to content

转换短链接

该接口主要用于Native支付模式一中的二维码链接转成短链接(weixin://wxpay/s/XXXXXX),减小二维码数据量,提升扫描速度和精确度。

请求参数类型描述
xmlobject声明请求的XML数据结构
appidstring公众账号ID
mch_idstring商户号
long_urlstringURL链接
sign_typestring签名类型
php
$instance->v2->tools->shorturl->postAsync([
  'xml' => [
    'appid'     => 'wx8888888888888888',
    'mch_id'    => '1900000109',
    'long_url'  => 'weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX',
    'sign_type' => 'HMAC-SHA256',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/tools/shorturl')->postAsync([
  'xml' => [
    'appid'     => 'wx8888888888888888',
    'mch_id'    => '1900000109',
    'long_url'  => 'weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX',
    'sign_type' => 'HMAC-SHA256',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/tools/shorturl']->postAsync([
  'xml' => [
    'appid'     => 'wx8888888888888888',
    'mch_id'    => '1900000109',
    'long_url'  => 'weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX',
    'sign_type' => 'HMAC-SHA256',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->tools->shorturl->post([
  'xml' => [
    'appid'     => 'wx8888888888888888',
    'mch_id'    => '1900000109',
    'long_url'  => 'weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX',
    'sign_type' => 'HMAC-SHA256',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/tools/shorturl')->post([
  'xml' => [
    'appid'     => 'wx8888888888888888',
    'mch_id'    => '1900000109',
    'long_url'  => 'weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX',
    'sign_type' => 'HMAC-SHA256',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/tools/shorturl']->post([
  'xml' => [
    'appid'     => 'wx8888888888888888',
    'mch_id'    => '1900000109',
    'long_url'  => 'weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX',
    'sign_type' => 'HMAC-SHA256',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
SUCCESS | FAIL 枚举值之一
return_msgstring返回信息
appidstring公众账号ID
mch_idstring商户号
nonce_strstring随机字符串
signstring签名
result_codestring业务结果
SUCCESS | FAIL 枚举值之一
err_codestring错误代码
short_urlstringURL链接

参阅 官方NATIVE文档

Published on the GitHub by TheNorthMemory