注册 ping++账号
在界面上可查看应用的APPID
点击应用标题可以进行webhook的配置
webhooks是ping++支付接口调用成功后,ping++进行回调。
在企业面板中可以查看开发所需参数![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f658e6165f35e4225156df51c5739247.png)
所需的参数有appKey,appId,Ping++公钥,商户RSA私钥,公钥和私钥可以分别保存在文件内,设置路径后进行内容读取。商户RSA私钥和商户RSA公钥成对出现,获取公钥和私钥地址http://demo.pingxx.com/tools/genrsa.php 该地址为1024加密
http://demo.pingxx.com/tools/genrsa.php?len=2048 该地址为2048加密
注意:
- 每次刷新页面会得到不同的 RSA 密钥
- 若您需要保存,可将一对 RSA 密钥以 pem 格式保存到本地。
- 保存方式:复制以上工具生成的密钥至文本编辑器后,保存时文件后缀名写为 .pem
以下是代码
首先先创建 企业转账
public class PingppUtil {
public static void main(String[] args) throws Exception {
// runDemos(); // 运行这个即可
}
public static void runDemos(Map<String, String> paramMap, String orderNo, int amount) throws Exception {
Pingpp.apiKey = CarUtils.PINGPP_API_KEY; // api_key对应ping++的Test Secret Key以及Live Secret Key
Pingpp.appId = CarUtils.PINGPP_APP_ID; // ping++appid
Pingpp.privateKeyPath = CarUtils.PINGPP_PRIVATE_KEY_PATH; // ping++私钥路径
System.setProperty("https.protocols", "TLSv1.2");
PingppUtil pu = new PingppUtil();
pu.create(paramMap, orderNo, amount);
}
/**
* 读取文件, 部署 web 程序的时候, 签名和验签内容需要从 request 中获得
* @param filePath
* @return
* @throws Exception
*/
public static String getStringFromFile(String filePath) throws Exception {
FileInputStream in = new FileInputStream(filePath);
InputStreamReader inReader = new InputStreamReader(in, "UTF-8");
BufferedReader bf = new BufferedReader(inReader);
StringBuilder sb = new StringBuilder();