forked from ArthasModern/AlipayOpenapiCpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Readme.txt
67 lines (47 loc) · 2.53 KB
/
Readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
该项目为C++项目,包含访问支付宝开放平台(Openapi)网关的源码;
/** ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ **/
工程中有两个项目文件:
Openapi.pro为QtCreater项目文件,可用QtCreater打开;
Openapi.sln为VS(2008版)项目文件,可用VS打开;
使用哪种项目文件,由开发者使用的IDE环境决定,并不一定局限于以上两种;
注:该项目源码依赖C\C++标准库(STL)以及几个开源的第三方库(libcurl,openssl);
示例Demo中第三方库(libcurl,openssl)是已经编译成windows平台下的静态库;
开发者可以在其它支持C\C++的平台(linux等)使用源码自行编译第三方库(libcurl,openssl);
开发者亦可自行决定使用静态\动态链接库;
/** ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ **/
项目的目录结构:
(主要源码包含在目录“/openapi”中)
1)主工具类 -- ./openapi/openapi_client
---- 访问支付宝开放平台(openapi)网关的工具类;
---- 外部主要依赖该类访问支付宝网关;
---- 具体使用示例可参见main.cpp中的源码及注释;
2)其它依赖的工具类:
HttpClient -- ./openapi/http/http_client
---- 该工具类提供Http(Https)网络通信的功能;
---- 该工具类依赖第三方库libcurl
JsonUtil -- ./openapi/json/json_util
---- 该工具类提供Json串与C++对象之间的转换功能;
---- 该工具类依赖第三方库cJSON;
openssl & libcurl -- ./libs/
---- 这两个第三方库已经编译成静态库(windows平台);
---- 其它平台的静态库,开发者可自行下载源码进行编译;
/** ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ **/
集成/调试之前的准备工作:
1)入住支付宝开放平台,申请应用并获得应用ID(appId);
2)本地生成rsa密钥对,并上传公钥到支付宝开放平台相应的应用下,
并保存好自己的私钥(privateKey -- 严格保密);
rsa密钥生成方式参看支付宝开放平台官方文档;
注:C++使用的是标准格式的rsa私钥,不是pkcs8格式的;
3)各个具体业务接口参数组装模式具体参看Openapi官方文档;
4)支付宝开放平台文档中心:https://doc.open.alipay.com/
/** ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ **/
免责声明:
1)DEMO仅供参考,实际开发中需要结合具体业务场景修改使用。
2)如果使用了支付接口中的异步通知,则需要严格按照如下描述校验通知数据的正确性(如果没有使用异步通知,可忽略):
2.1)商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号;
2.2)判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额);
2.3)校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email);
2.4)验证app_id是否为该商户本身;
3)该DEMO所运行的环境:
3.1)所提供的示例为windows平台下可运行;
3.2)开发者亦可以在其它支持C\C++的平台(如linux)适配运行;(只需要将依赖的第三方开源库(libcurl,openssl)编译适配好即可)