Skip to content

获取RSA加密公钥

调用获取RSA公钥API获取RSA公钥,用于加密付款到银行业务接口中的用户敏感信息。

请求参数类型描述
base_uristring声明接入点
固定值https://fraud.mch.weixin.qq.com/
xmlobject声明请求的XML数据结构
mch_idstring商户号
sign_typestring签名类型
MD5 | HMAC-SHA256 枚举值之一
securityboolean声明加载商户API证书
固定值true
php
$instance->v2->risk->getpublickey->postAsync([
  'base_uri' => 'https://fraud.mch.weixin.qq.com/', // 接入点
  'xml' => [
    'mch_id' => '1900000109',
    'sign_type' => 'MD5',
  ],
  'security' => true,
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/risk/getpublickey')->postAsync([
  'base_uri' => 'https://fraud.mch.weixin.qq.com/', // 接入点
  'xml' => [
    'mch_id' => '1900000109',
    'sign_type' => 'MD5',
  ],
  'security' => true,
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/risk/getpublickey']->postAsync([
  'base_uri' => 'https://fraud.mch.weixin.qq.com/', // 接入点
  'xml' => [
    'mch_id' => '1900000109',
    'sign_type' => 'MD5',
  ],
  'security' => true,
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->risk->getpublickey->post([
  'base_uri' => 'https://fraud.mch.weixin.qq.com/', // 接入点
  'xml' => [
    'mch_id' => '1900000109',
    'sign_type' => 'MD5',
  ],
  'security' => true,
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/risk/getpublickey')->post([
  'base_uri' => 'https://fraud.mch.weixin.qq.com/', // 接入点
  'xml' => [
    'mch_id' => '1900000109',
    'sign_type' => 'MD5',
  ],
  'security' => true,
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/risk/getpublickey']->post([
  'base_uri' => 'https://fraud.mch.weixin.qq.com/', // 接入点
  'xml' => [
    'mch_id' => '1900000109',
    'sign_type' => 'MD5',
  ],
  'security' => true,
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
return_msgstring错误码描述
error_codestring错误码
error_code_desstring错误代码描述
result_codestring返回状态码
mch_idstring商户号
pub_keystringRSA公钥

参阅 官方文档

Published on the GitHub by TheNorthMemory