Beispiel #1
0
        public void completeCardTransactionTest()
        {
            if (!chargeCard())
            {
                return;
            }
            CardTransactionResponse authorization = client.authorizeCardTransaction(
                TestConfig.CARD_ACCOUNT,
                TestConfig.CARD_NUMBER,
                TestConfig.CARD_ADDRESS_1,
                TestConfig.CARD_ADDRESS_2,
                TestConfig.CARD_EXPIRY,
                TestConfig.CARD_NAME,
                TestConfig.CARD_COUNTRY,
                TestConfig.CARD_STATE,
                TestConfig.CARD_ZIP,
                TestConfig.CARD_SECURITY_CODE,
                TestConfig.CARD_AMOUNT,
                TestConfig.CARD_CURRENCY);

            Assert.IsNotNull(authorization.contentResponse);
            Assert.IsTrue(authorization.isSuccessful());
            Assert.IsNotNull(authorization.getTransactionIndex());
            Assert.IsNotNull(authorization.getTransactionReference());

            CardTransactionResponse completeCardTransaction = client.reverseCardTransaction(
                authorization.getTransactionIndex(), authorization.getTransactionReference());

            Assert.IsNotNull(completeCardTransaction.contentResponse);
            Assert.IsTrue(completeCardTransaction.isSuccessful());
            Assert.IsNotNull(completeCardTransaction.getTransactionIndex());
            Assert.IsNotNull(completeCardTransaction.getTransactionReference());
        }
Beispiel #2
0
        public async Task <IActionResult> Detail(string id)
        {
            var APIKey = Convert.ToString(TempData["APIKey"]);
            var token  = "";

            using (var httpClient = new HttpClient())
            {
                var tokenRequest = new APIModeModel()
                {
                    apiKey = APIKey
                };
                StringContent content = new StringContent(JsonConvert.SerializeObject(tokenRequest), Encoding.UTF8, "application/json");

                using (var response = await httpClient.PostAsync($"{_configuration.GetSection("appSettings")["PaymentAPI"]}/Token", content))
                {
                    token = await response.Content.ReadAsStringAsync();
                }
            }

            CardTransactionResponse cardTransactionResponse = null;

            using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);


                using (var response = await httpClient.GetAsync($"{_configuration.GetSection("appSettings")["PaymentAPI"]}/CardTransaction/Detail/{id}"))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    cardTransactionResponse = JsonConvert.DeserializeObject <CardTransactionResponse>(apiResponse);
                }
            }

            return(View("detail", cardTransactionResponse));
        }