当前位置: 首页>>代码示例>>C#>>正文


C# IDictionary.MustContainKey方法代码示例

本文整理汇总了C#中IDictionary.MustContainKey方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.MustContainKey方法的具体用法?C# IDictionary.MustContainKey怎么用?C# IDictionary.MustContainKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDictionary的用法示例。


在下文中一共展示了IDictionary.MustContainKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CancelPayment

        public override ApiInfo CancelPayment( Order order, IDictionary<string, string> settings )
        {
            ApiInfo apiInfo = null;

              try {
            order.MustNotBeNull( "order" );
            settings.MustNotBeNull( "settings" );
            settings.MustContainKey( "accountNumber", "settings" );
            settings.MustContainKey( "encryptionKey", "settings" );

            long accountNumber = long.Parse( settings[ "accountNumber" ] );
            int transactionNumber = int.Parse( order.TransactionInformation.TransactionId );

            string md5Hash = GenerateMD5Hash( accountNumber.ToString( CultureInfo.InvariantCulture ) + transactionNumber.ToString( CultureInfo.InvariantCulture ) + settings[ "encryptionKey" ] );

            XDocument xmlDoc = XDocument.Parse( GetPayExServiceClient( settings ).Cancel2( accountNumber, transactionNumber, md5Hash ), LoadOptions.PreserveWhitespace );
            string errorCode = xmlDoc.XPathSelectElement( "//status/errorCode" ).Value;

            if ( errorCode == "OK" && xmlDoc.XPathSelectElement( "//transactionStatus" ).Value == "4" ) {
              apiInfo = new ApiInfo( xmlDoc.XPathSelectElement( "//transactionNumber" ).Value, PaymentState.Cancelled );
            } else {
              LoggingService.Instance.Log( "PayEx(" + order.OrderNumber + ") - Error making API request - Error code: " + errorCode + " - Description: " + xmlDoc.XPathSelectElement( "//status/description" ).Value );
            }
              } catch ( Exception exp ) {
            LoggingService.Instance.Log( exp, "PayEx(" + order.OrderNumber + ") - Cancel payment" );
              }

              return apiInfo;
        }
开发者ID:jizepi,项目名称:Payment-providers,代码行数:29,代码来源:PayEx.cs

示例2: CancelPayment

        public override ApiInfo CancelPayment( Order order, IDictionary<string, string> settings )
        {
            ApiInfo apiInfo = null;

              try {
            order.MustNotBeNull( "order" );
            settings.MustNotBeNull( "settings" );
            settings.MustContainKey( "merchant", "settings" );
            settings.MustContainKey( "md5secret", "settings" );

            Dictionary<string, string> inputFields = new Dictionary<string, string>();

            inputFields[ "protocol" ] = "7";
            inputFields[ "msgtype" ] = "cancel";
            inputFields[ "merchant" ] = settings[ "merchant" ];
            inputFields[ "transaction" ] = order.TransactionInformation.TransactionId;

            string md5Secret = settings[ "md5secret" ];
            inputFields[ "md5check" ] = GenerateMD5Hash( string.Join( "", inputFields.Values ) + md5Secret );

            apiInfo = MakeApiPostRequest( order.OrderNumber, inputFields, md5Secret );
              } catch ( Exception exp ) {
            LoggingService.Instance.Log( exp, "QuickPay(" + order.OrderNumber + ") - Cancel payment" );
              }

              return apiInfo;
        }
开发者ID:jizepi,项目名称:Payment-providers,代码行数:27,代码来源:QuickPay.cs

