} // SendMoney public virtual PacnetReturnData CheckStatus(int userId, string trackingNumber) { int r = new Random(DateTime.Now.Millisecond).Next(0, 2); var pacnetReturnData = new PacnetReturnData() { Status = statuses[r], TrackingNumber = trackingNumber, Error = "Fake " + statuses[r] }; log.Msg("Fake CheckStatus trackingNumber {0} Status {1}", trackingNumber, pacnetReturnData.Status); return(pacnetReturnData); } // CheckStatus
} // SendMoney public PacnetReturnData CheckStatus(int userId, string trackingNumber) { log.Msg("Pacnet check status(user id: {0}, tracking #: '{1}').", userId, trackingNumber); try { var request = new RavenRequest(RavenOperationType.STATUS.ToString()); request.Set("PaymentRoutingNumber", RoutingNumber); request.Set("TrackingNumber", trackingNumber); request.Set("PymtType", PaymentType); RavenResponse response = request.Send(); using (var wr = new StringWriter()) { serializer.Serialize(wr, response); log.Debug("Result: {0}", wr); } // using log.Msg( "Completed successfully: Pacnet check status(user id: {0}, tracking #: '{1}').", userId, trackingNumber ); var pacnetResponse = new PacnetReturnData(response); log.Msg( "Status = '{2}' at Pacnet check status(user id: {0}, tracking #: '{1}').", userId, trackingNumber, pacnetResponse.Status ); return(pacnetResponse); } catch (Exception ex) { log.Alert( ex, "Error while: Pacnet check status(user id: {0}, tracking #: '{1}').", userId, trackingNumber ); return(new PacnetReturnData { Error = ex.Message }); } // try } // CheckStatus
public PacnetReturnData SendMoney( int userId, decimal amount, string bankNumber, string accountNumber, string accountName, string fileName = "ezbob", string currencyCode = "GBP", string description = "EZBOB" ) { var logNotify = new Action <Exception, Severity, string>((ex, severity, note) => { if (ex == null) { log.Say( severity, "{8}Pacnet send money(userId {0}, amount {1}, bankNumber {2}, accountNumber {3}, accountName {4}," + "fileName {5}, currencyCode {6}, description {7})", userId, amount, bankNumber, accountNumber, accountName, fileName, currencyCode, description, note ); } else { log.Alert( ex, "{8}Pacnet send money(userId {0}, amount {1}, bankNumber {2}, accountNumber {3}, accountName {4}," + "fileName {5}, currencyCode {6}, description {7})", userId, amount, bankNumber, accountNumber, accountName, fileName, currencyCode, description, note ); } // if }); logNotify(null, Severity.Msg, string.Empty); try { var request = new RavenRequest(RavenOperationType.SUBMIT.ToString()); request.Set("PaymentRoutingNumber", RoutingNumber); request.Set("PaymentType", PaymentType); request.Set("Amount", ((int)(amount * 100)).ToString(CultureInfo.InvariantCulture)); request.Set("CurrencyCode", currencyCode); request.Set("BankNumber", bankNumber); request.Set("AccountNumber", accountNumber); request.Set("AccountName", accountName); request.Set("Description", description); if (!string.IsNullOrEmpty(fileName)) { request.Set("Filename", fileName); } var response = request.Send(); using (var wr = new StringWriter()) { serializer.Serialize(wr, response); log.Debug("SendMoney result: {0}", wr); } // using var pacnetReturnData = new PacnetReturnData(response); if (pacnetReturnData.HasError) // transaction failed; { logNotify(null, Severity.Alert, string.Format("Failed with error '{0}' at ", pacnetReturnData.Error)); throw new PacnetException(pacnetReturnData.Error); } // if if (pacnetReturnData.Status.Contains("Invalid")) { logNotify(null, Severity.Alert, string.Format("Invalid status '{0}' at ", pacnetReturnData.Status)); throw new PacnetException(pacnetReturnData.Status); } // if logNotify(null, Severity.Msg, "Completed successfully: "); return(pacnetReturnData); } catch (Exception ex) { logNotify(ex, Severity.Alert, "Error while: "); throw; } // try } // SendMoney