Esempio n. 1
0
        public async Task <Configuration> BuildClientSessionConfiguration(CancellationToken cancellationToken = default)
        {
            var session = await _cachingService.GetClientSession();

            if (session.HasValue)
            {
                return(new Configuration {
                    AccessToken = session.Value
                });
            }

            try
            {
                var auth           = new AuthorizationApi();
                var fintechSession = await auth.GetTokenAsync("client_credentials", _settings.ClientId,
                                                              _settings.Secret, cancellationToken : cancellationToken);

                await _cachingService.SaveClientSession(fintechSession._AccessToken);

                return(new Configuration {
                    AccessToken = fintechSession._AccessToken
                });
            }
            catch (ApiException ex)
            {
                _logger.LogError(ex.ToString());
            }

            return(null);
        }
        private string GetUserAccessToken(string userId, string userPassword)
        {
            var authApi      = new AuthorizationApi(BasePath);
            var responseAuth = authApi.GetToken("password", DefaultClientId, DefaultClientSecret, null, userId, userPassword);

            return(responseAuth._AccessToken);
        }
        private string GetClientToken()
        {
            var authApi  = new AuthorizationApi(BasePath);
            var response = authApi.GetToken("client_credentials", DefaultClientId, DefaultClientSecret, null, null, null);

            return(response._AccessToken);
        }
Esempio n. 4
0
 public MainForm()
 {
     InitializeComponent();
     AddLog("Initialisation");
     cmbEnvironment.SelectedIndex = 0;
     usersApi         = new UsersApi();
     authorizationApi = new AuthorizationApi();
 }
        public void Init()
        {
            authorizationApi = new AuthorizationApi("https://merchant-auth-nz.sandbox.zip.co");
            authorizationApi.Configuration.ClientId     = "VxBHMqt9aI4cPHjRBBmLt1Orw6xkk63n";
            authorizationApi.Configuration.ClientSecret = "o7fNo_1vfSDYUyMA_ZD2sVqxAiO-oeEkYo2FDQhiyUdeJ-8-rx91wRrUkUEJmgEe";

            metaData = new Metadata("platform", "nopCommerce v4.2 Payment Plugin");
            instance = new OrdersApi("https://sandbox.zip.co/nz/api");
        }
Esempio n. 6
0
        public void main()
        {
            // Configure API key authorization, get an Access Token, Create an Order, Get an Order

            try
            {
                authorizationApi = new AuthorizationApi("https://api-sandbox.afterpay.com/v2/");
                authorizationApi.Configuration.MerchantId        = "MerchantId";
                authorizationApi.Configuration.MerchantSecretKey = "MerchantSecretKey";
                authorizationApi.Configuration.UserAgent         = "Afterpay SDK; .netCore3.1; Git Example";

                // Create Acces Token
                var authentication = authorizationApi.AuthorizationCreateToken();

                checkoutsApi = new CheckoutsApi(authorizationApi.Configuration);
                paymentsApi  = new PaymentsApi(authorizationApi.Configuration);

                Debug.WriteLine(authentication);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling AuthorizationApi: " + e.Message);
            }

            try
            {
                // Create Checkout
                var createCheckoutRequest = CreateCheckoutRequest();

                var response = checkoutsApi.CheckoutsCreate(createCheckoutRequest);

                var checkout = checkoutsApi.CheckoutsGet(response.Token);

                string orderToken = null;

                var authorization = authorizationApi.AuthorizationCreateToken();

                orderToken = "OrderToken";

                var auth = new Auth("1", orderToken, "Auth for Order");

                var authResponse = paymentsApi.PaymentAuth(auth);

                var amount = new Money("0.00", "NZD");

                var capture = new Capture("1", "1", amount, "Capture for Order"); // Request Id needs to increas for each partial refund

                var id = "OrderId";

                var captureResponse = paymentsApi.PaymentCapture(id, capture);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling OrdersApi: " + e.Message);
            }
        }
Esempio n. 7
0
 public LoginPageViewModel(INavigationService navigationService)
 {
     this.LoginButtonEnabled = true;
     this.NavigationService  = navigationService;
     this.ErrorMessage       = string.Empty;
     this.LoginCommand       = new RelayCommand <object>(this.Login);
     this.RegisterCommand    = new RelayCommand <object>(this.Register);
     this.authApi            = new AuthorizationApi();
     this.NavigationService.SetAuthApi(this.authApi);
 }
