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


C# ProcessorArgumentCollection.TryGetValue方法代码示例

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


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

示例1: PerformVoidPayment

        /// <summary>
        /// The perform void payment.
        /// </summary>
        /// <param name="invoice">
        /// The invoice.
        /// </param>
        /// <param name="payment">
        /// The payment.
        /// </param>
        /// <param name="args">
        /// The args.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentResult"/>.
        /// </returns>
        protected override IPaymentResult PerformVoidPayment(IInvoice invoice, IPayment payment, ProcessorArgumentCollection args)
        {
            string transactionString;
            if (args.TryGetValue(Constants.ExtendedDataKeys.BraintreeTransaction, out transactionString))
            {
                var transaction = JsonConvert.DeserializeObject<Transaction>(transactionString);
                var result = _braintreeApiService.Transaction.Refund(transaction.Id);

                if (!result.IsSuccess()) return new PaymentResult(Attempt<IPayment>.Fail(payment), invoice, false);  

                foreach (var applied in payment.AppliedPayments())
                {
                    applied.TransactionType = AppliedPaymentType.Void;
                    applied.Amount = 0;
                    applied.Description += " - **Void**";
                    GatewayProviderService.Save(applied);
                }

                payment.Voided = true;
                GatewayProviderService.Save(payment);

                return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, false);
            }
            
            return new PaymentResult(Attempt<IPayment>.Fail(payment), invoice, false);
        }
开发者ID:cmgrey83,项目名称:Merchello.Plugin.Payment.Braintree,代码行数:41,代码来源:BraintreeSubscriptionRecordPaymentMethod.cs

示例2: PerformAuthorizeCapturePayment

        /// <summary>
        /// The perform authorize capture payment.
        /// </summary>
        /// <param name="invoice">
        /// The invoice.
        /// </param>
        /// <param name="amount">
        /// The amount.
        /// </param>
        /// <param name="args">
        /// The args.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentResult"/>.
        /// </returns>
        protected override IPaymentResult PerformAuthorizeCapturePayment(IInvoice invoice, decimal amount, ProcessorArgumentCollection args)
        {
            var payment = GatewayProviderService.CreatePayment(PaymentMethodType.Cash, amount, PaymentMethod.Key);
            payment.CustomerKey = invoice.CustomerKey;
            payment.PaymentMethodName = PaymentMethod.Name + " " + PaymentMethod.PaymentCode;
            payment.ReferenceNumber = PaymentMethod.PaymentCode + "-" + invoice.PrefixedInvoiceNumber();
            payment.Collected = true;
            payment.Authorized = true;

            string transaction;
            if (args.TryGetValue(Constants.ExtendedDataKeys.BraintreeTransaction, out transaction))
            {
                payment.ExtendedData.SetValue(Constants.ExtendedDataKeys.BraintreeTransaction, transaction);
            }

            GatewayProviderService.Save(payment);

            GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "Braintree subscription payment", amount);

            return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, CalculateTotalOwed(invoice).CompareTo(amount) <= 0);
        }
开发者ID:cmgrey83,项目名称:Merchello.Plugin.Payment.Braintree,代码行数:36,代码来源:BraintreeSubscriptionRecordPaymentMethod.cs

示例3: PerformCapturePayment

        /// <summary>
        /// The perform capture payment.
        /// </summary>
        /// <param name="invoice">
        /// The invoice.
        /// </param>
        /// <param name="payment">
        /// The payment.
        /// </param>
        /// <param name="amount">
        /// The amount.
        /// </param>
        /// <param name="args">
        /// The args.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentResult"/>.
        /// </returns>
        protected override IPaymentResult PerformCapturePayment(IInvoice invoice, IPayment payment, decimal amount, ProcessorArgumentCollection args)
        {
            payment.Collected = true;
            payment.Authorized = true;

            string transaction;
            if (args.TryGetValue(Constants.ExtendedDataKeys.BraintreeTransaction, out transaction))
            {
                payment.ExtendedData.SetValue(Constants.ExtendedDataKeys.BraintreeTransaction, transaction);
            }

            GatewayProviderService.Save(payment);

            GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "Braintree subscription payment", amount);

            return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, CalculateTotalOwed(invoice).CompareTo(amount) <= 0);
        }
开发者ID:cmgrey83,项目名称:Merchello.Plugin.Payment.Braintree,代码行数:35,代码来源:BraintreeSubscriptionRecordPaymentMethod.cs

示例4: GetArgumentValue

 /// <summary>
 /// Safely gets a value.
 /// </summary>
 /// <param name="args">
 /// The args.
 /// </param>
 /// <param name="argumentName">
 /// The argument name.
 /// </param>
 /// <param name="elseValue">
 /// The else value.
 /// </param>
 /// <returns>
 /// Tries to get an argument value with an optional default
 /// </returns>
 /// <remarks>
 /// This was in the original plugin.
 /// </remarks>
 private static string GetArgumentValue(ProcessorArgumentCollection args, string argumentName, string elseValue = null)
 {
     string value;
     if (args != null && args.TryGetValue(argumentName, out value)) return value;
     return elseValue;
 }
开发者ID:jlarc,项目名称:Merchello,代码行数:24,代码来源:PayPalProcessorArgumentCollectionsExtensions.cs


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