示例3: CancelPayment

        public override ApiInfo CancelPayment( Order order, IDictionary<string, string> settings )
        {
            ApiInfo apiInfo = null;

              try {
            order.MustNotBeNull( "order" );
            settings.MustNotBeNull( "settings" );
            settings.MustContainKey( "merchant", "settings" );
            settings.MustContainKey( "md5k1", "settings" );
            settings.MustContainKey( "md5k2", "settings" );
            settings.MustContainKey( "apiusername", "settings" );
            settings.MustContainKey( "apipassword", "settings" );

            Dictionary<string, string> inputFields = new Dictionary<string, string>();

            string merchant = settings[ "merchant" ];
            inputFields[ "merchant" ] = merchant;

            inputFields[ "orderid" ] = order.CartNumber;
            inputFields[ "transact" ] = order.TransactionInformation.TransactionId;
            inputFields[ "textreply" ] = "yes";

            //MD5(key2 + MD5(key1 + “merchant=<merchant>&orderid=<orderid>&transact=<transact>))
            string md5CheckValue = string.Empty;
            md5CheckValue += settings[ "md5k1" ];
            md5CheckValue += "merchant=" + merchant;
            md5CheckValue += "&orderid=" + order.CartNumber;
            md5CheckValue += "&transact=" + order.TransactionInformation.TransactionId;

            inputFields[ "md5key" ] = GenerateMD5Hash( settings[ "md5k2" ] + GenerateMD5Hash( md5CheckValue ) );

            try {
              string response = MakePostRequest( "https://payment.architrade.com/cgi-adm/cancel.cgi", inputFields, new NetworkCredential( settings[ "apiusername" ], settings[ "apipassword" ] ) );

              Regex reg = new Regex( @"result=(\d*)" );
              string result = reg.Match( response ).Groups[ 1 ].Value;

              if ( result == "0" ) {
            apiInfo = new ApiInfo( order.TransactionInformation.TransactionId, PaymentState.Cancelled );
              } else {
            LoggingService.Instance.Log( "DIBS(" + order.OrderNumber + ") - Error making API request - error message: " + result );
              }
            } catch ( WebException ) {
              LoggingService.Instance.Log( "DIBS(" + order.OrderNumber + ") - Error making API request - wrong credentials" );
            }

              } catch ( Exception exp ) {
            LoggingService.Instance.Log( exp, "DIBS(" + order.OrderNumber + ") - Refund payment" );
              }

              return apiInfo;
        }
开发者ID:jizepi,项目名称:Payment-providers,代码行数:52,代码来源:Dibs.cs

示例4: GetCancelUrl

        public override string GetCancelUrl( Order order, IDictionary<string, string> settings )
        {
            settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "cancel_url", "settings" );

              return settings[ "cancel_url" ];
        }
开发者ID:jizepi,项目名称:Payment-providers,代码行数:7,代码来源:CyberSource.cs

示例5: CancelPayment

        public override ApiInfo CancelPayment( Order order, IDictionary<string, string> settings )
        {
            ApiInfo apiInfo = null;

              try {
            order.MustNotBeNull( "order" );
            settings.MustNotBeNull( "settings" );
            settings.MustContainKey( "Vendor", "settings" );

            Dictionary<string, string> inputFields = new Dictionary<string, string>();

            inputFields[ "VPSProtocol" ] = "2.23";
            inputFields[ "TxType" ] = "CANCEL";
            inputFields[ "Vendor" ] = settings[ "Vendor" ];
            inputFields[ "VendorTxCode" ] = order.CartNumber;
            inputFields[ "VPSTxId" ] = order.TransactionInformation.TransactionId;
            inputFields[ "SecurityKey" ] = order.Properties[ "securityKey" ];

            IDictionary<string, string> responseFields = GetFields( MakePostRequest( GetMethodUrl( "CANCEL", settings ), inputFields ) );

            if ( responseFields[ "Status" ] == "OK" ) {
              apiInfo = new ApiInfo( order.TransactionInformation.TransactionId, PaymentState.Cancelled );
            } else {
              LoggingService.Instance.Log( "Sage pay(" + order.OrderNumber + ") - Error making API request: " + responseFields[ "StatusDetail" ] );
            }
              } catch ( Exception exp ) {
            LoggingService.Instance.Log( exp, "Sage pay(" + order.OrderNumber + ") - Cancel payment" );
              }

              return apiInfo;
        }
