private RateResponse CallUPSRateRequest(string scode, int Qty, int nrBoxes, int itemsInLastBox, string fullBoxWeight, int valuePerFullBox, int valuePerPartialBox, string partialBoxWeight, inv_detl details, decimal unitPrice, RateService upsService) { RateResponse rateResponse = new RateResponse(); try { RateRequest rateRequest = new RateRequest(); AddCustomerClassification(rateRequest); AddUpsSecurity(upsService); UPS_Shipping_Rate.UPSRateService.RequestType request = new RequestType(); String[] requestOption = { "Rate" }; request.RequestOption = requestOption; rateRequest.Request = request; ShipmentType shipment = new ShipmentType(); AddShipper(shipment); AddShipFromAddress(shipment); AddShipToAddress(shipment); UPS_Shipping_Rate.UPSRateService.CodeDescriptionType service = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType(); service.Code = scode.ToString(); shipment.Service = service; ShipmentRatingOptionsType optype = new ShipmentRatingOptionsType(); optype.NegotiatedRatesIndicator = string.Empty; shipment.ShipmentRatingOptions = optype; AddPackageArray(nrBoxes, itemsInLastBox, fullBoxWeight, partialBoxWeight, valuePerFullBox, valuePerPartialBox, details, shipment); AddInvoiceTotalType(Qty, unitPrice, shipment); rateRequest.Shipment = shipment; // ServicePointManager.ServerCertificateValidationCallback = ValidateRemoteCertificate; rateResponse = upsService.ProcessRate(rateRequest); } catch (Exception ex) { } return(rateResponse); }
private void AddCustomerClassification(RateRequest rateRequest) { UPS_Shipping_Rate.UPSRateService.CodeDescriptionType customerType = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType(); customerType.Code = "53"; customerType.Description = ""; rateRequest.CustomerClassification = customerType; }
private void AddPartialPackage(int nrBoxes, string partialBoxWeight, int valuePerPartialBox, inv_detl details, PackageType[] pkgArray) { PackageType package = new PackageType(); PackageWeightType packageWeight = new PackageWeightType(); packageWeight.Weight = partialBoxWeight; UPS_Shipping_Rate.UPSRateService.CodeDescriptionType uom = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType(); uom.Code = "LBS"; uom.Description = "pounds"; packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; DimensionsType packageDimensions = new DimensionsType(); packageDimensions.Height = ((int)details.CASE_HI.Value).ToString(); packageDimensions.Length = ((int)details.CASE_LEN.Value).ToString(); packageDimensions.Width = ((int)details.CASE_WT.Value).ToString(); UPS_Shipping_Rate.UPSRateService.CodeDescriptionType packDimType = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType(); packDimType.Code = "IN"; packDimType.Description = "Inches"; packageDimensions.UnitOfMeasurement = packDimType; package.Dimensions = packageDimensions; PackageServiceOptionsType packageServiceOptions = new PackageServiceOptionsType(); InsuredValueType insuredValue = new InsuredValueType(); insuredValue.CurrencyCode = "USD"; insuredValue.MonetaryValue = valuePerPartialBox.ToString(); packageServiceOptions.DeclaredValue = insuredValue; package.PackageServiceOptions = packageServiceOptions; UPS_Shipping_Rate.UPSRateService.CodeDescriptionType packType = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType(); packType.Code = "02"; package.PackagingType = packType; pkgArray[nrBoxes] = package; }
private RateResponse CallUPSRateRequest(string scode, int Qty, int nrBoxes, int itemsInLastBox, string fullBoxWeight, int valuePerFullBox, int valuePerPartialBox, string partialBoxWeight, inv_detl details, decimal unitPrice, RateService upsService) { RateResponse rateResponse = new RateResponse(); try { RateRequest rateRequest = new RateRequest(); AddCustomerClassification(rateRequest); AddUpsSecurity(upsService); UPS_Shipping_Rate.UPSRateService.RequestType request = new RequestType(); String[] requestOption = { "Rate" }; request.RequestOption = requestOption; rateRequest.Request = request; ShipmentType shipment = new ShipmentType(); AddShipper(shipment); AddShipFromAddress(shipment); AddShipToAddress(shipment); UPS_Shipping_Rate.UPSRateService.CodeDescriptionType service = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType(); service.Code = scode.ToString(); shipment.Service = service; ShipmentRatingOptionsType optype = new ShipmentRatingOptionsType(); optype.NegotiatedRatesIndicator = string.Empty; shipment.ShipmentRatingOptions = optype; AddPackageArray(nrBoxes, itemsInLastBox, fullBoxWeight, partialBoxWeight, valuePerFullBox, valuePerPartialBox, details, shipment); AddInvoiceTotalType(Qty, unitPrice, shipment); rateRequest.Shipment = shipment; // ServicePointManager.ServerCertificateValidationCallback = ValidateRemoteCertificate; rateResponse = upsService.ProcessRate(rateRequest); } catch (Exception ex) { } return rateResponse; }