Пример #1
0
		private static JudoPayApi Create(Credentials credentials, JudoEnvironment environment)
		{
			string baseUrl = null;
			switch (environment)
			{
				case JudoEnvironment.Live:
					baseUrl = LIVE_URL;
					break;
				case JudoEnvironment.Sandbox:
					baseUrl = SANDBOX_URL;
					break;
			}
			IHttpClientHelper httpClientHelper = DependencyService.Get<IHttpClientHelper>();
			IClientService clientService = DependencyService.Get<IClientService>();

			var nh = new NativeHandler(httpClientHelper.MessageHandler, credentials,
			                           XamarinLoggerFactory.Create(typeof(AuthorizationHandler)), Apiversionheader, API_VERSION, clientService);
			HttpClientWrapper httpClient = new HttpClientWrapper(nh);
			var connection = new Connection(httpClient,
								 XamarinLoggerFactory.Create,
								 baseUrl);
			var client = new Client(connection);

			return new JudoPayApi(XamarinLoggerFactory.Create, client);
		}
Пример #2
0
        private static JudoPayApi Create(Credentials credentials, JudoEnvironment environment)
        {
            string baseUrl = null;

            switch (environment)
            {
            case JudoEnvironment.Live:
                baseUrl = LIVE_URL;
                break;

            case JudoEnvironment.Sandbox:
                baseUrl = SANDBOX_URL;
                break;
            }

            var httpClient = new HttpClientWrapper(new AuthorizationHandler(credentials,
                                                                            XamarinLoggerFactory.Create(typeof(AuthorizationHandler))),
                                                   new VersioningHandler(Apiversionheader, API_VERSION));
            var connection = new Connection(httpClient,
                                            XamarinLoggerFactory.Create,
                                            baseUrl);
            var client = new Client(connection);

            return(new JudoPayApi(XamarinLoggerFactory.Create, client));
        }
Пример #3
0
            public void UsingDefault(JudoEnvironment judoEnvironment, string expectedUrl)
            {
                var configuration = Substitute.For<IJudoConfiguration>();

                var result = JudoPaymentsFactory.GetEnvironmentUrl(judoEnvironment, configuration);

                Assert.AreEqual(expectedUrl, result);
            }
Пример #4
0
            public void UsingConfigSetting(JudoEnvironment judoEnvironment, string configKey, string expectedUrl)
            {
                var configuration = Substitute.For<IJudoConfiguration>();
                configuration[configKey].Returns(expectedUrl);

                var result = JudoPaymentsFactory.GetEnvironmentUrl(judoEnvironment, configuration);

                Assert.AreEqual(expectedUrl, result);
            }
        internal static string GetEnvironmentUrl(JudoEnvironment judoEnvironment)
        {
            string defaultValue = null;

            switch (judoEnvironment)
            {
            case JudoEnvironment.Sandbox:
                defaultValue = DEFAULT_SANDBOX_URL;
                break;

            case JudoEnvironment.Live:
                defaultValue = DEFAULT_LIVE_URL;
                break;
            }

            return(defaultValue);
        }
        Judo BuildJudo(JudoEnvironment environment = JudoEnvironment.Sandbox)
        {
            // A! - on Android these properties are only customisable through styles.xml - see https://github.com/Judopay/Xamarin-Sample-App/wiki/Theme-reference
            var theme = new Theme
            {
                PageTitle                = "Card details",
                ButtonLabel              = "Authorize payment",
                ShowSecurityMessage      = true,
                SecurityMessageTextColor = Color.Green,
                ButtonTextColor          = Color.Orange,
                ButtonBackgroundColor    = Color.DarkRed,
                BackgroundColor          = Color.LightGray,
                EntryTextColor           = Color.DarkOrange,
                LabelActiveTextColor     = Color.Yellow,    // A!
                LabelInactiveTextColor   = Color.LightPink, // A!
                PlaceholderTextColor     = Color.Fuchsia,   // A!
                ErrorTextColor           = Color.DarkRed,   // A!
                OverlayBackgroundColor   = Color.Black.MultiplyAlpha(0.7)
            };

            return(new Judo
            {
                JudoId = "<JUDO_ID>",
                Token = "<API_TOKEN>",
                Secret = "<API_SECRET>",
                Environment = environment,
                Amount = 0.01m,
                Currency = Settings.Currency,
                MaestroAccepted = Settings.MaestroAllowed,
                AmexAccepted = Settings.AmexAllowed,
                AvsEnabled = Settings.AvsEnabled,
                ConsumerReference = "XamarinSdkConsumerRef",
                MetaData = new Dictionary <string, string> {
                    { "SampleApp", "true" }
                },
                //Theme = theme
            });
        }
        public void GetEnvironmentUrl(JudoEnvironment judoEnvironment, string expectedUrl)
        {
            var result = JudoPaymentsFactory.GetEnvironmentUrl(judoEnvironment);

            Assert.AreEqual(expectedUrl, result);
        }