开发者ID:jizepi,项目名称:Payment-providers,代码行数:31,代码来源:SagePay.cs

示例6: GetContinueUrl

        public override string GetContinueUrl( Order order, IDictionary<string, string> settings )
        {
            settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "acceptUrl", "settings" );

              return settings["acceptUrl"];
        }
开发者ID:EtchUK,项目名称:Payment-providers,代码行数:7,代码来源:Invoicing.cs

示例7: GetContinueUrl

        public override string GetContinueUrl( Order order, IDictionary<string, string> settings )
        {
            settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "merchant.confirmation_uri", "settings" );

              return settings[ "merchant.confirmation_uri" ];
        }
开发者ID:EtchUK,项目名称:Payment-providers,代码行数:7,代码来源:Klarna.cs

示例8: CapturePayment

        public override ApiInfo CapturePayment( Order order, IDictionary<string, string> settings )
        {
            try {
            order.MustNotBeNull( "order" );
            settings.MustNotBeNull( "settings" );
            settings.MustContainKey( "mode", "settings" );
            settings.MustContainKey( settings[ "mode" ] + "_secret_key", "settings" );

            StripeChargeService chargeService = new StripeChargeService( settings[ settings[ "mode" ] + "_secret_key" ] );
            StripeCharge charge = chargeService.Capture( order.TransactionInformation.TransactionId, (int)order.TransactionInformation.AmountAuthorized.Value * 100 );

            return new ApiInfo( charge.Id, GetPaymentState( charge ) );
              } catch ( Exception exp ) {
            LoggingService.Instance.Log( exp, "Stripe(" + order.OrderNumber + ") - GetStatus" );
              }

              return null;
        }
开发者ID:jizepi,项目名称:Payment-providers,代码行数:18,代码来源:Stripe.cs

示例9: GenerateHtmlForm

        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "x_login", "settings" );
              settings.MustContainKey( "x_type", "settings" );
              settings.MustContainKey( "transactionKey", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = settings.ContainsKey( "testing" ) && settings[ "testing" ] == "1" ? "https://test.authorize.net/gateway/transact.dll" : "https://secure.authorize.net/gateway/transact.dll"
              };

              string[] settingsToExclude = new[] { "transactionKey", "md5HashKey", "testing" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              //Future: Would be cool to support item lines for this one - you have to return a List<Tuple<string, string>> for it to work with this provider
              htmlForm.InputFields[ "x_version" ] = "3.1";
              htmlForm.InputFields[ "x_show_form" ] = "PAYMENT_FORM";
              htmlForm.InputFields[ "x_relay_always" ] = "false";
              htmlForm.InputFields[ "x_relay_response" ] = "TRUE";
              htmlForm.InputFields[ "x_receipt_link_method" ] = "LINK";

              htmlForm.InputFields[ "x_invoice_num" ] = order.CartNumber;

              string amount = order.TotalPrice.Value.WithVat.ToString( "0.00", CultureInfo.InvariantCulture );
              htmlForm.InputFields[ "x_amount" ] = amount;

              htmlForm.InputFields[ "x_receipt_link_url" ] = teaCommerceContinueUrl;
              htmlForm.InputFields[ "x_cancel_url" ] = teaCommerceCancelUrl;

              string sequenceNumber = new Random().Next( 0, 1000 ).ToString( CultureInfo.InvariantCulture );
              htmlForm.InputFields[ "x_fp_sequence" ] = sequenceNumber;

              string timestamp = ( DateTime.UtcNow - new DateTime( 1970, 1, 1 ) ).TotalSeconds.ToString( "0", CultureInfo.InvariantCulture );
              htmlForm.InputFields[ "x_fp_timestamp" ] = timestamp;
              htmlForm.InputFields[ "x_fp_hash" ] = new HMACMD5( Encoding.UTF8.GetBytes( settings[ "transactionKey" ] ) ).ComputeHash( Encoding.UTF8.GetBytes( settings[ "x_login" ] + "^" + sequenceNumber + "^" + timestamp + "^" + amount + "^" ) ).ToHex();

              return htmlForm;
        }
