<?php

namespace app\admin\controller\notify;

use support\Log;
use support\Request;
use Yansongda\Pay\Pay;

class OrderPayController
{
    public function wxpay(Request $request)
    {
        Log::channel('pay')->info("WXPAY_NOTIFY_REPLY", $request->all());
        try {
//            $config = config('payment.wxpay');
//            $config['notify_url'] = getenv('NOTIFY_DOMAIN_ADMIN').'/notify/orderPay/wxpay';
//            Pay::wechat($config)->success()->send();

            echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
        }catch (\Exception $e){
            Log::channel('pay')->info("WXPAY_NOTIFY_REPLY_FAIL", ['msg'=>"回复失败"]);
        }

    }

    public function alipay(Request $request)
    {
        Log::channel('pay')->info("ALIPAY_NOTIFY_REPLY", $request->all());
        try {
//            $config = config('payment.alipay');
//            $config['notify_url'] = getenv('NOTIFY_DOMAIN_ADMIN').'/notify/orderPay/alipay';
//            Pay::alipay($config)->success()->send();
            header('Content-type: application/json');
            echo json_encode(['code' => '200', 'msg' => 'success']);
        }catch (\Exception $e){
            Log::channel('pay')->info("ALIPAY_NOTIFY_REPLY_FAIL", ['msg'=>"回复失败"]);
        }
    }
}