前提:
因为支付宝没有C++ rsa2加密的支付demo,所以本博主采用了支付使用qt进行https支付, 加密调用php脚本进行加密。
环境:
Qt 5.5.1
php7.0 需要开启php_openssl.dll , 这个自行百度, 就改个php.ini文件。
废话少说直接上代码:
qt:
void Widget::on_pushButton_clicked()
{
QDateTime time = QDateTime::currentDateTime();
QString timestamp = time.toString("yyyy-MM-dd hh:mm:ss");
QString phTimestamp = QString::number(time.toTime_t()); //时间戳 php脚本使用
QString order_id = randNums(11); //订单号 11位随机数
QString code = ui->lineEdit->text();
QString price = "0.01";
QString app_id = "xxxxxxxxxxxx"; //支付宝app_id
// 执行php脚本 传递时间戳 订单id 条码 价钱 进行加密
QProcess pro(0);
QString cmd = QString("php.exe rsa2.php %0 %1 %2 %3").arg(phTimestamp).arg(order_id).arg(code).arg(price);
pro.start(cmd);
pro.wai