{"_path":"/docs/3rd/wxpay","_draft":false,"_partial":false,"_empty":false,"title":"微信支付","description":"在宁皓独立开发者训练营，我们会集成商户版微信支付提供的支付功能，完成付费订阅与数字资产销售的功能。","excerpt":{"type":"root","children":[{"type":"element","tag":"h1","props":{"id":"微信支付"},"children":[{"type":"text","value":"微信支付"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在宁皓独立开发者训练营，我们会集成商户版微信支付提供的支付功能，完成付费订阅与数字资产销售的功能。"}]},{"type":"element","tag":"h2","props":{"id":"在服务端应用里集成微信支付功能"},"children":[{"type":"text","value":"在服务端应用里集成微信支付功能"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"要在我们自己开发的服务端应用里集成商户版微信支付，需要申请开通商户版微信支付，还需要给它关联一个应用，比如公众平台服务号，或者小程序。按说也应该可以关联在微信开放平台注册的网站应用，不过在实际操作中，无法关联网站应用。在训练营中选择使用的是公众平台服务号+微信支付。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在开发过程中需要准备以下信息："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"应用 ID（示例：wx58264149db20f28e），这是与微信支付关联的 AppID，比如公众平台服务号的 AppID。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"微信支付商户号（示例：1428508902），这是注册商户版微信支付以后获得的商户号。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"微信支付密钥（3f47ebf92...），在商户版微信支付账户设置- API 安全里设置，训练营中用的是 APIv2 密钥。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"异步通知接口（示例："},{"type":"element","tag":"a","props":{"href":"https://sandbox.ninghao.net/payments/wxpay/notify%EF%BC%89%EF%BC%8C%E8%BF%99%E6%98%AF%E6%88%91%E4%BB%AC%E8%A6%81%E5%9C%A8%E8%AE%AD%E7%BB%83%E8%90%A5%E4%B8%AD%E8%87%AA%E5%B7%B1%E5%BC%80%E5%8F%91%E7%9A%84%E3%80%82","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://sandbox.ninghao.net/payments/wxpay/notify），这是我们要在训练营中自己开发的。"}]}]}]},{"type":"element","tag":"h2","props":{"id":"微信公众平台服务号"},"children":[{"type":"text","value":"微信公众平台服务号"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在微信公众平台使用企业身份注册一个服务号并完成实名认证，每年需要 300 元的认证费用。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"官方网站"}]},{"type":"text","value":"："},{"type":"element","tag":"a","props":{"href":"https://mp.weixin.qq.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://mp.weixin.qq.com"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"登录到公众平台，在 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"设置与开发"}]},{"type":"text","value":" - "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"基本配置"}]},{"type":"text","value":" 里会显示公众号的 AppID。\n"},{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image.png"},"children":[]}]},{"type":"element","tag":"h2","props":{"id":"微信支付商户平台"},"children":[{"type":"text","value":"微信支付商户平台"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在我们的应用里集成了微信支付并完成相关支付功能以后，用户通过微信支付的金额会出现在微信支付商户平台这里，我们可以将金额提到对公司的对公账户里，或者直接转至个人银行账户（需要额外的手续费）。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"登录到微信支付商户平台，点击成为商户，注册一个微信支付商户号，通过审核以后开通需要的支付产品，然后再关联应用 ID。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"官方网站"}]},{"type":"text","value":"："},{"type":"element","tag":"a","props":{"href":"https://pay.weixin.qq.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://pay.weixin.qq.com"}]}]},{"type":"element","tag":"h3","props":{"id":"注册微信支付商户号"},"children":[{"type":"text","value":"注册微信支付商户号"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在微信支付商户平台注册微信支付商户号时，提前准备好下列信息："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"营业执照照片"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"法人身份证正面与反面照片"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"对公账户相关信息（银行名称、开户行、账号...）"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(1).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"点击页面上的 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"注册微信支付商户号"}]},{"type":"text","value":"，会提示你使用管理员的微信客户端扫描二维码。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(2).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"管理员确认操作以后，点击 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"申请注册"}]},{"type":"text","value":"，下一步需要填写商户相关资料，首先要选择主体身份，类型应该是企业，然后上传准备好的营业执照的照片。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(3).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"继续填写法人相关信息，证件类型可以选择身份证，再分别上传身份证的正面与反面照片。\n"},{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(4).png"},"children":[]},{"type":"text","value":"\n然后填写经营与行业相关信息，比如商户简称、客服电话等。\n"},{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(5).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"确认商户相关资料以后，需要等待审核。\n"},{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(6).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"提示 7 到 15 天完成审核，不过我的审核在当天上午就完成了。通过以后会收到微信通知，然后需要登录微信支付商户平台完成签约。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(7).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"签约成功以后，会提示成为微信支付商家。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(8).png"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"开通支付产品"},"children":[{"type":"text","value":"开通支付产品"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"登录到微信支付商户平台，在 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"产品中心"}]},{"type":"text","value":" - "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"我的产品"}]},{"type":"text","value":" 页面，选择要开通的支付产品。在宁皓独立开发者训练营中，需要用的是 Native 支付，这种支付方式需要在应用界面生成微信支付二维码，用户可以使用微信客户端扫描页面上的二维码完成支付。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(9).png"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"关联应用"},"children":[{"type":"text","value":"关联应用"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在微信支付商户平台，"},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"产品中心"}]},{"type":"text","value":" - "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"AppID 账号管理"}]},{"type":"text","value":" 页面，可以关联应用，比如关联一下公众平台服务号。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(10).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在关联状态那里会提示 待授权，这时需要登录公众平台，打开 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"微信支付"}]},{"type":"text","value":" 页面，在待关联商户号这里会显示要关联的微信支付商户。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(11).png"},"children":[]},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"在公众号平台，微信支付页面显示的待关联商户号"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"确认以后，会在 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"已关联商户号"}]},{"type":"text","value":" 的下面显示被关联的微信支付商户。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(12).png"},"children":[]},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"在公众号平台，微信支付页面显示的已关联商户号"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在公众号那里确定关联微信支付商户以后，回到微信支付商户平台，"},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"产品中心"}]},{"type":"text","value":" - "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"AppID 账号管理"}]},{"type":"text","value":" 页面，应用的关联状态会变成 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"已关联"}]},{"type":"text","value":"。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(13).png"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"设置接口密钥"},"children":[{"type":"text","value":"设置接口密钥"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在微信支付商户平台，"},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"账户中心"}]},{"type":"text","value":" - "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"API 安全"}]},{"type":"text","value":" 页面可以设置接口密钥。在宁皓独立开发者训练营，我们用的是 v2 微信支付接口，所以在这里要设置一下 APIv2 密钥。密钥的内容是由字母数字组成的 32 位随机字符，使用 openssl 命令生成随机字符串，在终端执行："}]},{"type":"element","tag":"code","props":{"code":"openssl rand -hex 16\n"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"openssl rand -hex 16\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"执行上面的命令会得到一串长度是 32 位的字符串，示例：cac2241ac9c61a8062a66e178d058247，然后可以将其作为微信支付的 APIv2 密钥。\n"},{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(14).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"设置密钥需要完成安全验证，要输入操作密码（提前自行设置）与手机验证码。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(15).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"完成以后会在 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"设置 APIV2 密钥"}]},{"type":"text","value":" 的右侧显示 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"已设置"}]},{"type":"text","value":"。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(16).png"},"children":[]}]}]},"body":{"type":"root","children":[{"type":"element","tag":"h1","props":{"id":"微信支付"},"children":[{"type":"text","value":"微信支付"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在宁皓独立开发者训练营，我们会集成商户版微信支付提供的支付功能，完成付费订阅与数字资产销售的功能。"}]},{"type":"element","tag":"h2","props":{"id":"在服务端应用里集成微信支付功能"},"children":[{"type":"text","value":"在服务端应用里集成微信支付功能"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"要在我们自己开发的服务端应用里集成商户版微信支付，需要申请开通商户版微信支付，还需要给它关联一个应用，比如公众平台服务号，或者小程序。按说也应该可以关联在微信开放平台注册的网站应用，不过在实际操作中，无法关联网站应用。在训练营中选择使用的是公众平台服务号+微信支付。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在开发过程中需要准备以下信息："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"应用 ID（示例：wx58264149db20f28e），这是与微信支付关联的 AppID，比如公众平台服务号的 AppID。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"微信支付商户号（示例：1428508902），这是注册商户版微信支付以后获得的商户号。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"微信支付密钥（3f47ebf92...），在商户版微信支付账户设置- API 安全里设置，训练营中用的是 APIv2 密钥。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"异步通知接口（示例："},{"type":"element","tag":"a","props":{"href":"https://sandbox.ninghao.net/payments/wxpay/notify%EF%BC%89%EF%BC%8C%E8%BF%99%E6%98%AF%E6%88%91%E4%BB%AC%E8%A6%81%E5%9C%A8%E8%AE%AD%E7%BB%83%E8%90%A5%E4%B8%AD%E8%87%AA%E5%B7%B1%E5%BC%80%E5%8F%91%E7%9A%84%E3%80%82","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://sandbox.ninghao.net/payments/wxpay/notify），这是我们要在训练营中自己开发的。"}]}]}]},{"type":"element","tag":"h2","props":{"id":"微信公众平台服务号"},"children":[{"type":"text","value":"微信公众平台服务号"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在微信公众平台使用企业身份注册一个服务号并完成实名认证，每年需要 300 元的认证费用。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"官方网站"}]},{"type":"text","value":"："},{"type":"element","tag":"a","props":{"href":"https://mp.weixin.qq.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://mp.weixin.qq.com"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"登录到公众平台，在 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"设置与开发"}]},{"type":"text","value":" - "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"基本配置"}]},{"type":"text","value":" 里会显示公众号的 AppID。\n"},{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image.png"},"children":[]}]},{"type":"element","tag":"h2","props":{"id":"微信支付商户平台"},"children":[{"type":"text","value":"微信支付商户平台"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在我们的应用里集成了微信支付并完成相关支付功能以后，用户通过微信支付的金额会出现在微信支付商户平台这里，我们可以将金额提到对公司的对公账户里，或者直接转至个人银行账户（需要额外的手续费）。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"登录到微信支付商户平台，点击成为商户，注册一个微信支付商户号，通过审核以后开通需要的支付产品，然后再关联应用 ID。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"官方网站"}]},{"type":"text","value":"："},{"type":"element","tag":"a","props":{"href":"https://pay.weixin.qq.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://pay.weixin.qq.com"}]}]},{"type":"element","tag":"h3","props":{"id":"注册微信支付商户号"},"children":[{"type":"text","value":"注册微信支付商户号"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在微信支付商户平台注册微信支付商户号时，提前准备好下列信息："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"营业执照照片"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"法人身份证正面与反面照片"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"对公账户相关信息（银行名称、开户行、账号...）"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(1).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"点击页面上的 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"注册微信支付商户号"}]},{"type":"text","value":"，会提示你使用管理员的微信客户端扫描二维码。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(2).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"管理员确认操作以后，点击 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"申请注册"}]},{"type":"text","value":"，下一步需要填写商户相关资料，首先要选择主体身份，类型应该是企业，然后上传准备好的营业执照的照片。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(3).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"继续填写法人相关信息，证件类型可以选择身份证，再分别上传身份证的正面与反面照片。\n"},{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(4).png"},"children":[]},{"type":"text","value":"\n然后填写经营与行业相关信息，比如商户简称、客服电话等。\n"},{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(5).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"确认商户相关资料以后，需要等待审核。\n"},{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(6).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"提示 7 到 15 天完成审核，不过我的审核在当天上午就完成了。通过以后会收到微信通知，然后需要登录微信支付商户平台完成签约。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(7).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"签约成功以后，会提示成为微信支付商家。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(8).png"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"开通支付产品"},"children":[{"type":"text","value":"开通支付产品"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"登录到微信支付商户平台，在 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"产品中心"}]},{"type":"text","value":" - "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"我的产品"}]},{"type":"text","value":" 页面，选择要开通的支付产品。在宁皓独立开发者训练营中，需要用的是 Native 支付，这种支付方式需要在应用界面生成微信支付二维码，用户可以使用微信客户端扫描页面上的二维码完成支付。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(9).png"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"关联应用"},"children":[{"type":"text","value":"关联应用"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在微信支付商户平台，"},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"产品中心"}]},{"type":"text","value":" - "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"AppID 账号管理"}]},{"type":"text","value":" 页面，可以关联应用，比如关联一下公众平台服务号。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(10).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在关联状态那里会提示 待授权，这时需要登录公众平台，打开 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"微信支付"}]},{"type":"text","value":" 页面，在待关联商户号这里会显示要关联的微信支付商户。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(11).png"},"children":[]},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"在公众号平台，微信支付页面显示的待关联商户号"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"确认以后，会在 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"已关联商户号"}]},{"type":"text","value":" 的下面显示被关联的微信支付商户。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(12).png"},"children":[]},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"在公众号平台，微信支付页面显示的已关联商户号"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在公众号那里确定关联微信支付商户以后，回到微信支付商户平台，"},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"产品中心"}]},{"type":"text","value":" - "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"AppID 账号管理"}]},{"type":"text","value":" 页面，应用的关联状态会变成 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"已关联"}]},{"type":"text","value":"。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(13).png"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"设置接口密钥"},"children":[{"type":"text","value":"设置接口密钥"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在微信支付商户平台，"},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"账户中心"}]},{"type":"text","value":" - "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"API 安全"}]},{"type":"text","value":" 页面可以设置接口密钥。在宁皓独立开发者训练营，我们用的是 v2 微信支付接口，所以在这里要设置一下 APIv2 密钥。密钥的内容是由字母数字组成的 32 位随机字符，使用 openssl 命令生成随机字符串，在终端执行："}]},{"type":"element","tag":"code","props":{"code":"openssl rand -hex 16\n"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"openssl rand -hex 16\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"执行上面的命令会得到一串长度是 32 位的字符串，示例：cac2241ac9c61a8062a66e178d058247，然后可以将其作为微信支付的 APIv2 密钥。\n"},{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(14).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"设置密钥需要完成安全验证，要输入操作密码（提前自行设置）与手机验证码。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(15).png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"完成以后会在 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"设置 APIV2 密钥"}]},{"type":"text","value":" 的右侧显示 "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"已设置"}]},{"type":"text","value":"。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"/images/docs/3rd/wxpay/image(16).png"},"children":[]}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"在服务端应用里集成微信支付功能","depth":2,"text":"在服务端应用里集成微信支付功能"},{"id":"微信公众平台服务号","depth":2,"text":"微信公众平台服务号"},{"id":"微信支付商户平台","depth":2,"text":"微信支付商户平台","children":[{"id":"注册微信支付商户号","depth":3,"text":"注册微信支付商户号"},{"id":"开通支付产品","depth":3,"text":"开通支付产品"},{"id":"关联应用","depth":3,"text":"关联应用"},{"id":"设置接口密钥","depth":3,"text":"设置接口密钥"}]}]}},"_type":"markdown","_id":"content:docs:3.3rd:3.wxpay.md","_source":"content","_file":"docs/3.3rd/3.wxpay.md","_extension":"md"}