public static string ProcessCard(int orderNumber, int customerId, decimal orderTotal, long paymentProfileId, string transactionMode, bool useLiveTransactions, out string AVSResult, out string AuthorizationResult, out string AuthorizationCode, out string AuthorizationTransID, out string TransactionCommandOut, out string TransactionResponse) { AVSResult = string.Empty; AuthorizationResult = string.Empty; AuthorizationCode = string.Empty; AuthorizationTransID = string.Empty; TransactionCommandOut = string.Empty; TransactionResponse = string.Empty; var status = ERROR; var paymentProcessor = new PaymentProcessor(); CIMResponse processStatus = null; long profileId = DataUtility.GetProfileId(customerId); if (profileId > 0) { if (paymentProfileId > 0) { if (transactionMode.ToUpperInvariant() == "AUTH") { processStatus = paymentProcessor.Authorize(profileId, paymentProfileId, orderNumber, orderTotal); } else if (transactionMode.ToUpperInvariant() == "AUTHCAPTURE") { processStatus = paymentProcessor.AuthCapture(profileId, paymentProfileId, orderNumber, orderTotal); } } } if (processStatus != null) { if (processStatus.Success) { status = OK; AVSResult = processStatus.AvsCode; AuthorizationResult = processStatus.AuthMessage; AuthorizationCode = processStatus.AuthCode; AuthorizationTransID = processStatus.TransactionId; } else { status = processStatus.AuthMessage; if (string.IsNullOrEmpty(status)) { status = "There was an error processing your payment. Please try again, choose a different payment method, or contact customer support."; } } } return(status); }
public PaymentDisplay AuthorizePayment(PaymentRequest request) { var processor = new PaymentProcessor(MerchelloContext, request); var authorize = processor.Authorize(); if (!authorize.Payment.Success) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(authorize.Payment.Result.ToPaymentDisplay()); }
public PaymentResultDisplay AuthorizePayment(PaymentRequestDisplay request) { // Add the amount to the args, this is for the Authorize from the backoffice new payments // for some reason Authorize does not take in the amount and only uses the full invoice amount // which is incorrect when adding adjustments via the back office. var requestArgs = request.ProcessorArgs.ToList(); requestArgs.Add(new KeyValuePair <string, string>("authorizePaymentAmount", request.Amount.ToString(CultureInfo.InvariantCulture))); request.ProcessorArgs = requestArgs; var processor = new PaymentProcessor(MerchelloContext, request); var authorize = processor.Authorize(); var result = new PaymentResultDisplay { Success = authorize.Payment.Success, Invoice = authorize.Invoice.ToInvoiceDisplay(), Payment = authorize.Payment.Result.ToPaymentDisplay(), ApproveOrderCreation = authorize.ApproveOrderCreation }; if (!authorize.Payment.Success) { authorize.Payment.Result.AuditPaymentDeclined(); } else { if (request.Amount > 0) { authorize.Payment.Result.AuditPaymentAuthorize(authorize.Invoice, request.Amount); } else { authorize.Payment.Result.AuditPaymentAuthorize(authorize.Invoice); } } return(result); }
public PaymentResultDisplay AuthorizePayment(PaymentRequest request) { var processor = new PaymentProcessor(MerchelloContext, request); var authorize = processor.Authorize(); var result = new PaymentResultDisplay() { Success = authorize.Payment.Success, Invoice = authorize.Invoice.ToInvoiceDisplay(), Payment = authorize.Payment.Result.ToPaymentDisplay(), ApproveOrderCreation = authorize.ApproveOrderCreation }; if (!authorize.Payment.Success) { authorize.Payment.Result.AuditPaymentDeclined(); } else { authorize.Payment.Result.AuditPaymentAuthorize(authorize.Invoice); } return(result); }
public PaymentResultDisplay AuthorizePayment(PaymentRequestDisplay request) { var processor = new PaymentProcessor(MerchelloContext, request); var authorize = processor.Authorize(); var result = new PaymentResultDisplay() { Success = authorize.Payment.Success, Invoice = authorize.Invoice.ToInvoiceDisplay(), Payment = authorize.Payment.Result.ToPaymentDisplay(), ApproveOrderCreation = authorize.ApproveOrderCreation }; if (!authorize.Payment.Success) { authorize.Payment.Result.AuditPaymentDeclined(); } else { authorize.Payment.Result.AuditPaymentAuthorize(authorize.Invoice); } return result; }