DengBiao před 1 rokem
rodič
revize
0a480f4419
1 změnil soubory, kde provedl 59 přidání a 40 odebrání
  1. +59
    -40
      src/applet/app/controllers/AliCallBackController.php

+ 59
- 40
src/applet/app/controllers/AliCallBackController.php Zobrazit soubor

@@ -2,17 +2,6 @@

namespace SRVX\Api\Controllers;

use App\constants\Pay as IPay;
use App\constants\Common as ICommon;
use SRVX\Model\MerchantAlipayAuthorize;
use SRVX\Model\OwnOrder;
use SRVX\Model\UserMerchantOrder;
use SRVX\Msg;
use SRVX\Service\Pay\AlipayService;
use SRVX\Service\Pay\EasyAlipayService;
use SRVX\Service\Pay\PayService;
use SRVX\Service\Pay\Wx\EcommercePayService;
use SRVX\Service\Pay\Wx\PayService as WxPayService;
use SRVX\Traits\BasisFun;

class AliCallBackController extends \Phalcon\Mvc\Controller
@@ -65,50 +54,80 @@ class AliCallBackController extends \Phalcon\Mvc\Controller
//配置应用公私钥 中生成的私钥
$privateKey = 'MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCSGJ9ob4kmGy6y4YeynjKJc/LSg02EXjLErPZSfVrAOy69FTRfBDbazlxpfl6YCAxDdT5ZcspB5kS2XYOY4dmqqPmF4VywmcjmZM8IxZFl1p7YC8BOlP6JrzDPwVl3hn4z3Em1byj8ANLY/AxAaW9W43FSIX+cSfdJThTlxGcbHZFM3kqu++hgFc/E+ar1nB0garqh03ESjatO4b6tuHM57ou7M+fXsoIf3gaL1IDZpeAoRh5sLCBLIbLz55tF0DcOaFsK7NUImnabJDRtrM1IN0lDZkQYAzL+JFsAq+ncRJm60Vd1jq/pXML/cFVHQQgdnjUd2u2NJTSMiCKCftmdAgMBAAECggEARzt+LduEEXJbeJiCI1MC7QX9tSqUFyAevMpgZ6P7JZM1nLfECzfwzwqjAES/Nn1mDVYTCmXvu+XcRtadnWMxUAaHcwGIwgqZa8xnLa220OKuHETOhQIcgWFL+WAakS6gRgT4Y2BJqWV1aJqsFpPR15mZ3SO8JqXhznolskn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

$iv = "";
// 1、验签、请求报文
//判断请求数据数组是否为空
if (empty($params)) {
$response = [
"code" => '40000',
"sub_code" => 'ISV-VERIFICATION-FAILED',
"sub_msg" => "入参数据错误",
];
} else {

if (array_key_exists('biz_content', $params)) {
$biz_content = $params['biz_content'];
} else {
$biz_content = '';
}


$response = [
"code" => "10000",
"msg" => "Success",
"face_group_key" => "K12_2088323332233424",
];

}
// 3、业务处理结果加签,业务返回结果需要进行排序
$response = [
"code" => "10000",
"msg" => "Success",
"face_group_key" => "K12_2088323332233424",
];

// 3、业务处理结果加签,业务返回结果需要进行排序
ksort($response);//数组排序

$contentToSign = json_encode($response);//数组转json
// $responseSecretText = $this->encrypt($contentToSign, $secretKey, $iv);//加密方法,只有当前调用的业务接口需要加解密时才需要

$responseSecretText = $this->encrypt($contentToSign, $secretKey, $iv);//加密方法,只有当前调用的业务接口需要加解密时才需要
//用 接入准备 > 3.配置应用公私钥 中生成的私钥,对第4步的加密字符串进行加签,放到 sign 参数里。
// $sign1 = $this->RSA2($responseSecretText, $privateKey);//加签
$sign1 = $this->RSA2($contentToSign, $privateKey);//加签
$result = [
"sign" => $sign1,
"response" => $contentToSign
];
exit(json_encode(
$result
));
}

