예제 #1
0
        /// <summary>
        /// PayOutAsync method pay the payment
        /// </summary>
        /// <param name="payment"></param>
        /// <returns>BankPayOutResponse</returns>
        public async Task <BankPayOutResponse> PayOutAsync(Payment payment)
        {
            var request = new HttpRequestMessage(HttpMethod.Post, this._url);

            request.Content = new StringContent(
                JsonConvert.SerializeObject(payment),
                Encoding.UTF8,
                "application/json"
                );

            var client = _clientFactory.CreateClient();

            try
            {
                var response = await client.SendAsync(request);

                var body = await response.Content.ReadAsStringAsync();

                var bankResponse = JsonConvert.DeserializeObject <BankPayOutResponse>(body);
                this._logger.LogInformation($@"RequestId:{this._requestTrackingService.RequestTraceId} 
                    Bank Payout finished with status:{bankResponse.PaymentStatus}
                    for Card ending: {MaskHelper.Mask(payment.CardNumber)}");

                return(bankResponse);
            }
            catch (JsonException jsonException)
            {
                this._logger.LogError(jsonException, $@"RequestId:{this._requestTrackingService.RequestTraceId} 
                Bank Service Incompatible");

                throw new BankServiceException("Bank Service Incompatible", jsonException)
                      {
                          RequestTraceId = Guid.NewGuid().ToString()
                      };
            }
            catch (HttpRequestException httpRequestException)
            {
                this._logger.LogError(httpRequestException, $@"RequestId:{this._requestTrackingService.RequestTraceId} 
                Bank Service Unavailable");

                throw new BankServiceException("Bank Service Unavailable", httpRequestException)
                      {
                          RequestTraceId = Guid.NewGuid().ToString()
                      };
            }
        }
예제 #2
0
        public void ItCanUnmask()
        {
            sbyte[] payload = Converter.ToTrits(
                "AAMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9AMESSAGEFORYOU9MESSAGEFORYOU9");
            sbyte[] keys = Converter.ToTrits("MYMERKLEROOTHASH");

            //int index = 5;
            ICurl curl = new Curl(SpongeFactory.Mode.CURLP27);

            //add_assign(&mut keys, index as isize);
            sbyte[] cipher = new sbyte[payload.Length];
            Array.Copy(payload, cipher, payload.Length);

            MaskHelper.Mask(cipher, keys, curl);
            curl.Reset();
            MaskHelper.UnMask(cipher, keys, curl);

            Assert.AreEqual(Converter.ToTrytes(cipher), Converter.ToTrytes(payload));
        }
예제 #3
0
        public void MaskValidLengthTest(string cardnumber, string masked)
        {
            var result = MaskHelper.Mask(cardnumber);

            Assert.AreEqual(masked, result);
        }