|
@@ -19,15 +19,15 @@ class Pay extends Controller{
|
|
|
public function pay(){
|
|
|
$data = decode($this->request->post());
|
|
|
|
|
|
- $data['t'] = 1;
|
|
|
- $data['i'] = 1;
|
|
|
- $data['u'] = 324234;
|
|
|
+// $data['i'] = 'com.dashgame.garden.packfresh';
|
|
|
+// $data['t'] = 1;
|
|
|
+// $data['u'] = 1704251601802555535;
|
|
|
|
|
|
- $ipaInfo = Db::name('iap_config')->where(['id'=>$data['i']])->find();
|
|
|
- if(empty($ipaInfo)) dir(json(['error'=>1111]));
|
|
|
+ $ipaInfo = Db::name('iap_config')->where(['item_id'=>$data['i']])->find();
|
|
|
+ if(empty($ipaInfo)) exit(json(['error'=>1111]));
|
|
|
|
|
|
$plugin = $this->payPluginModel->getPayPluginByType($data['t']);
|
|
|
- if(empty($plugin)) dir(json(['error'=>1111]));
|
|
|
+ if(empty($plugin)) exit(json(['error'=>1111]));
|
|
|
|
|
|
$biz_content = $this->getAliTradeInfo($ipaInfo, $data['u']);
|
|
|
$val = $this->getAliPayInfo($plugin, $biz_content);
|
|
@@ -36,17 +36,20 @@ class Pay extends Controller{
|
|
|
}
|
|
|
|
|
|
public function notify(){
|
|
|
-
|
|
|
+ echo 'success';
|
|
|
}
|
|
|
|
|
|
private function getAliTradeInfo($ipa, $user){
|
|
|
$content = [];
|
|
|
|
|
|
- $content['subject'] = "玩家充值";
|
|
|
+ $content['subject'] = $ipa['desc'];
|
|
|
+// $content['subject'] = "Player Pay Money!";
|
|
|
$content['out_trade_no'] = $tradeNo = 'D'.getId();
|
|
|
$content['total_amount'] = $ipa['price'];
|
|
|
+// $content['total_amount'] = 0.01;
|
|
|
$content['product_code'] = 'QUICK_MSECURITY_PAY';
|
|
|
$content['timeout_express'] = '90m';
|
|
|
+// $content['body'] = "Temp Body";
|
|
|
$content['body'] = $ipa['desc'];
|
|
|
|
|
|
$userPay = new UserPay();
|
|
@@ -58,27 +61,31 @@ class Pay extends Controller{
|
|
|
private function getAliPayInfo($plugin, $biz_content){
|
|
|
$params = [];
|
|
|
|
|
|
- $params['gatewayUrl'] = "https://openapi.alipaydev.com/gateway.do";
|
|
|
+// $params['gatewayUrl'] = "https://openapi.alipaydev.com/gateway.do";
|
|
|
+// $params['gatewayUrl'] = "https://openapi.alipay.com/gateway.do ";
|
|
|
|
|
|
$params['app_id'] = $plugin['appid'];
|
|
|
$params['method'] = 'alipay.trade.app.pay';
|
|
|
- $params['format'] = "json";
|
|
|
+ $params['format'] = "JSON";
|
|
|
$params['charset'] = "UTF-8";
|
|
|
$params['version'] = "1.0";
|
|
|
$params['timestamp'] = getCurrentTime();
|
|
|
$params['sign_type'] = "RSA2";
|
|
|
$params['notify_url'] = 'http://'.$_SERVER['SERVER_NAME']._PHP_FILE_.'/'.$this->request->module().'/'.$this->request->controller().'/notify';
|
|
|
$params['biz_content'] = $biz_content;
|
|
|
-
|
|
|
+
|
|
|
ksort($params);
|
|
|
-
|
|
|
- $params['sign'] = aliSign($plugin['private_key'], getAliSignContent($params));
|
|
|
+
|
|
|
+ $sign = aliSign($plugin['private_key'], getAliSignContent($params));
|
|
|
+ $params['sign'] = $sign;
|
|
|
|
|
|
foreach ($params as &$value) {
|
|
|
- $value = characet($value, $params['charset']);
|
|
|
+ //$value = characet($value, $params['charset']);
|
|
|
+ $value = urlencode($value);
|
|
|
}
|
|
|
|
|
|
return $params;
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|
|
|
+
|