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


C# IInvoice.Customer方法代码示例

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


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

示例1: ProcessPayment

        protected override IPaymentResult ProcessPayment(IInvoice invoice, TransactionOption option, decimal amount, string paymentMethodNonce)
        {
            var payment = GatewayProviderService.CreatePayment(PaymentMethodType.CreditCard, amount, PaymentMethod.Key);

            payment.CustomerKey = invoice.CustomerKey;
            payment.Authorized = false;
            payment.Collected = false;
            payment.PaymentMethodName = "Braintree Transaction";
            payment.ExtendedData.SetValue(Braintree.Constants.ProcessorArguments.PaymentMethodNonce, paymentMethodNonce);

            var merchCustomer = invoice.Customer();

            if (merchCustomer == null)
            {
                var customerError = new NullReferenceException("A customer is not associated with the invoice.  Braintree vault transactions require a customer reference.");
                return new PaymentResult(Attempt<IPayment>.Fail(payment, customerError), invoice, false);
            }

            var result = BraintreeApiService.Transaction.Sale(invoice, paymentMethodNonce, merchCustomer, invoice.GetBillingAddress(), option);

            if (result.IsSuccess())
            {
                payment.ExtendedData.SetBraintreeTransaction(result.Target);

                if (option == TransactionOption.Authorize) payment.Authorized = true;
                if (option == TransactionOption.SubmitForSettlement)
                {
                    payment.Authorized = true;
                    payment.Collected = true;
                }

                return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, true);
            }

            var error = new BraintreeApiException(result.Errors, result.Message);

            return new PaymentResult(Attempt<IPayment>.Fail(payment, error), invoice, false);
        }
开发者ID:GaryLProthero,项目名称:Merchello,代码行数:38,代码来源:BraintreeVaultTransactionPaymentGatewayMethod.cs


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