private IPaymentResult ProcessPayment(IInvoice invoice, TransactionMode transactionMode, decimal amount, ProcessorArgumentCollection args) { var cc = args.AsCreditCardFormData(); var payment = GatewayProviderService.CreatePayment(PaymentMethodType.CreditCard, invoice.Total, PaymentMethod.Key); payment.CustomerKey = invoice.CustomerKey; payment.Authorized = false; payment.Collected = false; payment.PaymentMethodName = string.Format("{0} Chase Credit Card", cc.CreditCardType); payment.ExtendedData.SetValue(Constants.ExtendedDataKeys.CcLastFour, cc.CardNumber.Substring(cc.CardNumber.Length - 4, 4).EncryptWithMachineKey()); var result = _processor.ProcessPayment(invoice, payment, transactionMode, amount, cc); GatewayProviderService.Save(payment); if (!result.Payment.Success) { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, result.Payment.Exception.Message, 0); } else { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.AuthorizationTransactionResult) + (transactionMode == TransactionMode.AuthorizeAndCapture ? string.Empty : " to show record of Authorization"), transactionMode == TransactionMode.AuthorizeAndCapture ? invoice.Total : 0); } return(result); }
private IPaymentResult ProcessPayment(IInvoice invoice, TransactionMode transactionMode, decimal amount, ProcessorArgumentCollection args) { var cc = args.AsCreditCardFormData(); var payment = GatewayProviderService.CreatePayment(PaymentMethodType.CreditCard, invoice.Total, PaymentMethod.Key); payment.CustomerKey = invoice.CustomerKey; payment.Authorized = false; payment.Collected = false; payment.PaymentMethodName = string.Format("{0} Stripe Credit Card", cc.CreditCardType); payment.ExtendedData.SetValue(Constants.ExtendedDataKeys.CcLastFour, cc.CardNumber.Substring(cc.CardNumber.Length - 4, 4).EncryptWithMachineKey()); var result = _processor.ProcessPayment(invoice, payment, transactionMode, amount, cc); GatewayProviderService.Save(payment); if (!result.Payment.Success) { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, result.Payment.Exception.Message, 0); } else { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, //payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.AuthorizationTransactionResult) + (transactionMode == TransactionMode.AuthorizeAndCapture ? string.Empty : " to show record of Authorization"), transactionMode == TransactionMode.AuthorizeAndCapture ? invoice.Total : 0); } return result; }