开发者ID:jizepi,项目名称:Payment-providers,代码行数:39,代码来源:AuthorizeNet.cs

示例10: CancelPayment

        public override ApiInfo CancelPayment( Order order, IDictionary<string, string> settings )
        {
            ApiInfo apiInfo = null;

              try {
            order.MustNotBeNull( "order" );
            settings.MustNotBeNull( "settings" );
            settings.MustContainKey( "SECURITY.SENDER", "settings" );
            settings.MustContainKey( "USER.LOGIN", "settings" );
            settings.MustContainKey( "USER.PWD", "settings" );
            settings.MustContainKey( "TRANSACTION.CHANNEL", "settings" );
            settings.MustContainKey( "TRANSACTION.MODE", "settings" );

            Dictionary<string, string> inputFields = new Dictionary<string, string>();
            inputFields[ "REQUEST.VERSION" ] = "1.0";

            inputFields[ "SECURITY.SENDER" ] = settings[ "SECURITY.SENDER" ];
            inputFields[ "USER.LOGIN" ] = settings[ "USER.LOGIN" ];
            inputFields[ "USER.PWD" ] = settings[ "USER.PWD" ];
            inputFields[ "TRANSACTION.CHANNEL" ] = settings[ "TRANSACTION.CHANNEL" ];

            inputFields[ "PAYMENT.CODE" ] = "CC.RV";
            inputFields[ "IDENTIFICATION.REFERENCEID" ] = order.TransactionInformation.TransactionId;
            inputFields[ "TRANSACTION.MODE" ] = settings[ "TRANSACTION.MODE" ];

            IDictionary<string, string> responseKvps = MakePostRequest( settings, inputFields );
            if ( responseKvps[ "PROCESSING.RESULT" ] == "ACK" ) {
              apiInfo = new ApiInfo( responseKvps[ "IDENTIFICATION.UNIQUEID" ], PaymentState.Cancelled );
            } else {
              LoggingService.Instance.Log( "Axcess(" + order.OrderNumber + ") - Error making API request - PROCESSING.CODE: " + responseKvps[ "PROCESSING.CODE" ] );
            }

              } catch ( Exception exp ) {
            LoggingService.Instance.Log( exp, "Axcess(" + order.OrderNumber + ") - Cancel payment" );
              }

              return apiInfo;
        }
开发者ID:jizepi,项目名称:Payment-providers,代码行数:38,代码来源:Axcess.cs

示例11: CancelPayment

        public override ApiInfo CancelPayment( Order order, IDictionary<string, string> settings )
        {
            ApiInfo apiInfo = null;

              try {
            order.MustNotBeNull( "order" );
            settings.MustNotBeNull( "settings" );
            settings.MustContainKey( "merchantId", "settings" );
            settings.MustContainKey( "token", "settings" );

            Dictionary<string, string> inputFields = new Dictionary<string, string>();
            inputFields[ "merchantId" ] = settings[ "merchantId" ];
            inputFields[ "token" ] = settings[ "token" ];
            inputFields[ "operation" ] = "ANNUL";
            inputFields[ "transactionId" ] = order.TransactionInformation.TransactionId;

            apiInfo = MakeApiRequest( order.OrderNumber, inputFields, order.TransactionInformation.TransactionId, PaymentState.Cancelled, settings.ContainsKey( "testMode" ) && settings[ "testMode" ] == "1" ? "https://epayment-test.bbs.no/Netaxept/Process.aspx" : "https://epayment.bbs.no/Netaxept/Process.aspx" );
              } catch ( Exception exp ) {
            LoggingService.Instance.Log( exp, "Netaxept(" + order.OrderNumber + ") - Cancel payment" );
              }

              return apiInfo;
        }
