123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace app\api\controller;
- use app\Request;
- use crmeb\repositories\PaymentRepositories;
- use crmeb\services\AlipayService;
- use crmeb\services\SystemConfigService;
- use crmeb\utils\Hook;
- class AlipayController
- {
- public function Notify()
- {
- $alipay = SystemConfigService::more(['alipay_app_id', 'alipay_pub_key', 'alipay_private_key', 'alipay_key']);
- $Pay = new AlipayService();
- $Pay->setAlipayPublicKey($alipay['alipay_key']);
- $result = $Pay->rsaCheck($_POST, $_POST['sign_type']);
- if ($result === true && $_POST['trade_status'] == 'TRADE_SUCCESS') {
- $out_trade_no = input('out_trade_no', '');
- if (($count = strpos(input('out_trade_no'), '_')) !== false) {
- $out_trade_no = substr(input('out_trade_no'), $count + 1);
- }
- parse_str(input('passback_params'), $attach);
- (new Hook(PaymentRepositories::class, 'wechat'))->listen($attach['attach'], $out_trade_no);
- echo 'success';
- exit();
- } else {
- echo 'error';
- exit();
- }
- }
- }
|