public bool ProcessSuccessfulTransaction(PayExPayment payExPayment, string orderNumber, string orderRef, Cart cart, out string transactionErrorCode) { transactionErrorCode = null; Log.InfoFormat("Processing a transaction for payment with ID:{0} belonging to order with ID: {1}. Order number: {2}. Order reference: {3}", payExPayment.Id, payExPayment.OrderGroupId, orderNumber, orderRef); PaymentMethod currentPayment = _paymentMethodFactory.Create(payExPayment); if (currentPayment == null) { Log.ErrorFormat("As the PaymentMethod for payment with ID:{0} could not be resolved, it cannot be processed by the PayEx Payment Provider!", payExPayment.Id); return(false); } Log.InfoFormat("Completing payment with ID:{0} belonging to order with ID: {1}", payExPayment.Id, payExPayment.OrderGroupId); PaymentCompleteResult result = currentPayment.Complete(orderRef); transactionErrorCode = result.TransactionErrorCode; if (!result.Success) { Log.ErrorFormat("Could not complete payment with ID:{0} belonging to order with ID: {1}. TransactionErrorCode: {2}", payExPayment.Id, payExPayment.OrderGroupId, transactionErrorCode); } else { Log.InfoFormat("Successfully completed payment with ID:{0} belonging to order with ID: {1}", payExPayment.Id, payExPayment.OrderGroupId); } return(result.Success); }
public bool ProcessSuccessfulTransaction(PayExPayment payExPayment, string orderNumber, string orderRef, Cart cart, out string transactionErrorCode) { transactionErrorCode = null; Log.InfoFormat("Processing a transaction for payment with ID:{0} belonging to order with ID: {1}. Order number: {2}. Order reference: {3}", payExPayment.Id, payExPayment.OrderGroupId, orderNumber, orderRef); PaymentMethod currentPayment = _paymentMethodFactory.Create(payExPayment); if (currentPayment == null) { Log.ErrorFormat("As the PaymentMethod for payment with ID:{0} could not be resolved, it cannot be processed by the PayEx Payment Provider!", payExPayment.Id); return false; } Log.InfoFormat("Completing payment with ID:{0} belonging to order with ID: {1}", payExPayment.Id, payExPayment.OrderGroupId); PaymentCompleteResult result = currentPayment.Complete(orderRef); transactionErrorCode = result.TransactionErrorCode; if (!result.Success) Log.ErrorFormat("Could not complete payment with ID:{0} belonging to order with ID: {1}. TransactionErrorCode: {2}", payExPayment.Id, payExPayment.OrderGroupId, transactionErrorCode); else Log.InfoFormat("Successfully completed payment with ID:{0} belonging to order with ID: {1}", payExPayment.Id, payExPayment.OrderGroupId); return result.Success; }