All Projects → wechatpay-apiv3 → Wechatpay Postman Script

wechatpay-apiv3 / Wechatpay Postman Script

Licence: apache-2.0
微信支付API v3的调试工具

Projects that are alternatives of or similar to Wechatpay Postman Script

Weixin Spider
微信公众号爬虫,公众号历史文章,文章评论,文章阅读及在看数据,可视化web页面,可部署于Windows服务器。基于Python3之flask/mysql/redis/mitmproxy/pywin32等实现,高效微信爬虫,微信公众号爬虫,历史文章,文章评论,数据更新。
Stars: ✭ 287 (+156.25%)
Mutual labels:  api, wechat
Node Express Mongodb Jwt Rest Api Skeleton
This is a basic API REST skeleton written on JavaScript using async/await. Great for building a starter web API for your front-end (Android, iOS, Vue, react, angular, or anything that can consume an API). Demo of frontend in VueJS here: https://github.com/davellanedam/vue-skeleton-mvp
Stars: ✭ 603 (+438.39%)
Mutual labels:  api, postman
Laravel Api To Postman
Generate a Postman collection automatically from your Laravel API
Stars: ✭ 320 (+185.71%)
Mutual labels:  api, postman
Api
API for Current cases and more stuff about COVID-19 and Influenza
Stars: ✭ 2,323 (+1974.11%)
Mutual labels:  api, postman
Httplive
HTTP Request & Response Service, Mock HTTP
Stars: ✭ 1,094 (+876.79%)
Mutual labels:  api, postman
Chatapi Wechat
Java版本微信聊天接口,使用网页微信API,让你能够开发自己的微信聊天机器人
Stars: ✭ 207 (+84.82%)
Mutual labels:  api, wechat
Itchat
A complete and graceful API for Wechat. 微信个人号接口、微信机器人及命令行微信,三十行即可自定义个人号机器人。
Stars: ✭ 21,935 (+19484.82%)
Mutual labels:  api, wechat
Postman Bdd
A BDD test framework for Postman and Newman
Stars: ✭ 139 (+24.11%)
Mutual labels:  api, postman
Python Api Development Fundamentals
Develop a full-stack web application with Python and Flask
Stars: ✭ 44 (-60.71%)
Mutual labels:  api, postman
Weixinbot
网页版微信API,包含终端版微信及微信机器人
Stars: ✭ 6,903 (+6063.39%)
Mutual labels:  api, wechat
Wxpy
微信机器人 / 可能是最优雅的微信个人号 API ✨✨
Stars: ✭ 13,057 (+11558.04%)
Mutual labels:  api, wechat
Wechat Go
go version wechat web api and message framework for building wechat robot
Stars: ✭ 1,381 (+1133.04%)
Mutual labels:  api, wechat
Wechatvideocourse
《微信公众号+小程序快速开发》视频教程课件及代码
Stars: ✭ 185 (+65.18%)
Mutual labels:  api, wechat
Postman Docs
Documentation for Postman, a collaboration platform for API development. Available for Mac, Windows and Linux.
Stars: ✭ 235 (+109.82%)
Mutual labels:  api, postman
Curlx
◼️ Supercharge curl with history, collections and more.
Stars: ✭ 169 (+50.89%)
Mutual labels:  api, postman
Swell
Swell: API development tool that enables developers to test endpoints served over streaming technologies including Server-Sent Events (SSE), WebSockets, HTTP2, GraphQL, and gRPC.
Stars: ✭ 517 (+361.61%)
Mutual labels:  api, postman
Rocket Api
API敏捷开发框架,用于API接口功能的快速开发。不再定义Controller,Service,Dao,Mybatis,xml,Entity,VO等对象和方法.以springboot starter 形式集成使用
Stars: ✭ 122 (+8.93%)
Mutual labels:  api, postman
Minapp
重新定义微信小程序的开发
Stars: ✭ 902 (+705.36%)
Mutual labels:  api, wechat
Mojo Weixin
使用Perl语言(不会没关系)编写的个人账号微信/weixin/wechat客户端框架(非GUI),可通过插件提供基于HTTP协议的api接口供其他语言或系统调用
Stars: ✭ 1,181 (+954.46%)
Mutual labels:  api, wechat
Rageframe2
一个基于Yii2高级框架的快速开发应用引擎
Stars: ✭ 1,553 (+1286.61%)
Mutual labels:  api, wechat

微信支付API v3 Postman脚本使用指南

简介

Postman是一款业界知名的API开发工具。为了方便微信支付的商户开发者快速上手,我们利用Postman强大的脚本扩展能力,编写了一套微信支付API v3的请求前置脚本。通过这套脚本,商户开发者不用自行计算API v3的签名,就可以在Postman上轻松的构造并发送API请求。

导入

脚本和相关配置,统一保存在Collection V2JSON文件中。开发者可以点击Postman界面左上角的Import按钮或者通过File中的Import发起导入。选择本地的wechatpay-apiv3.postman_collection.json,点击确认后,导入便完成了。

你会发现在左侧Collection下新增了名为wechatpay-apiv3的一组请求。

配置脚本

选中wechatpay-apiv3,右键Edit进入Collection的配置页面。如图所示。

Collection

在弹出的Edit Collection的浮层上部的多个分栏中,找到Pre-request Scripts一栏。

EDIT COLLECTION

其中红色方框中的代码,是需要配置三个参数。

const private_key = `-----BEGIN PRIVATE KEY-----
{商户的私钥}
-----END PRIVATE KEY-----`;
      
const mchid = "{商户号}";
const serialNo = "{商户证书的证书序列号}";

// ....以下省略

参数的详细说明:

配置请求

现在回到请求的配置界面吧。接下来,你可以用自己习惯的方式去设置请求的信息了,如方法、URL、请求参数、Body。最后,配置两项:

  • AuthorizationType选择No Auth
  • 在请求的头部Headers中,新增一条,KEY设为AuthorizationVALUE设为{{auth}}

EDIT REQUEST

我们准备了平台证书下载发放指定批次的代金券两个请求样例供开发者参考,分别对应GETPOST两种典型的操作。开发者也可以在两个请求样例的基础上进行修改,或者复制出新的请求。

发起请求

点击地址栏右侧的Send按钮,发送你的请求吧。

实现原理

我们通过定制Postman的Pre-request Script,实现了请求的签名。

Pre-request Script脚本会在请求发送之前被执行。在脚本中,我们根据请求的方法、URL、请求参数、Body等信息,计算了微信支付API v3的Authorization信息,并设置到了环境变量auth当中。而在请求发送时,Headers中配置的{{auth}}将被替换成真实的签名值,实现了请求的签名。

关于Postman脚本的信息,可以参考Pre-request Script

常见问题

导入后找不到预设的脚本

为了给不同的请求做统一配置,脚本是Collection级别的,不是单个Request级别的。请结合配图找到Collection的EDIT入口,里面的Pre-request Script才有预设的脚本。

发送请求时遇到错误提示“Error: Too few bytes to parse DER.”或者“Too few bytes to read ASN.1 value.”

一般是Pre-request Script选项里private_key字段填写有误导致的,可以按以下步骤排查:

  1. private_key字段是否有填写正确的值,即商户的私钥。
  2. 是否有既在Collection层级,又在请求层级,都设置了Pre-request Script选项,如果是的话,只保留其中一个正确的设置即可。(注:Collection里的设置优先级更高)

联系我们

如果你有任何疑问,欢迎访问我们的开发者社区进行反馈。

我们也欢迎各种各样的issue和Merge Request:-)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].