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


C# ProcessorArgumentCollection.GetPaymentMethodToken方法代码示例

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


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

示例1: PerformAuthorizePayment

        /// <summary>
        /// The perform authorize payment.
        /// </summary>
        /// <param name="invoice">
        /// The invoice.
        /// </param>
        /// <param name="args">
        /// The args.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentResult"/>.
        /// </returns>
        protected override IPaymentResult PerformAuthorizePayment(IInvoice invoice, ProcessorArgumentCollection args)
        {
            // The Provider settings 
            if (BraintreeApiService.BraintreeProviderSettings.DefaultTransactionOption == TransactionOption.SubmitForSettlement)
            {
                return this.PerformAuthorizeCapturePayment(invoice, invoice.Total, args);
            }

            var paymentMethodToken = args.GetPaymentMethodToken();

            if (string.IsNullOrEmpty(paymentMethodToken))
            {
                var error = new InvalidOperationException("No payment method token was found in the ProcessorArgumentCollection");
                LogHelper.Debug<BraintreeStandardTransactionPaymentGatewayMethod>(error.Message);
                return new PaymentResult(Attempt<IPayment>.Fail(error), invoice, false);
            }

            var attempt = ProcessPayment(invoice, TransactionOption.Authorize, invoice.Total, paymentMethodToken);

            var payment = attempt.Payment.Result;

            GatewayProviderService.Save(payment);

            if (!attempt.Payment.Success)
            {
                GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, attempt.Payment.Exception.Message, 0);
            }
            else
            {
                GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "To show record of Braintree Authorization", 0);
            }

            return attempt;
        }
开发者ID:cmgrey83,项目名称:Merchello.Plugin.Payment.Braintree,代码行数:46,代码来源:BraintreeVaultTransactionPaymentGatewayMethod.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 paymentMethodToken = args.GetPaymentMethodToken();

            if (string.IsNullOrEmpty(paymentMethodToken))
            {
                var error = new InvalidOperationException("No payment method token was found in the ProcessorArgumentCollection");
                LogHelper.Debug<BraintreeStandardTransactionPaymentGatewayMethod>(error.Message);
                return new PaymentResult(Attempt<IPayment>.Fail(error), invoice, false);
            }

            var attempt = this.ProcessPayment(invoice, TransactionOption.SubmitForSettlement, invoice.Total, paymentMethodToken);

            var payment = attempt.Payment.Result;

            this.GatewayProviderService.Save(payment);

            if (!attempt.Payment.Success)
            {
                this.GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, attempt.Payment.Exception.Message, 0);
            }
            else
            {
                var customerKey = invoice.CustomerKey.GetValueOrDefault();
                var last4 = string.Empty;
                if (!Guid.Empty.Equals(customerKey))
                {
                    var customer = this.BraintreeApiService.Customer.GetBraintreeCustomer(customerKey);
                    if (customer.CreditCards.Any())
                    {
                        var cc = customer.CreditCards.FirstOrDefault(x => x.Token == paymentMethodToken);
                        if (cc != null)
                        {
                            last4 += " - " + cc.CardType + " " + cc.LastFour;
                        }
                    }
                }

                this.GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, this.PaymentLineAuthorizeCaptureDescription + " " + last4, payment.Amount);
            }

            return attempt;
        }
开发者ID:,项目名称:,代码行数:58,代码来源:


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