本文整理汇总了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);
}