/// <summary>Creates new card registration data.</summary>
        /// <param name="cardRegistration">Card registration data object to create.</param>
        /// <returns>Card registration object returned from API.</returns>
        public CardRegistrationDataDTO RegisterCardData(CardRegistrationDataPostDTO cardRegistrationData)
        {
            var client = new RestClient(cardRegistrationData.CardRegistrationURL);

            var request = new RestRequest(Method.POST);
            request.AddParameter(Constants.DATA, cardRegistrationData.PreregistrationData);
            request.AddParameter(Constants.ACCESS_KEY_REF, cardRegistrationData.AccessKey);
            request.AddParameter(Constants.CARD_NUMBER, cardRegistrationData.CardNumber);
            request.AddParameter(Constants.CARD_EXPIRATION_DATE, cardRegistrationData.CardExpirationDate);
            request.AddParameter(Constants.CARD_CVX, cardRegistrationData.CardCvx);

            var response = client.Execute(request);

            var responseString = response.Content;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var cardRegistrationDataDTO = new CardRegistrationDataDTO
                {
                    RegistrationData = responseString
                };
                return cardRegistrationDataDTO;
            }
            else
                throw new Exception(responseString);
        }
Пример #2
0
        public void Test_CardRegistrationData()
        {
            var userId = this.GetJohn().Id;
            var cardRegistrationPost = new CardRegistrationPostDTO(userId,
                CurrencyIso.EUR,
               CardType.CB_VISA_MASTERCARD);
            var cardRegistrationGet = this.Api.CardRegistrations.Create(cardRegistrationPost);

            var cardRegistrationDataPost = new CardRegistrationDataPostDTO(cardRegistrationGet.PreregistrationData,
                cardRegistrationGet.AccessKey, "4970100000000154", "1218", "123", cardRegistrationGet.CardRegistrationURL);
            var cardRegistrationDataGet = this.Api.CardRegistrations.RegisterCardData(cardRegistrationDataPost);

            var cardRegistrationPut = new CardRegistrationPutDTO();
            cardRegistrationPut.RegistrationData = cardRegistrationDataGet.RegistrationData;
            var cardRegistrationPutGet = this.Api.CardRegistrations.Update(cardRegistrationPut, cardRegistrationGet.Id);
        }