1. 接口: http://xxx.xxx.cn/index.php/Common/apiAlipay;
APP端只需传入排好的订单的串:
public function apiAlipay(){
$home_path = realpath(dirname(__FILE__).'/../'); // /data/wwwroot/jinling/home
//require_once ($home_path.'/alipay-sdk-PHP-20180104135052/AopSdk.php');
//require $home_path.'/alipay-sdk-PHP-20180104135052/aop/AopClient.php';
require $home_path .'/libraries/alipay/AopClient.php';
$data['orderInfo'] = $this->input->post('orderInfo'); // 订单信息,在iOS端加密
$c = new AopClient;
$c->gatewayUrl = "https://openapi.alipay.com/gateway.do";
$c->appId = ""; // 填写你的AppID
$c->rsaPrivateKey = ''; // 应用私钥 在生成私钥的时候看清是java还是非java端
$c->format = "json";
$c->charset = "UTF-8";
$c->signType= "RSA2"; // 这里看清到底是用RSA 还是 RSA2
$c->alipayrsaPublicKey = ''; // 是支付宝公钥!不是应用公钥!
exit(json_encode(array('data'=>$c->rsaSign($data['order_no'],'RSA2')),true));
}
还存在的问题:使用最新的sdk不行,得用相对应的SDK
2. iOS端传入的orderInfo 如下 :
app_id=20180106xxxx7555&
biz_content={ "seller_id": "", "total_amount": "0.01", "subject": "标题", "out_trade_no": "MD2018020413415411744", "timeout_express": "30m", "product_code": "QUICK_MSECURITY_PAY" }&
charset=utf-8&
method=alipay.trade.app.pay&
notify_url=http://jinling.veyd.cn/index.php/AliPay/notify&
sign_type=RSA2&
timestamp=2018-02-04 13:41:54&
version=1.0
image.png