编辑: star薰衣草 | 2014-08-09 |
digest_len)) { EVP_MD_CTX_cleanup(&
md_ctx);
return false;
} 微信云支付 版权所有:腾讯云计算(北京)有限责任公司 第8 共61页EVP_MD_CTX_cleanup(&
md_ctx);
unsigned char em[256] = {0};
unsigned char sign[256] = {0};
int status = RSA_padding_add_PKCS1_PSS(rsa.get(), em, digest, EVP_sha256(), -2 /* maximum salt length*/);
if (!status) { return false;
} status = RSA_private_encrypt(sizeof(em), em, sign, rsa.get(), RSA_NO_PADDING);
if (-1 == status) { return false;
} *sign_base64encode = base64_encode(sign, sizeof(sign));
return true;
} 构造请求举例(以刷卡支付为例) { Json::Value pay_mch_key;
// 构造pay_mch_key pay_mch_key[ pay_platform ] = 1;
pay_mch_key[ out_mch_id ] = sz013NzuonO6CMJd0rCB ;
pay_mch_key[ out_sub_mch_id ] = sz01ELTR281OFpmdAp6J ;
pay_mch_key[ out_shop_id ] = sz01qyoPJmd3j1hWmul4 ;
Json::Value pay_content;
// 构造pay_content pay_content[ out_trade_no ] = sz0100lmnx20171228151031 ;
pay_content[ author_code ] =
134680423163089456 ;
pay_content[ total_fee ] = 1;
pay_content[ fee_type ] = CNY ;
pay_content[ attach ] = attach ;
Json::Value order_client;
// 构造order_client order_client[ machine_no ] = 32-62-A8-14-B3-C0 ;
order_client[ sdk_version ] = 1.0 ;
order_client[ device_id ] = 1;
order_client[ spbill_create_ip ] = 192.168.100.75 ;
order_client[ staff_id ] =
1003 ;
order_client[ terminal_type ] = 2;
Json::Value request_content;
// 构造request_content request_content[ pay_mch_key ] = pay_mch_key;
request_content[ pay_content ] = pay_content;
request_content[ order_client ] = order_client;
request_content[ nonce_str ] = 416492026bc84091bcaf7e74ea90ceba ;
微信云支付 版权所有:腾讯云计算(北京)有限责任公司 第9 共61页Json::FastWriter w;
std::string request_content_str = w.write(request_content);
Json::Value authen;
authen[ authen_code ] = hmac_sha256(authen_key, request_content_str);
//计算认证码 authen[ authen_type ] = 1;
//hmac_sha256 为1 Json::Value authen_info;
authen_info[ a ] = authen;
//认证码,签名是s Json::Value request;
//构造最终发给服务器的请求 request[ request_content ] = request_content_str;
request[ authen_info ] = authen_info;
std::string request_str = w.write(request);
return request_str;
} 响应举例(以刷卡支付为例) 把响应包从 string 转成 json,取出 json 里面的 response_content 和authen_info,具体如下: { response_content : { status :0, description : , log_id :18654852, internal_status :0, micro_pay :{ pay_mch_key :{ pay_platform :2, mch_id :
1900007941 , sub_mch_id :
1900008341 , out_mch_id : 1234mcWYS3iM5TjKLorAZ , out_sub_mch_id : 12343ycHpBDv8GX]fmSvT7, out_shop_id : 1234ruQCleTa9w30AaAH }, order_content :{ out_trade_no : 12341008b320170802191960015 , transaction_id :
2017080221001004620281091091 , trade_type :1, author_code :
282129340414399818 , time_expire :1501676124, time_end :1501676005, nonce_str : 542AB309ECA042FE92355BDEC4E2D733 , create_time :1501676004, last_update_time :1501676005, 微信云支付 版权所有:腾讯云计算(北京)有限责任公司 第10 共61页 is_transforming :false, total_fee :1, fee_type : CNY , cash_fee :1, settlement_total_fee :1, body : 生活用品套餐 , alipay_order_content_ext :{ current_trade_state :2, fund_bill_list :[ { fund_channel : ALIPAYACCOUNT , amount : 1} ], point_amount :0, invoice_amount :1 } }, nonce_str : SmM10CXPlZLalY9PIYdVGVgxcs58wDRG } } , authen_info :{ a :{ authen_type :1, authen_code : ACD4C1920A6C8646B395D0CBB4AF9B395AC0601D1883D8EF2D7BD7238C2991A5 } } } 对response_content 计算认证码,并将该认证码与 authen_info 的authen_code 进行比较. 接口调用说明 交易接口中的门店信息,必须和子商户在云支付手机端商户管理系统设置的一致. 订单和退款单号说明 为了保护不同商户的订单号不重复,云支付为每个服务商录入的子商户分配了 云支付订单前缀 ,在云支付后台的商户详情 中可以看到,该商户的订单和退款单必须以云支付子商户号做前缀. 交易接口 刷卡支付 接口地址 https://pay.qcloud.com/cpay/micro_pay content_type:application/json 输入参数 微信云支付 版权所有:腾讯云计算(北京)有限责任公司 第11 共61页 参数名 必填 类型 说明 request_content 是RequestContent 请求内容,详见本节 RequestContent authen_info 是AuthenInfo 认证信息,详见 AuthenInfo RequestContent 结构 参数名 必填 类型 说明 pay_mch_key 是PayMchKey 支付商户信息,详见 PayMchKey pay_content 是PayContent 订单信息,详见 PayContent order_client 是OrderClient 客户端信息,详见 OrderClient nonce_str 是String(32) 随机字符串 返回参数 参数名 必填 类型 说明 response_content 是ResponseContent 请求内容,详见本节 ResponseContent authen_info 否AuthenInfo 认证信息,详见 AuthenInfo ResponseContent 结构 参数名 必填类型 说明 status 是Status 错误码,详见 Status.0 :成功;