Пример #8
0
 public static JudoPayApi Create(JudoEnvironment environment, string oauthAccessToken)
 {
     return(Create(new Credentials(oauthAccessToken), environment));
 }
Пример #9
0
 public static JudoPayApi Create(JudoEnvironment environment, string token, string secret)
 {
     return(Create(new Credentials(token, secret), environment));
 }
 /// <summary>
 /// Creates an instance of the judopay api client with a custom base url, that will authenticate with your api token and secret.
 /// </summary>
 /// <param name="judoEnvironment">Either the sandbox (development/testing) or live environments</param>
 /// <param name="token">Your API token (from our merchant dashboard)</param>
 /// <param name="secret">Your API secret (from our merchant dashboard)</param>
 /// <param name="userAgent">The name and version number of the calling application, should be in the form PRODUCT/VERSION</param>
 /// <returns>Initialized instance of the Judopay api client</returns>
 public static JudoPayApi Create(JudoEnvironment judoEnvironment, string token, string secret, ProductInfoHeaderValue userAgent)
 {
     return(Create(new Credentials(token, secret), GetEnvironmentUrl(judoEnvironment), userAgent));
 }
Пример #11
0
        internal static string GetEnvironmentUrl(JudoEnvironment judoEnvironment, IJudoConfiguration configuration = null)
        {
            string key = null;
            string defaultValue = null;

            switch (judoEnvironment)
            {
                case JudoEnvironment.Sandbox:
                    key = SandboxUrlKey;
                    defaultValue = DEFAULT_SANDBOX_URL;
                    break;
                case JudoEnvironment.Live:
                    key = LiveUrlKey;
                    defaultValue = DEFAULT_LIVE_URL;
                    break;
            }

            return GetConfigValue(key, defaultValue, configuration ?? defaultConfigurationAccess);
        }
Пример #12
0
 internal static JudoPayApi Create(Credentials credentials, JudoEnvironment judoEnvironment, string apiVersion)
 {
     return Create(credentials, GetEnvironmentUrl(judoEnvironment), apiVersion, null);
 }
Пример #13
0
 /// <summary>
 /// Creates an instance of the judopay api client with a custom base url, that will authenticate with your api token and secret.
 /// </summary>
 /// <param name="judoEnvironment">Either the sandbox (development/testing) or live environments</param>
 /// <param name="token">Your API token (from our merchant dashboard)</param>
 /// <param name="secret">Your API secret (from our merchant dashboard)</param>
 /// <param name="userAgent">The name and version number of the calling application, should be in the form PRODUCT/VERSION</param>
 /// <returns>Initialized instance of the Judopay api client</returns>
 public static JudoPayApi Create(JudoEnvironment judoEnvironment, string token, string secret, ProductInfoHeaderValue userAgent)
 {
     return Create(new Credentials(token, secret), GetEnvironmentUrl(judoEnvironment), defaultConfigurationAccess, userAgent);
 }
Пример #14
0
 /// <summary>
 /// Creates an instance of the judopay api client with a custom base url, that will authenticate with your api token and secret.
 /// </summary>
 /// <param name="judoEnvironment">Either the sandbox (development/testing) or live environments</param>
 /// <param name="token">Your API token (from our merchant dashboard)</param>
 /// <param name="secret">Your API secret (from our merchant dashboard)</param>
 /// <returns>Initialized instance of the Judopay api client</returns>
 public static JudoPayApi Create(JudoEnvironment judoEnvironment, string token, string secret)
 {
     return Create(token, secret, GetEnvironmentUrl(judoEnvironment), defaultConfigurationAccess);
 }
 internal static JudoPayApi Create(Credentials credentials, JudoEnvironment judoEnvironment, string apiVersion)
 {
     return(Create(credentials, GetEnvironmentUrl(judoEnvironment), apiVersion, null));
 }
Пример #16
0
		public static JudoPayApi Create(JudoEnvironment environment, string token, string secret)
		{
			return Create(new Credentials(token, secret), environment);
		}
Пример #17
0
		public static JudoPayApi Create(JudoEnvironment environment, string oauthAccessToken)
		{
			return Create(new Credentials(oauthAccessToken), environment);
		}
 /// <summary>
 /// Creates an instance of the judopay api client with a custom base url, that will authenticate with your api token and secret.
 /// </summary>
 /// <param name="judoEnvironment">Either the sandbox (development/testing) or live environments</param>
 /// <param name="token">Your API token (from our merchant dashboard)</param>
 /// <param name="secret">Your API secret (from our merchant dashboard)</param>
 /// <returns>Initialized instance of the Judopay api client</returns>
 public static JudoPayApi Create(JudoEnvironment judoEnvironment, string token, string secret)
 {
     return(Create(token, secret, GetEnvironmentUrl(judoEnvironment)));
 }