示例#1
0
        public async Task <HttpResponseMessage> StorePickup(int orderId, StorePickup value)
        {
            //預設值 不能做更改
            value.MerchantID        = Merchant.MerchantID;
            value.HashKey           = Merchant.HashKey;
            value.HashIV            = Merchant.HashIV;
            value.SenderName        = Merchant.SenderName;
            value.SenderPhone       = Merchant.SenderPhone;
            value.SenderCellPhone   = Merchant.SenderCellphone;
            value.MerchantTradeDate = DateTime.Now.ToString();
            value.IsCollection      = Merchant.IsCollection ? "Y" : "N";
            value.ServerReplyURL    = $"{Http}://{Host}/api/ECPay/ECPay/Message?orderId={orderId}";

            _storePickup.EnableSecurityProtocol = true;
            var request = await _storePickup.PostAsyncForECPay(Links.Create, value);

            if (request.Success)
            {
                if (request.Response.Substring(0, 1) != "0" && request.Response.Substring(0, 2) != "10")
                {
                    var json = ObjectConvert <StatusNotification> .QueryStringToJson(request.Response);

                    if (json.RtnCode == 300)
                    {
                        string info = await TradeInfo(json);

                        if (int.TryParse(info, out int temp))
                        {
                            _orderRepository.UpdateOrder(orderId, json.AllPayLogisticsID, "080", temp);
                        }

                        var ptd = new PrintTradeDocument
                        {
                            MerchantID        = Merchant.MerchantID,
                            AllPayLogisticsID = json.AllPayLogisticsID,
                            PlatformID        = "",
                            HashKey           = Merchant.HashKey,
                            HashIV            = Merchant.HashIV
                        };

                        string printHtml = _tradeDocument.PrintForECPay(Links.TradeDocument, ptd);

                        return(Request.CreateResponse(new { html = printHtml }));
                    }
                    else
                    {
                        return(Request.CreateResponse(new { message = json.RtnMsg }));
                    }
                }
                else
                {
                    return(Request.CreateResponse(new { message = request.Response }));
                }
            }
            else
            {
                return(Request.CreateResponse(new { message = request.Message }));
            }
        }
示例#2
0
        public HttpResponseMessage PrintTradeDocument(string orderNumber)
        {
            // 先取得訂單裡 紀錄一筆的物流編號
            var value = _orderRepository.GetByOrderNumber(orderNumber, "080");

            var tdModel = new PrintTradeDocument
            {
                MerchantID        = Merchant.MerchantID,
                AllPayLogisticsID = value.AllPayLogisticsID, //物流編號
                PlatformID        = "",
                HashKey           = Merchant.HashKey,
                HashIV            = Merchant.HashIV
            };

            // 取得 tdModel 裡的值後 傳送至列印流程
            var printHtml = _tradeDocument.PrintForECPay(Links.TradeDocument, tdModel);

            var response = new
            {
                html = printHtml
            };

            return(Request.CreateResponse(response));
        }