public function testAction()
{
$params = $this->request->get();
$this->logger($params, 'testAction', true);

//用 接入准备 > 3.配置应用公私钥 中生成的私钥,对第4步的加密字符串进行加签,放到 sign 参数里。
//获取支付宝行业云公钥
$alipayrsaPublicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuWFuSpwY/2llLhy5Hxkqcc0qQFQOvemkYOI4S43L4qArX4x+DQN1RFuvfGuwOLScBKaoDYHsu9PSoTtcIj4obhhexbWHfelcsouV7Pj4YChrOkOLHAMLDQhGRXaZyXQAJdk2DoBkJ0vBDD/b1gZT8QznPopvuT4Y0rx/a2vK+5B/XV0wUuP2PnpWoPxNSwr7neFWvUdkC7yJJg4zJ1INLYy9TgHH3LKYrsEDbQzPJyMPFhD0zDb36b62q3tQYc1w8JknS6XeXMkX1Tu4zZbAxyIiv3J1FK8y7dtoRi9gLgo0uLsXWDn5AwAlzqfOERgLMWD2r6FE8tOXVbMha6IImQIDAQAB';
//支付宝提供的密钥
$secretKey = "HOrPS0V4BthAPfgSdbHWwy0TwPnC8TQAQZIOjc8vOzI=";
//配置应用公私钥 中生成的私钥
$privateKey = 'MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCSGJ9ob4kmGy6y4YeynjKJc/LSg02EXjLErPZSfVrAOy69FTRfBDbazlxpfl6YCAxDdT5ZcspB5kS2XYOY4dmqqPmF4VywmcjmZM8IxZFl1p7YC8BOlP6JrzDPwVl3hn4z3Em1byj8ANLY/AxAaW9W43FSIX+cSfdJThTlxGcbHZFM3kqu++hgFc/E+ar1nB0garqh03ESjatO4b6tuHM57ou7M+fXsoIf3gaL1IDZpeAoRh5sLCBLIbLz55tF0DcOaFsK7NUImnabJDRtrM1IN0lDZkQYAzL+JFsAq+ncRJm60Vd1jq/pXML/cFVHQQgdnjUd2u2NJTSMiCKCftmdAgMBAAECggEARzt+LduEEXJbeJiCI1MC7QX9tSqUFyAevMpgZ6P7JZM1nLfECzfwzwqjAES/Nn1mDVYTCmXvu+XcRtadnWMxUAaHcwGIwgqZa8xnLa220OKuHETOhQIcgWFL+WAakS6gRgT4Y2BJqWV1aJqsFpPR15mZ3SO8JqXhznolsknqw8sO+DBJu+QXn1HdntSGWrLU4GblPlYAs64y/MzPMUWfA4ShDRn9MZK6ypnh2GB5ezgnFxx1jRGOy96IqikI8f+M/CVdgzErLIl+qTd/IbfL8B6Gccb4ZwimL/x1H1bqYCA6xINMZLo5eDHCvBTU4AW7sItw1Q7MQ8l3wBl7hW62gQKBgQDZT1SEaeBtOJxt3vrK7o/kCWNh/4h9oENFhDIuTvLQk9tirKw0BSiZedjbEHqnqM+bgeuvxazCp9uqoYXgC/dtIooy1P8aso+ZrroC/0vZV7TQBGBjbSSkKPn7ShZM2hfYQFpmLznwpel7KJbP6AJ8atv99wjB6uvqNf6fMU7IbQKBgQCsG3mj0amsYbS5ZQZpl2v65QnlkAxv0dxcstx15kW0hXRugLOu7EGcJNZMhO4gbn8dzMOaJANZPG1VLcFpe/QyP/AW7vDt9vTWdeQkQCD5xcXEDihLLCq0pFaSkmuOHWCI+aepSHUILlJ1P/K/5biD7MTdPg6tyLqyM+rjUd/38QKBgQCNu2fsVQHDOsEMB/qakK3YlSb0q61iAjzeAjKYcXV9BHJ6ERTfeN3Z+9asSjs1TqzZSAtoQQ1EiCaFS4P9dNCTpYttS+52gy+VlJhNjCT0RHfxlGkpb+4OA4vHkbKpvTUAHjjXnMW1ZwC5CugSAchdTXTeV1im4Yms4DqJqacwoQKBgQCocPd7An8qTDIBZMOC4oT29+TYvUO+yMkAHLmx1h4QkLCkWegB4g5QkKkAGPWp3hshAj/KA0cXthFXVUG/SGZ2K6eB+nbon1N+9cDETdM4QXzN5gE/mUlupIxqRU1ouI27YYPbJSQNTrC7OkwNzfnpe/gshEj/gr5eHHvd4UrvMQKBgD2Toow7sfpV0R9rhO8aJ9njlbH15LqUK/AotK3E7zr73Uv5j/BIKS4dVC7T56L2khEUbM/y8+Rig6CdyFf3A4i4GKfbp56Sap/Haa9OP6jfep6VW7Aa1AJxPvIPgPZ2U+EuRxrwrP1EBcL5z6Cern9c9Zzs8BPUacU+Q5e8c87W';
$publicKey = "xxxxxxx";
$iv = "";
// 1、验签、请求报文
$aop = new \AopClient();//调用支付宝SDK
$aop->postCharset="UTF-8";
$aop->alipayrsaPublicKey=$alipayrsaPublicKey;
$sign_type="RSA2";

//验签代码--支付宝SDK函数
$flag = $aop->rsaCheckV1($params, null, $sign_type);
//输出验签结果

dd($flag);
if($flag) {
// 2、验签成功:处理业务逻辑,并构造业务处理结果
//用申请的密钥对biz_content解密得到业务参数
$bizContentPlainText = $this->decrypt($biz_content, $secretKey, $iv);//解密,只有当前调用的业务接口需要加解密时才需要

//var_dump("入参解密数据:".$bizContentPlainText);
}
$response = [
"code" => "10000",
"msg" => "Success",
"face_group_key" => "K12_2088323332233424",
];

$sign1 = $this->RSA2($responseSecretText, $privateKey);//加签
// 3、业务处理结果加签,业务返回结果需要进行排序
ksort($response);//数组排序
$contentToSign = json_encode($response);//数组转json
$responseSecretText = $this->encrypt($contentToSign, $secretKey, $iv);//加密方法,只有当前调用的业务接口需要加解密时才需要

//用 接入准备 > 3.配置应用公私钥 中生成的私钥,对第4步的加密字符串进行加签,放到 sign 参数里。
$sign1 = $this->RSA2($responseSecretText, $privateKey);//加签
$result = [
"sign" => $sign1,
"response" => $responseSecretText
];

exit(json_encode(
$result
));


Načítá se…
Zrušit
Uložit