コード例 #1
0
        /// <summary>
        /// Method returns string value of IPGApiActionResponseObject object
        /// </summary>
        /// <param name="oIPGApiActionResponse">IPGApiActionResponse object to create string from</param>
        /// <returns>string value containing all IPGApiActionResponseObject values</returns>
        public static string IPGApiActionResponseToString(this IPGApiActionResponse oIPGApiActionResponse)
        {
            if (oIPGApiActionResponse == null)
            {
                return("");
            }

            StringBuilder result = new StringBuilder();

            var items = new Dictionary <string, string>()
            {
                { "OrderId", oIPGApiActionResponse.OrderId },
                { "successfully", oIPGApiActionResponse.successfully.ToString() },
                { "ProcessorRequestMessage", oIPGApiActionResponse.ProcessorRequestMessage },
                { "ProcessorResponseCode", oIPGApiActionResponse.ProcessorResponseCode },
                { "ProcessorResponseMessage", oIPGApiActionResponse.ProcessorResponseMessage },
                { "MandateReference", oIPGApiActionResponse.MandateReference },
                { "ResultInfo:MoreResultsAvailable", oIPGApiActionResponse.ResultInfo.ResultInfoToString() }
            };

            result.Append(items.NotNullDataToString());
            //Error message from server
            result.Append(oIPGApiActionResponse.Error.ErrorToString());
            //Data storage items
            result.Append(oIPGApiActionResponse.DataStorageItem.DataStorageItemsToString());
            //Billing
            result.Append(oIPGApiActionResponse.Billing.BillingToString());
            //Shipping
            result.Append(oIPGApiActionResponse.Shipping.ShippingToString());
            //Recurring payment information
            result.Append(oIPGApiActionResponse.RecurringPaymentInformation.RecurringPaymentValuesToString());
            //Transaction values
            result.Append(Environment.NewLine + oIPGApiActionResponse.TransactionValues.TransactionValuesToString() + Environment.NewLine);
            //Basket
            result.Append(oIPGApiActionResponse.Basket.BasketToString());
            //Product
            result.Append(oIPGApiActionResponse.Product.ProductToString());
            //ProductStock
            result.Append(oIPGApiActionResponse.ProductStock.ProductStockToString());
            //OrderValues
            result.Append(oIPGApiActionResponse.OrderValues.OrderValuesToString());
            //MerchantRateForDynamicPricing
            result.Append(oIPGApiActionResponse.MerchantRateForDynamicPricing.MerchantRateForDynamicPricingToString("Merchant Rate For Dynamic Pricing Information"));
            //CardRafeForDCC
            result.Append(oIPGApiActionResponse.CardRateForDCC.CardRafeForDCCToString("Card Rate For DCC Information"));

            return(result.ToString());
        }
コード例 #2
0
        /// <summary>
        /// Method creates a IPG API Action Request, sends and recieves IPG API Action Response.
        /// </summary>
        /// <param name="oIPGApiActionRequest"></param>
        /// <returns>IPG API Action response as string</returns>
        private static String SendActionRequest(IPGApiActionRequest oIPGApiActionRequest)
        {
            var cert = CertificateHandler.LoadCertificate(@"c:\certificates\WS120995000._.4.p12", "tester02");

            IPGApiOrderService oIPGApiOrderService    = new IPGApiOrderService();
            String             RequestResponseMessage = "";

            if (cert != null)
            {
                oIPGApiOrderService.ClientCertificates.Add(cert);
                oIPGApiOrderService.Url = @"https://test.ipg-online.com:443/ipgapi/services";

                NetworkCredential nc = new NetworkCredential("WS120995000._.4", "Tester02");
                oIPGApiOrderService.Credentials = nc;

                //set proxy host and port
                IWebProxy webProxy = new WebProxy("host", 8080);
                webProxy.Credentials      = new NetworkCredential("username", "password");
                oIPGApiOrderService.Proxy = webProxy;
                try
                {
                    //send action request and get response
                    IPGApiActionResponse oResponse = oIPGApiOrderService.IPGApiAction(oIPGApiActionRequest);
                    RequestResponseMessage = oResponse.IPGApiActionResponseToString() ?? "";
                }
                catch (SoapException se)
                {//SoapException: MerchantException or ProcessingException
                    RequestResponseMessage = se.SoapExceptionResponseToString() ?? "";
                }
                catch (Exception e)
                {
                    RequestResponseMessage  = e.Message + Environment.NewLine;
                    RequestResponseMessage += e.InnerException + Environment.NewLine;
                    RequestResponseMessage += e.StackTrace;
                }
            }
            return(RequestResponseMessage);
        }