public static void PaytmShipped1() { try { string token1 = "7a9aef55-7723-426f-a078-86cf78d5282c"; string merchantID1 = "572305"; string orderId1 = "6912017838"; string[] itemIdList1 = new string[] { "7397083852" }; string trackingNum1 = "682156311"; string paytmShipmentUrl1 = "https://fulfillment.paytm.com/v1/merchant/{0}/fulfillment/create/{1}?Authtoken={2}"; paytmShipmentUrl1 = String.Format(paytmShipmentUrl1, merchantID1, orderId1, token1); string userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"; CreateShipmentRequstParameter parameter = new CreateShipmentRequstParameter() { order_item_ids = itemIdList1, tracking_url = "https://www.17track.net", shipper_id = "159", shipping_description = "Gati_International", tracking_number = trackingNum1, weight = "0.029000" }; string json = JsonConvert.SerializeObject(parameter); HttpWebRequest httpRequest = null; paytmShipmentUrl1 = "https://fulfillment.paytm.com/v1/merchant/572305/fulfillment/bulkmarkshipped?fulfillment_ids=6912017838&authtoken=7a9aef55-7723-426f-a078-86cf78d5282c"; httpRequest = (HttpWebRequest)WebRequest.Create(paytmShipmentUrl1); httpRequest.UserAgent = userAgent; // "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"; httpRequest.Method = "POST"; httpRequest.ContentType = "application/json; charset=utf-8"; //返回的数据格式 //byte[] bytesToPost = Encoding.UTF8.GetBytes(json);//转换请求数据为二进制 //httpRequest.ContentLength = bytesToPost.Length; ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //Stream requestStream = httpRequest.GetRequestStream(); //requestStream.Write(bytesToPost, 0, bytesToPost.Length); //requestStream.Close(); HttpWebResponse response = (HttpWebResponse)httpRequest.GetResponse(); StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8); string result = sr.ReadToEnd(); } catch (Exception ex) { string msg = ex.Message; } }
public static void PaytmShipped() { string paytmShipmentUrl = "https://fulfillment.paytm.com/v1/merchant/{0}/fulfillment/create/{1}?authtoken={2}"; string paymDownloadPackingLabelUrl = "https://fulfillment.paytm.com/v2/invoice/merchant/{0}/fulfillment/bulkfetch?fulfillment_ids={1}&template=shared&authtoken={2}&ffUpdate=true"; string paytmShippedUrl = "https://fulfillment.paytm.com/v1/merchant/{0}/fulfillment/bulkmarkshipped?fulfillment_ids={1}&authtoken={2}"; string weigth = "0.030000"; string token = "4162fcb7-0dfd-40f9-822e-18223735b8ca"; string merchantID = "572305"; string orderId = "6962500622"; string[] itemIdList = new string[] { "7449585824" }; string trackingNum = "682390067"; paytmShipmentUrl = String.Format(paytmShipmentUrl, merchantID, orderId, token); using (System.Net.Http.HttpClient client = new System.Net.Http.HttpClient()) { try { CreateShipmentRequstParameter parameter = new CreateShipmentRequstParameter() { order_item_ids = itemIdList, tracking_url = "https://www.17track.net", shipper_id = "159", shipping_description = "shipping_description", tracking_number = trackingNum, weight = weigth }; string json = JsonConvert.SerializeObject(parameter); HttpContent contentPost = new StringContent(json, Encoding.UTF8, "application/json"); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HttpResponseMessage response = client.PostAsync(paytmShipmentUrl, contentPost).Result; string result = response.Content.ReadAsStringAsync().Result; if (!string.IsNullOrEmpty(result)) { CreateShipmentRequstResponse shipmentRequstResponse = JsonConvert.DeserializeObject <CreateShipmentRequstResponse>(result); if (shipmentRequstResponse.res == "success") { if (shipmentRequstResponse.fulfillment_details.status == "15") { } //下载标签 paymDownloadPackingLabelUrl = String.Format(paymDownloadPackingLabelUrl, merchantID, shipmentRequstResponse.fulfillment_id, token); contentPost = new StringContent("", Encoding.UTF8, "application/json"); response = client.GetAsync(paymDownloadPackingLabelUrl).Result; result = response.Content.ReadAsStringAsync().Result; //标识发货 paytmShippedUrl = String.Format(paytmShippedUrl, merchantID, shipmentRequstResponse.fulfillment_id, token); contentPost = new StringContent("", Encoding.UTF8, "application/json"); response = client.PostAsync(paytmShippedUrl, contentPost).Result; result = response.Content.ReadAsStringAsync().Result; if (!string.IsNullOrEmpty(result)) { BulkmarkShippedResponse bulkmarkShippedResponse = JsonConvert.DeserializeObject <BulkmarkShippedResponse>(result); if (bulkmarkShippedResponse.changedRows > 0) { //bulkmarkShippedResponse.success.ForEach(p => //{ // if (p.message == "Successful") // { // string msg = p.message; // } // else // { // string msg = p.message; // } //}); } } } } } catch (Exception ex) { string errorMsg = ex.Message; } } }