Esempio n. 8
0
        public void Login(string username, string password, string tenant = null, string branch = null, string locale = null)
        {
            var cookieContainer = new CookieContainer();

            AuthorizationApi.Configuration.ApiClient.RestClient.CookieContainer = cookieContainer;
            AuthorizationApi.AuthLogin(new Credentials(username, password, tenant, branch, locale));

            //share cookie container between API clients because we use different client for authentication and interaction with endpoint
            CurrentConfiguration.ApiClient.RestClient.CookieContainer = AuthorizationApi.Configuration.ApiClient.RestClient.CookieContainer;
        }
Esempio n. 9
0
 public RegisterPageViewModel(INavigationService navigationService)
 {
     this.NavigationService    = navigationService;
     this.ErrorMessage         = string.Empty;
     this.ErrorCheck           = "wrong";
     this.LoginCommand         = new RelayCommand <object>(this.Login);
     this.RegisterCommand      = new RelayCommand <object>(this.Register);
     this.authApi              = new AuthorizationApi();
     this.LoginContent         = "I already have an account";
     this.LoginContentFontSize = 12;
 }
Esempio n. 10
0
 static void Main(string[] args)
 {
     var authenticationClient = new AuthorizationApi("https://ixapidemo.arxivar.it/OAuth");
     var token = authenticationClient.Token(new IO.Swagger.Model.Account.TokenRequest(
                                                "MioClientID",
                                                "MioClientSecret",
                                                IO.Swagger.Model.Account.TokenRequest.GrantTypeEnum.Password,
                                                "",
                                                "",
                                                new List <string>(),
                                                null,
                                                "v2.0.3.1"));
 }
Esempio n. 11
0
        public async Task <AccessToken> Login(string id, string password, CancellationToken cancellationToken = default)
        {
            try
            {
                var auth = new AuthorizationApi();
                return(await auth.GetTokenAsync("password", _settings.ClientId,
                                                _settings.Secret,
                                                null, id, password, cancellationToken));
            }
            catch (ApiException ex)
            {
                _logger.LogError(ex.ToString());
            }

            return(null);
        }
Esempio n. 12
0
        private IPosDataService CreatePosfDatService(Data.DataObjects.Server server, string tenantAlias)
        {
            IAPIConfig apiConfig = new ApiConfig()
            {
                Tenant                 = tenantAlias,
                TerminalId             = Guid.NewGuid().ToString(),
                AuthorizationAddress   = server.AuthorizationAddress,
                BackOfficeAddress      = server.BackofficeAddress,
                OrderServiceAddress    = server.ServiceAddress.ToLowerInvariant().Replace("/terminalservice.svc", "/orderservice.svc"),
                TerminalServiceAddress = server.ServiceAddress
            };
            IBackOfficeApi    b = new BackOfficeApi(apiConfig);
            IAuthorizationApi a = new AuthorizationApi(apiConfig);
            ITerminalApi      t = new TerminalApi(apiConfig, new SerializationService(), new CheckServerConnectionService());
            var posfDatService  = new PosDataService(_container, b, a, t, server.Login, server.Password);

            return(posfDatService);
        }
        private static bool AuthenticateUser()
        {
            lock (_sync)
            {
                BearerToken = null;

                if (string.IsNullOrEmpty(Username))
                {
                    throw new AuthenticationException("Username must be provided!");
                }

                if (string.IsNullOrEmpty(Password))
                {
                    throw new AuthenticationException("Password must be provided!");
                }

                try
                {
                    var controller = new AuthorizationApi();

                    var request = new PasswordAuthRequest(Username, Password);

                    var response = controller.Token(request);

                    BearerToken = response.Token;

                    Console.WriteLine("Authenticated!");
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to authenticate!");
                    Console.WriteLine(e);
                    throw e;
                }
            }

            return(true);
        }
Esempio n. 14
0
 public void SetAuthApi(AuthorizationApi api)
 {
     this.authApi = api;
 }
Esempio n. 15
0
 public void Init()
 {
     instance = new AuthorizationApi("https://merchant-auth-nz.sandbox.zip.co");
 }
 public AuthorizationApiTests()
 {
     instance = new AuthorizationApi();
 }
Esempio n. 17
0
 public void Logout()
 {
     AuthorizationApi.AuthLogout();
 }
Esempio n. 18
0
 public void Init()
 {
     instance = new AuthorizationApi("https://api-sandbox.afterpay.com/v2/");
 }