public static ITransactionController CreateMockTransactionController( ITransactionRequest txnReq, ICreditCard creditCard) { var response = TransactionResponseType.DECLINED; if (creditCard.ExpiryDate.CompareTo(DateTime.Today) > 0 && txnReq.Amount > 0.0M) { response = TransactionResponseType.OK; } // We use a mock here rather than linq to moq because we need to setup execute for a strict mock behavior. var mockTxnCtrl = new Mock <ITransactionController>(MockBehavior.Strict); var seq = new MockSequence(); mockTxnCtrl.InSequence(seq).Setup(ex => ex.Execute()); mockTxnCtrl.InSequence(seq).Setup(ar => ar.GetApiResponse()).Returns(response); mockTxnCtrl.InSequence(seq).SetupGet(r => r.TransactionRequest).Returns(txnReq); return(mockTxnCtrl.Object); }
public TransactionProvider(IConnection connection, ITransactionRequest transactionRequest) { this.connection = connection; this.transactionRequest = transactionRequest; }
/// <summary> /// Creates a transaction to report an error for a payment gateway. /// </summary> /// <param name="paymentGatewayId">The id of the payment gateway.</param> /// <param name="request">The request for the failed transaction.</param> /// <param name="errorCode">The error code to report.</param> /// <param name="errorMessage">The error message to report.</param> /// <returns>A transaction object configured with the error message.</returns> public static Transaction CreateErrorTransaction(int paymentGatewayId, ITransactionRequest request, string errorCode, string errorMessage) { return(Transaction.CreateErrorTransaction(paymentGatewayId, request.TransactionType, request.Amount, errorCode, errorMessage, request.RemoteIP)); }