This commit is contained in:
@@ -128,7 +128,7 @@ namespace AyaNova.PlugIn.QBOI
|
|||||||
public static Dictionary<string, string> QCompOtherPrefs = new Dictionary<string, string>();
|
public static Dictionary<string, string> QCompOtherPrefs = new Dictionary<string, string>();
|
||||||
//whether the QB company supports inventory or not
|
//whether the QB company supports inventory or not
|
||||||
//In testing AU, CA, UK and US all support inventory if OfferingSku is "Quickbooks online plus" and not if any other value
|
//In testing AU, CA, UK and US all support inventory if OfferingSku is "Quickbooks online plus" and not if any other value
|
||||||
// public static bool QBSupportsInventory = false;
|
// public static bool QBSupportsInventory = false;
|
||||||
public static string QOfferingSku = "";
|
public static string QOfferingSku = "";
|
||||||
|
|
||||||
|
|
||||||
@@ -294,6 +294,12 @@ namespace AyaNova.PlugIn.QBOI
|
|||||||
const string KAT = "xZ\v\nQ\a(\fN\nX\0\a}\vO[\vZTV_\fWQ,\vV\v-";
|
const string KAT = "xZ\v\nQ\a(\fN\nX\0\a}\vO[\vZTV_\fWQ,\vV\v-";
|
||||||
const string KOACS = "Y?,V\f1^\0\r+\v!<0-1$\n7-9\fV\0?%#3";
|
const string KOACS = "Y?,V\f1^\0\r+\v!<0-1$\n7-9\fV\0?%#3";
|
||||||
|
|
||||||
|
const string Q2_CLIENT_ID = "ABj70Wv5gDauFd9KgKFwuvpQjfzTwEgodEG8tnBbS8mSQhNrZJ";
|
||||||
|
const string Q2_CLIENT_SECRET = "XUmJyvEcEuwQuyhARUAm0a8G3gzbEAeMiATCLyFZ";
|
||||||
|
const string Q2_REDIRECT_URL = "https://qboauth.ayanova.com/redirect";
|
||||||
|
const string Q2_ENVIRONMENT = "Sandbox";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//simple xor encryption
|
//simple xor encryption
|
||||||
private static string Ec(string text, string key)
|
private static string Ec(string text, string key)
|
||||||
@@ -307,99 +313,163 @@ namespace AyaNova.PlugIn.QBOI
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//OAUTH 1.x code, unchanged.
|
||||||
|
|
||||||
|
// static ServiceContext SC = null;
|
||||||
|
// static DesktopIppOAuth.OAuthConnector CN;
|
||||||
|
// //case 3671
|
||||||
|
// //Modify the below code to instead work with a static tokens obtained from qBridge (just for initial testing)
|
||||||
|
////then test that all ops work witha fresh company connection
|
||||||
|
// static public void StartAuthorization()
|
||||||
|
// {
|
||||||
|
// //case 3669
|
||||||
|
// //https://help.developer.intuit.com/s/question/0D50f00005gFeqpCAC/how-do-i-suddenly-get-there-was-an-error-while-communicating-with-the-ids-server
|
||||||
|
// System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; //Add this just to be sure to use TLS1.2
|
||||||
|
|
||||||
|
// //#if(DEBUG)
|
||||||
|
// // string KEY_APP_TOKEN_ENCRYPTED = Ec(KEY_APP_TOKEN, "Invoice");
|
||||||
|
// // string KEY_O_AUTH_CONSUMER_ENCRYPTED = Ec(KEY_O_AUTH_CONSUMER, "Invoice");
|
||||||
|
// // string KEY_O_AUTH_CONSUMER_SECRET_ENCRYPTED = Ec(KEY_O_AUTH_CONSUMER_SECRET, "Invoice");
|
||||||
|
// //#endif
|
||||||
|
// SC = null;
|
||||||
|
// CN = new OAuthConnector();
|
||||||
|
// CN.IppOAuthResultEvent += _authResultEvent;
|
||||||
|
// //CN.Connect(KEY_O_AUTH_CONSUMER, KEY_O_AUTH_CONSUMER_SECRET, "http://www.ayanova.com");
|
||||||
|
// CN.Connect(Ec(KOAC, "Invoice"), Ec(KOACS, "Invoice"), "http://www.ayanova.com");
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
static ServiceContext SC = null;
|
static ServiceContext SC = null;
|
||||||
static DesktopIppOAuth.OAuthConnector CN;
|
//static DesktopIppOAuth.OAuthConnector CN;
|
||||||
//case 3671
|
//case 3671
|
||||||
//Modify the below code to instead work with a static tokens obtained from qBridge (just for initial testing)
|
//Modify the below code to instead work with a static tokens obtained from qBridge (just for initial testing)
|
||||||
//then test that all ops work witha fresh company connection
|
//then test that all ops work witha fresh company connection
|
||||||
static public void StartAuthorization()
|
static public void StartAuthorization()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Intuit.Ipp.OAuth2PlatformClient.OAuth2Client oac = new OAuth2Client(Q2_CLIENT_ID,Q2_CLIENT_SECRET,Q2_REDIRECT_URL, Q2_ENVIRONMENT);
|
||||||
|
|
||||||
//case 3669
|
//case 3669
|
||||||
//https://help.developer.intuit.com/s/question/0D50f00005gFeqpCAC/how-do-i-suddenly-get-there-was-an-error-while-communicating-with-the-ids-server
|
//https://help.developer.intuit.com/s/question/0D50f00005gFeqpCAC/how-do-i-suddenly-get-there-was-an-error-while-communicating-with-the-ids-server
|
||||||
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; //Add this just to be sure to use TLS1.2
|
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; //Add this just to be sure to use TLS1.2
|
||||||
|
|
||||||
//#if(DEBUG)
|
string ACCESS_TOKEN = "";
|
||||||
// string KEY_APP_TOKEN_ENCRYPTED = Ec(KEY_APP_TOKEN, "Invoice");
|
string REFRESH_TOKEN = "";
|
||||||
// string KEY_O_AUTH_CONSUMER_ENCRYPTED = Ec(KEY_O_AUTH_CONSUMER, "Invoice");
|
string REALM_ID = "";
|
||||||
// string KEY_O_AUTH_CONSUMER_SECRET_ENCRYPTED = Ec(KEY_O_AUTH_CONSUMER_SECRET, "Invoice");
|
|
||||||
//#endif
|
|
||||||
SC = null;
|
|
||||||
CN = new OAuthConnector();
|
|
||||||
CN.IppOAuthResultEvent += _authResultEvent;
|
|
||||||
//CN.Connect(KEY_O_AUTH_CONSUMER, KEY_O_AUTH_CONSUMER_SECRET, "http://www.ayanova.com");
|
|
||||||
CN.Connect(Ec(KOAC, "Invoice"), Ec(KOACS, "Invoice"), "http://www.ayanova.com");
|
|
||||||
|
|
||||||
|
Intuit.Ipp.Security.OAuth2RequestValidator validator = new Intuit.Ipp.Security.OAuth2RequestValidator(ACCESS_TOKEN);
|
||||||
|
SC = new Intuit.Ipp.Core.ServiceContext(REALM_ID, Intuit.Ipp.Core.IntuitServicesType.QBO, validator);
|
||||||
|
|
||||||
|
SC.IppConfiguration.Logger.RequestLog.EnableRequestResponseLogging = true;
|
||||||
|
|
||||||
|
SC.IppConfiguration.Logger.RequestLog.ServiceRequestLoggingLocation = "c:\\temp\\qblogs\\";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//' Common setting for both ServiceContexts:
|
||||||
|
|
||||||
|
SC.IppConfiguration.MinorVersion.Qbo = "23";
|
||||||
|
|
||||||
|
SC.IppConfiguration.BaseUrl.Qbo = "https://sandbox-quickbooks.api.intuit.com/";
|
||||||
|
|
||||||
|
//' Serialization Format Json or xml
|
||||||
|
|
||||||
|
SC.IppConfiguration.Message.Request.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
|
||||||
|
|
||||||
|
SC.IppConfiguration.Message.Response.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//' Compression Format can be GZip or Deflate:
|
||||||
|
|
||||||
|
SC.IppConfiguration.Message.Request.CompressionFormat = Intuit.Ipp.Core.Configuration.CompressionFormat.GZip;
|
||||||
|
|
||||||
|
SC.IppConfiguration.Message.Response.CompressionFormat = Intuit.Ipp.Core.Configuration.CompressionFormat.GZip;
|
||||||
|
|
||||||
|
//' Retry 5 times at an interval of 1 Second if service fails. Note that RetryPolicy moved from Intuit.Ipp.Retry to Intuit.Ipp.Core.
|
||||||
|
|
||||||
|
TimeSpan retryInterval = new TimeSpan(0, 0, 0, 1);
|
||||||
|
|
||||||
|
SC.IppConfiguration.RetryPolicy = new Intuit.Ipp.Core.IntuitRetryPolicy(5, retryInterval);
|
||||||
|
|
||||||
|
//' For data updates, create DataService:
|
||||||
|
|
||||||
|
Intuit.Ipp.DataService.DataService loDataService = new Intuit.Ipp.DataService.DataService(SC);
|
||||||
|
_AuthenticationCompleted=true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// Process auth event
|
// /// Process auth event
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="accessToken"></param>
|
// /// <param name="accessToken"></param>
|
||||||
/// <param name="accessTokenSecret"></param>
|
// /// <param name="accessTokenSecret"></param>
|
||||||
/// <param name="realmId"></param>
|
// /// <param name="realmId"></param>
|
||||||
/// <param name="dataSource"></param>
|
// /// <param name="dataSource"></param>
|
||||||
static void _authResultEvent(
|
// static void _authResultEvent(
|
||||||
string accessToken,
|
// string accessToken,
|
||||||
string accessTokenSecret,
|
// string accessTokenSecret,
|
||||||
string realmId,
|
// string realmId,
|
||||||
string dataSource)
|
// string dataSource)
|
||||||
{
|
// {
|
||||||
//Intuit.Ipp.Security.OAuthRequestValidator oauthValidator =
|
// //Intuit.Ipp.Security.OAuthRequestValidator oauthValidator =
|
||||||
// new Intuit.Ipp.Security.OAuthRequestValidator(
|
// // new Intuit.Ipp.Security.OAuthRequestValidator(
|
||||||
// accessToken,
|
// // accessToken,
|
||||||
// accessTokenSecret,
|
// // accessTokenSecret,
|
||||||
// KEY_O_AUTH_CONSUMER,
|
// // KEY_O_AUTH_CONSUMER,
|
||||||
// KEY_O_AUTH_CONSUMER_SECRET);
|
// // KEY_O_AUTH_CONSUMER_SECRET);
|
||||||
|
|
||||||
Intuit.Ipp.Security.OAuthRequestValidator oauthValidator =
|
// Intuit.Ipp.Security.OAuthRequestValidator oauthValidator =
|
||||||
new Intuit.Ipp.Security.OAuthRequestValidator(
|
// new Intuit.Ipp.Security.OAuthRequestValidator(
|
||||||
accessToken,
|
// accessToken,
|
||||||
accessTokenSecret,
|
// accessTokenSecret,
|
||||||
Ec(KOAC, "Invoice"),
|
// Ec(KOAC, "Invoice"),
|
||||||
Ec(KOACS, "Invoice"));
|
// Ec(KOACS, "Invoice"));
|
||||||
|
|
||||||
SC = new ServiceContext(accessToken, realmId, IntuitServicesType.QBO, oauthValidator);
|
// SC = new ServiceContext(accessToken, realmId, IntuitServicesType.QBO, oauthValidator);
|
||||||
|
|
||||||
//TODO: set up a proper retry policy look into it
|
// //TODO: set up a proper retry policy look into it
|
||||||
//https://developer.intuit.com/docs/0100_quickbooks_online/0400_tools/0005_sdks/0010.net_tools/0050_retries
|
// //https://developer.intuit.com/docs/0100_quickbooks_online/0400_tools/0005_sdks/0010.net_tools/0050_retries
|
||||||
|
|
||||||
//FOr now retry every 10 seconds for 3 times for total of a 30 seconds.
|
// //FOr now retry every 10 seconds for 3 times for total of a 30 seconds.
|
||||||
#if(!DEBUG)
|
//#if(!DEBUG)
|
||||||
//Can't do this because I lose the exception and the end user never sees it.
|
// //Can't do this because I lose the exception and the end user never sees it.
|
||||||
// SC.IppConfiguration.RetryPolicy = new Intuit.Ipp.Retry.IntuitRetryPolicy(3, new TimeSpan(0, 0, 10));
|
// // SC.IppConfiguration.RetryPolicy = new Intuit.Ipp.Retry.IntuitRetryPolicy(3, new TimeSpan(0, 0, 10));
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
#if(DEBUG)
|
//#if(DEBUG)
|
||||||
|
|
||||||
//DANGER DANGER!!! If a retry is specified then the only exception error seen during dev is BadRequest
|
// //DANGER DANGER!!! If a retry is specified then the only exception error seen during dev is BadRequest
|
||||||
//and not the actual error.
|
// //and not the actual error.
|
||||||
//Have a case on the go about it:
|
// //Have a case on the go about it:
|
||||||
//https://help.developer.intuit.com/s/case/5000f00001Bu1umAAB
|
// //https://help.developer.intuit.com/s/case/5000f00001Bu1umAAB
|
||||||
|
|
||||||
//SC.IppConfiguration.RetryPolicy = new Intuit.Ipp.Retry.IntuitRetryPolicy(3, new TimeSpan(0, 0, 10));
|
// //SC.IppConfiguration.RetryPolicy = new Intuit.Ipp.Retry.IntuitRetryPolicy(3, new TimeSpan(0, 0, 10));
|
||||||
//SC.IppConfiguration.Logger.RequestLog.EnableRequestResponseLogging = true;
|
// //SC.IppConfiguration.Logger.RequestLog.EnableRequestResponseLogging = true;
|
||||||
//SC.IppConfiguration.Logger.RequestLog.ServiceRequestLoggingLocation = @"C:\temp\QBOLOGS";
|
// //SC.IppConfiguration.Logger.RequestLog.ServiceRequestLoggingLocation = @"C:\temp\QBOLOGS";
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
//Notify that we are authenticated
|
// //Notify that we are authenticated
|
||||||
_AuthenticationCompleted = true;
|
// _AuthenticationCompleted = true;
|
||||||
//todo what happens if we don't login??
|
// //todo what happens if we don't login??
|
||||||
|
|
||||||
//test case 3515
|
// //test case 3515
|
||||||
//System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; //Add this just to be sure to use TLS1.2
|
// //System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; //Add this just to be sure to use TLS1.2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//var result = string.Empty;
|
// //var result = string.Empty;
|
||||||
//using (var webClient = new System.Net.WebClient())
|
// //using (var webClient = new System.Net.WebClient())
|
||||||
//{
|
// //{
|
||||||
// result = webClient.DownloadString("https://tlstest.intuit.com");
|
// // result = webClient.DownloadString("https://tlstest.intuit.com");
|
||||||
//}
|
// //}
|
||||||
|
|
||||||
}
|
// }
|
||||||
#endregion authentication
|
#endregion authentication
|
||||||
|
|
||||||
#region Pre flight check
|
#region Pre flight check
|
||||||
@@ -780,7 +850,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
|
|||||||
|
|
||||||
//this is current as of 7/27/2017
|
//this is current as of 7/27/2017
|
||||||
// wrong wrong wrong apparently, need to use preferences.ProductAndServicesPrefs.QuantityOnHand is true instead
|
// wrong wrong wrong apparently, need to use preferences.ProductAndServicesPrefs.QuantityOnHand is true instead
|
||||||
// QBSupportsInventory = (QOfferingSku == "QuickBooks Online Plus" || QOfferingSku == "QuickBooks Online");
|
// QBSupportsInventory = (QOfferingSku == "QuickBooks Online Plus" || QOfferingSku == "QuickBooks Online");
|
||||||
|
|
||||||
|
|
||||||
QCountry = comp[0].Country;//In testing it was CA for canada and US for US, GB for UK, AU for australia
|
QCountry = comp[0].Country;//In testing it was CA for canada and US for US, GB for UK, AU for australia
|
||||||
@@ -794,7 +864,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
|
|||||||
{
|
{
|
||||||
IntegrationLog.Log(QBID, "PFC: Failed with exception:" + CrackException(ex));
|
IntegrationLog.Log(QBID, "PFC: Failed with exception:" + CrackException(ex));
|
||||||
//clean connection
|
//clean connection
|
||||||
CN.Clean();
|
//CN.Clean();//removed as part of oauth2 switch
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4661,7 +4731,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
|
|||||||
|
|
||||||
#region Part charges
|
#region Part charges
|
||||||
//case 3296
|
//case 3296
|
||||||
PartDisplayFormats defaultPartDisplayFormat = AyaBizUtils.GlobalSettings.DefaultPartDisplayFormat;
|
PartDisplayFormats defaultPartDisplayFormat = AyaBizUtils.GlobalSettings.DefaultPartDisplayFormat;
|
||||||
|
|
||||||
foreach (WorkorderItem it in w.WorkorderItems)
|
foreach (WorkorderItem it in w.WorkorderItems)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user