Esempio n. 1
0
        public virtual async Task <object> PayNotifyUrl(string appName, [FromBody] TenPayNotifyXml input)
        {
            Log.Warning(JsonConvert.SerializeObject(input));
            var return_msg  = input.return_msg;
            var return_code = input.return_code;

            var app = await _appProvider.GetOrNullAsync(appName);

            var appsec = app["appsec"] ?? throw new AbpException($"App:{appName} appsec未设置");

            var verifySign = _signatureGenerator.Generate(GetPayParameters(input), MD5.Create(), appsec);

            Log.Warning($"verifySign:{verifySign},InputSign:{input.sign}");

            var tenPayNotify = new TenPayNotify
            {
                appid        = input.appid,
                bank_type    = input.bank_type,
                cash_fee     = input.cash_fee,
                fee_type     = input.fee_type,
                is_subscribe = input.is_subscribe,
                mch_id       = input.mch_id,
                nonce_str    = input.nonce_str,
                openid       = input.openid,
                out_trade_no = input.out_trade_no,
                result_code  = input.result_code,
                return_code  = input.return_code,

                sign           = input.sign,
                time_end       = input.time_end,
                total_fee      = input.total_fee,
                trade_type     = input.trade_type,
                transaction_id = input.transaction_id
            };


            var notify = await _tenpayRepository.FirstOrDefaultAsync(z => z.out_trade_no == tenPayNotify.out_trade_no);

            if (notify == null)
            {
                notify = tenPayNotify;
                var insertEntity = await _tenpayRepository.InsertAsync(notify, autoSave : true);

                await _capBus.PublishAsync("mall.tenpay.notify", insertEntity);
            }

            var xml = $@"<xml>
<return_code><![CDATA[{return_code}]]></return_code>
<return_msg><![CDATA[{return_msg}]]></return_msg>
</xml>";

            return(xml);
        }
Esempio n. 2
0
        public virtual async Task <object> PayNotifyUrl([FromBody] TenPayNotifyXml input)
        {
            Log.Warning(JsonConvert.SerializeObject(input));
            var return_msg  = input.return_msg;
            var return_code = input.return_code;

            var tenPayNotify = new TenPayNotify
            {
                appid        = input.appid,
                bank_type    = input.bank_type,
                cash_fee     = input.cash_fee,
                fee_type     = input.fee_type,
                is_subscribe = input.is_subscribe,
                mch_id       = input.mch_id,
                nonce_str    = input.nonce_str,
                openid       = input.openid,
                out_trade_no = input.out_trade_no,
                result_code  = input.result_code,
                return_code  = input.return_code,

                sign           = input.sign,
                time_end       = input.time_end,
                total_fee      = input.total_fee,
                trade_type     = input.trade_type,
                transaction_id = input.transaction_id
            };

            var notify = await _tenpayRepository.FirstOrDefaultAsync(z => z.out_trade_no == tenPayNotify.out_trade_no);

            if (notify == null)
            {
                notify = tenPayNotify;
                var insertEntity = await _tenpayRepository.InsertAsync(notify, autoSave : true);

                await _capBus.PublishAsync("mall.tenpay.notify", insertEntity);
            }

            var xml = $@"<xml>
<return_code><![CDATA[{return_code}]]></return_code>
<return_msg><![CDATA[{return_msg}]]></return_msg>
</xml>";

            return(xml);
        }
Esempio n. 3
0
        private PayParameters GetPayParameters(TenPayNotifyXml tenPayNotify)
        {
            var p = new PayParameters();

            p.AddParameter("appid", tenPayNotify.appid);
            p.AddParameter("bank_type", tenPayNotify.bank_type);
            p.AddParameter("cash_fee", tenPayNotify.cash_fee);
            p.AddParameter("fee_type", tenPayNotify.fee_type);
            p.AddParameter("is_subscribe", tenPayNotify.is_subscribe);
            p.AddParameter("mch_id", tenPayNotify.mch_id);
            p.AddParameter("nonce_str", tenPayNotify.nonce_str);
            p.AddParameter("openid", tenPayNotify.openid);
            p.AddParameter("out_trade_no", tenPayNotify.out_trade_no);
            p.AddParameter("result_code", tenPayNotify.result_code);
            p.AddParameter("return_code", tenPayNotify.return_code);

            p.AddParameter("time_end", tenPayNotify.time_end);
            p.AddParameter("total_fee", tenPayNotify.total_fee);
            p.AddParameter("trade_type", tenPayNotify.trade_type);
            p.AddParameter("transaction_id", tenPayNotify.transaction_id);
            return(p);
        }