private static AmazonSecurityInfo GetAuthToken(string accessKey, string secretKey, string SellerId) { // The client application name string appName = "C#"; // The client application version string appVersion = "4.0"; // The endpoint for region service and version (see developer guide) string serviceURL = "https://mws.amazonservices.co.uk"; // Create a configuration object MarketplaceWebServiceSellersConfig config = new MarketplaceWebServiceSellersConfig(); config.ServiceURL = serviceURL; // Create the client itself var client = new MarketplaceWebServiceSellersClient(appName, appVersion, accessKey, secretKey, config); //Create the request object GetAuthTokenRequest req = new GetAuthTokenRequest(); req.SellerId = SellerId; try { //Try connecting to server to aquire requested data GetAuthTokenResponse response = client.GetAuthTokenStatus(req); //Create resault objext AmazonSecurityInfo result = new AmazonSecurityInfo(); //Fill in the aquired data to the result object result.MWSAuthToken = response.getAuthTokenResult.MWSAuthToken; result.MerchantId = response.getAuthTokenResult.SellerId; return(result); } catch (Exception e) { //All exceptions are written to MWSAuthToken field to be handled outside this function AmazonSecurityInfo result = new AmazonSecurityInfo(); result.MWSAuthToken = e.Message; return(result); } }
internal static void TestSellerAccount(SOAmazonSetup setupview) { bool marketplaceIdExist = false; try { if (setupview != null) { MarketplaceWebServiceSellersConfig msconfig = new MarketplaceWebServiceSellersConfig(); msconfig.ServiceURL = SOHelper.GetIntegrationType(setupview.IntegrationType.Trim(), SOConstants.serviceUrl); MarketplaceWebServiceSellers.MarketplaceWebServiceSellers client = new MarketplaceWebServiceSellersClient(SOConstants.appName, SOConstants.version, setupview.AccessKey, setupview.SecretKey, msconfig); SOServiceCalls sample = new SOServiceCalls(client); ListMarketplaceParticipationsResponse response = null; response = sample.InvokeListMarketplaceParticipations(setupview.SellerId, setupview.AuthToken); if (response != null) { string integrationType = SOHelper.GetIntegrationType(setupview.IntegrationType.Trim(), SOConstants.domainName); foreach (Marketplace marketplace in response.ListMarketplaceParticipationsResult.ListMarketplaces.Marketplace) { if (!string.IsNullOrEmpty(marketplace.Name) && !string.IsNullOrEmpty(integrationType) && marketplace.Name.ToLower() == integrationType.ToLower() && !string.IsNullOrEmpty(setupview.MarketplaceId) && !string.IsNullOrEmpty(marketplace.MarketplaceId) && setupview.MarketplaceId.ToLower() == marketplace.MarketplaceId.ToLower()) { marketplaceIdExist = true; break; } } } } } catch (Exception ex) { throw new Exception(SOMessages.connectionFailed + Convert.ToString(ex.Message)); } if (marketplaceIdExist) // we need this condition check because if we try to raise PXOperationCompletedException inside try catch block , //the catch block gets executed and displays a success message with error icon. { throw new PXOperationCompletedException(SOMessages.connectionSuccess); } else { throw new PXOperationCompletedWithErrorException(SOMessages.connectionFailed + SOMessages.errorMsg); } }
public AuthTokenRetriver GetAuthToken(string SellerId) { // The client application name string appName = "C#"; // The client application version string appVersion = "4.0"; // The endpoint for region service and version (see developer guide) string serviceURL = "https://mws.amazonservices.co.uk"; // Create a configuration object MarketplaceWebServiceSellersConfig config = new MarketplaceWebServiceSellersConfig(); config.ServiceURL = serviceURL; // Create the client itself var client = new MarketplaceWebServiceSellersClient(appName, appVersion, AccessKey, SecretKey, config); //Create the request object GetAuthTokenRequest req = new GetAuthTokenRequest(); req.SellerId = SellerId; try { //Try connecting to server to aquire requested data GetAuthTokenResponse response = client.GetAuthTokenStatus(req); doRetry = false; this.MWSAuthToken = response.getAuthTokenResult.MWSAuthToken; return(this); } catch (Exception e) { if (e.Message != "Request is throttled") { doRetry = false; } error = e.Message; return(this); } }
public static void Main(string[] args) { // TODO: Set the below configuration variables before attempting to run // Developer AWS access key string accessKey = "AKIAJTIETNNID4BMNRTA"; // Developer AWS secret key string secretKey = "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"; // The client application name string appName = "CSharpSampleCode"; // The client application version string appVersion = "1.0"; // The endpoint for region service and version (see developer guide) // ex: https://mws.amazonservices.com string serviceURL = "https://mws.amazonservices.com"; // Create a configuration object MarketplaceWebServiceSellersConfig config = new MarketplaceWebServiceSellersConfig(); config.ServiceURL = serviceURL; // Set other client connection configurations here if needed // Create the client itself Claytondus.AmazonMWS.Sellers.MarketplaceWebServiceSellers client = new MarketplaceWebServiceSellersClient(appName, appVersion, accessKey, secretKey, config); MarketplaceWebServiceSellersSample sample = new MarketplaceWebServiceSellersSample(client); // Uncomment the operation you'd like to test here // TODO: Modify the request created in the Invoke method to be valid try { IMWSResponse response = null; // response = sample.InvokeGetServiceStatus(); response = sample.InvokeListMarketplaceParticipations(); // response = sample.InvokeListMarketplaceParticipationsByNextToken(); Console.WriteLine("Response:"); ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata; // We recommend logging the request id and timestamp of every call. Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); string responseXml = response.ToXML(); Console.WriteLine(responseXml); } catch (MarketplaceWebServiceSellersException ex) { // Exception properties are important for diagnostics. ResponseHeaderMetadata rhmd = ex.ResponseHeaderMetadata; Console.WriteLine("Service Exception:"); if (rhmd != null) { Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); } Console.WriteLine("Message: " + ex.Message); Console.WriteLine("StatusCode: " + ex.StatusCode); Console.WriteLine("ErrorCode: " + ex.ErrorCode); Console.WriteLine("ErrorType: " + ex.ErrorType); throw ex; } }