开发者ID:jizepi,项目名称:Payment-providers,代码行数:23,代码来源:Netaxept.cs

示例12: GenerateHtmlForm

        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "paymentFormUrl", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = settings[ "paymentFormUrl" ]
              };

              order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceCommunicationUrl", teaCommerceCommunicationUrl ) { ServerSideOnly = true } );
              order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceContinueUrl", teaCommerceContinueUrl ) { ServerSideOnly = true } );
              order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceCallbackUrl", teaCommerceCallBackUrl ) { ServerSideOnly = true } );

              return htmlForm;
        }
开发者ID:EtchUK,项目名称:Payment-providers,代码行数:16,代码来源:Klarna.cs

示例13: CancelPayment

        public override ApiInfo CancelPayment( Order order, IDictionary<string, string> settings )
        {
            ApiInfo apiInfo = null;

              try {
            order.MustNotBeNull( "order" );
            settings.MustNotBeNull( "settings" );
            settings.MustContainKey( "apiKey", "settings" );

            Dictionary<string, string> parameters = new Dictionary<string, string>();

            apiInfo = MakeApiRequest( order.TransactionInformation.TransactionId, settings[ "apiKey" ], "cancel", parameters );
              } catch ( Exception exp ) {
            LoggingService.Instance.Error<QuickPay10>( "QuickPay(" + order.OrderNumber + ") - Cancel payment", exp );
              }

              return apiInfo;
        }
开发者ID:EtchUK,项目名称:Payment-providers,代码行数:18,代码来源:QuickPay10.cs

示例14: GenerateHtmlForm

        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "form_url", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = settings[ "form_url" ]
              };

              htmlForm.InputFields[ "form_url" ] = settings.ContainsKey( "mode" ) && settings[ "mode" ] == "live" ? LiveTransactionEndpoint : TestTransactionEndpoint;

              htmlForm.InputFields[ "cancel_url" ] = teaCommerceCancelUrl;
              htmlForm.InputFields[ "communication_url" ] = teaCommerceCommunicationUrl;
              order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceContinueUrl", teaCommerceContinueUrl ) { ServerSideOnly = true } );
              order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceCallBackUrl", teaCommerceCallBackUrl ) { ServerSideOnly = true } );
              order.Save();

              return htmlForm;
        }
开发者ID:jizepi,项目名称:Payment-providers,代码行数:20,代码来源:CyberSource.cs

示例15: CancelPayment

        public override ApiInfo CancelPayment( Order order, IDictionary<string, string> settings )
        {
            ApiInfo apiInfo = null;

              try {
            order.MustNotBeNull( "order" );
            settings.MustNotBeNull( "settings" );
            settings.MustContainKey( "merchantnumber", "settings" );

            int ePayResponse = 0;

            if ( GetEPayServiceClient().delete( int.Parse( settings[ "merchantnumber" ] ), long.Parse( order.TransactionInformation.TransactionId ), string.Empty, settings.ContainsKey( "webservicepassword" ) ? settings[ "webservicepassword" ] : string.Empty, ref ePayResponse ) ) {
              apiInfo = new ApiInfo( order.TransactionInformation.TransactionId, PaymentState.Cancelled );
            } else {
              LoggingService.Instance.Warn<ePay>( "ePay(" + order.OrderNumber + ") - Error making API request - error code: " + ePayResponse );
            }
              } catch ( Exception exp ) {
            LoggingService.Instance.Error<ePay>( "ePay(" + order.OrderNumber + ") - Cancel payment", exp );
              }

              return apiInfo;
        }
开发者ID:EtchUK,项目名称:Payment-providers,代码行数:22,代码来源:ePay.cs


注:本文中的IDictionary.MustContainKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。