Skip to content

获取沙箱环境密钥

仿真系统与生产环境完全独立,包括存储层。商户在仿真系统所做的所有交易(如下单、支付、查询)均为无资金流的假数据,即:用户无需真实扣款,商户也不会有资金入账。代金券同理,沙箱环境中无需商户真实制券与发券,亦不会出现真实扣券情况。

请求参数类型描述
xmlarray声明请求的XML数据结构
mch_idstring商户号
php
$instance->v2->xdc->apiv2getsignkey->sign->getsignkey->postAsync([
  'xml' => [
    'mch_id' => '1900000109',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string)$response->getBody()));
})
->wait();
php
$instance->chain('v2/xdc/apiv2getsignkey/sign/getsignkey')->postAsync([
  'xml' => [
    'mch_id' => '1900000109',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string)$response->getBody()));
})
->wait();
php
$instance['v2/xdc/apiv2getsignkey/sign/getsignkey']->postAsync([
  'xml' => [
    'mch_id' => '1900000109',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string)$response->getBody()));
})
->wait();
php
$response = $instance->v2->xdc->apiv2getsignkey->sign->getsignkey->post([
  'xml' => [
    'mch_id' => '1900000109',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string)$response->getBody()));
php
$response = $instance->chain('v2/xdc/apiv2getsignkey/sign/getsignkey')->post([
  'xml' => [
    'mch_id' => '1900000109',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string)$response->getBody()));
php
$response = $instance['v2/xdc/apiv2getsignkey/sign/getsignkey']->post([
  'xml' => [
    'mch_id' => '1900000109',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string)$response->getBody()));
返回字典类型描述
return_codestring返回状态码 SUCCESS | FAIL
return_msgstring返回信息
result_codestring业务结果 SUCCESS | FAIL
err_codestring错误代码
err_code_desstring错误代码描述
mch_idstring商户号
sandbox_signkeystring沙箱密钥

重要提示

  1. wxpay 构造实例化时,需要显式初始化 secret 字段,此为正式环境密钥;
  2. 此接口请求时,会隐式按照MD5数据签名算法进行签名,填充请求的sign字段;
  3. 此接口有QPS限制(官方未公布),高频请求会被官方重定向到腾讯公益404页面;
  4. sandbox_signkey 具有时效性,时长官方未公布,建议缓存1个小时即可,请按需缓存;

参阅 官方沙箱环境文档

Published on the GitHub by TheNorthMemory