Example #1
0
        protected PayInCardDirectPostDTO GetPayInCardDirectPost(String userId, string idempotencyKey)
        {
            WalletDTO wallet = this.GetJohnsWalletWithMoney();

            if (userId == null)
            {
                UserNaturalDTO user = this.GetJohn();
                userId = user.Id;
            }

            CardRegistrationPostDTO cardRegistrationPost = new CardRegistrationPostDTO(userId, CurrencyIso.EUR);

            CardRegistrationDTO cardRegistration = this.Api.CardRegistrations.Create(idempotencyKey, cardRegistrationPost);

            CardRegistrationPutDTO cardRegistrationPut = new CardRegistrationPutDTO();

            cardRegistrationPut.RegistrationData = this.GetPaylineCorrectRegistartionData(cardRegistration);
            cardRegistration = this.Api.CardRegistrations.Update(cardRegistrationPut, cardRegistration.Id);

            CardDTO card = this.Api.Cards.Get(cardRegistration.CardId);

            // create pay-in CARD DIRECT
            PayInCardDirectPostDTO payIn = new PayInCardDirectPostDTO(cardRegistration.UserId, cardRegistration.UserId,
                                                                      new Money {
                Amount = 10000, Currency = CurrencyIso.EUR
            }, new Money {
                Amount = 0, Currency = CurrencyIso.EUR
            },
                                                                      wallet.Id, "http://test.com", card.Id);

            // payment type as CARD
            payIn.CardType = card.CardType;

            return(payIn);
        }
        public void Test_Idempotency_PayinsCardDirectCreate()
        {
            string         key    = DateTime.Now.Ticks.ToString();
            UserNaturalDTO john   = this.GetJohn();
            WalletPostDTO  wallet =
                new WalletPostDTO(new List <string> {
                john.Id
            }, "WALLET IN EUR WITH MONEY", CurrencyIso.EUR);
            var johnsWallet = this.Api.Wallets.Create(wallet);
            CardRegistrationPostDTO cardRegistrationPost =
                new CardRegistrationPostDTO(johnsWallet.Owners[0], CurrencyIso.EUR);
            CardRegistrationDTO    cardRegistration    = this.Api.CardRegistrations.Create(cardRegistrationPost);
            CardRegistrationPutDTO cardRegistrationPut = new CardRegistrationPutDTO();

            cardRegistrationPut.RegistrationData = this.GetPaylineCorrectRegistartionData(cardRegistration);
            cardRegistration = this.Api.CardRegistrations.Update(cardRegistrationPut, cardRegistration.Id);
            CardDTO card = this.Api.Cards.Get(cardRegistration.CardId);
            PayInCardDirectPostDTO payIn = new PayInCardDirectPostDTO(cardRegistration.UserId, cardRegistration.UserId,
                                                                      new Money {
                Amount = 1000, Currency = CurrencyIso.EUR
            },
                                                                      new Money {
                Amount = 0, Currency = CurrencyIso.EUR
            },
                                                                      johnsWallet.Id, "http://test.com", card.Id);

            payIn.CardType = card.CardType;
            Api.PayIns.CreateCardDirect(key, payIn);

            var result = Api.Idempotency.Get(key);

            Assert.IsInstanceOf <PayInCardDirectDTO>(result.Resource);
        }
Example #3
0
        /// <summary>Creates card registration object.</summary>
        /// <returns>CardRegistration instance returned from API.</returns>
        protected CardRegistrationDTO GetJohnsCardRegistration()
        {
            if (BaseTest._johnsCardRegistration == null)
            {
                UserNaturalDTO user = this.GetJohn();

                CardRegistrationPostDTO cardRegistration = new CardRegistrationPostDTO(user.Id, CurrencyIso.EUR);

                BaseTest._johnsCardRegistration = this.Api.CardRegistrations.Create(cardRegistration);
            }

            return(BaseTest._johnsCardRegistration);
        }
Example #4
0
        /// <summary>Creates card registration object.</summary>
        /// <param name="cardType">Card type.</param>
        /// <returns>CardRegistration instance returned from API.</returns>
        protected CardRegistrationDTO GetJohnsCardRegistration(CardType cardType = CardType.CB_VISA_MASTERCARD)
        {
            if (BaseTest._johnsCardRegistration == null)
            {
                UserNaturalDTO user = this.GetJohn();

                CardRegistrationPostDTO cardRegistration = new CardRegistrationPostDTO(user.Id, CurrencyIso.EUR, cardType);
                cardRegistration.Tag = "DefaultTag";

                BaseTest._johnsCardRegistration = this.Api.CardRegistrations.Create(cardRegistration);
            }

            return(BaseTest._johnsCardRegistration);
        }
Example #5
0
        /// <summary>Creates wallet for John, if not created yet, or returns an existing one.</summary>
        /// <param name="amount">Initial wallet's money amount.</param>
        /// <returns>Wallet entity instance returned from API.</returns>
        protected WalletDTO GetJohnsWalletWithMoney(int amount)
        {
            if (BaseTest._johnsWalletWithMoney == null)
            {
                UserNaturalDTO john = this.GetJohn();

                // create wallet with money
                WalletPostDTO wallet = new WalletPostDTO(new List <string> {
                    john.Id
                }, "WALLET IN EUR WITH MONEY", CurrencyIso.EUR);

                BaseTest._johnsWalletWithMoney = this.Api.Wallets.Create(wallet);

                CardRegistrationPostDTO cardRegistrationPost = new CardRegistrationPostDTO(BaseTest._johnsWalletWithMoney.Owners[0], CurrencyIso.EUR);
                CardRegistrationDTO     cardRegistration     = this.Api.CardRegistrations.Create(cardRegistrationPost);

                CardRegistrationPutDTO cardRegistrationPut = new CardRegistrationPutDTO();
                cardRegistrationPut.RegistrationData = this.GetPaylineCorrectRegistartionData(cardRegistration);
                cardRegistration = this.Api.CardRegistrations.Update(cardRegistrationPut, cardRegistration.Id);

                CardDTO card = this.Api.Cards.Get(cardRegistration.CardId);

                // create pay-in CARD DIRECT
                PayInCardDirectPostDTO payIn = new PayInCardDirectPostDTO(cardRegistration.UserId, cardRegistration.UserId,
                                                                          new Money {
                    Amount = amount, Currency = CurrencyIso.EUR
                }, new Money {
                    Amount = 0, Currency = CurrencyIso.EUR
                },
                                                                          BaseTest._johnsWalletWithMoney.Id, "http://test.com", card.Id);

                if (card.CardType == CardType.CB || card.CardType == CardType.VISA || card.CardType == CardType.MASTERCARD || card.CardType == CardType.CB_VISA_MASTERCARD)
                {
                    payIn.CardType = CardType.CB_VISA_MASTERCARD;
                }
                else if (card.CardType == CardType.AMEX)
                {
                    payIn.CardType = CardType.AMEX;
                }

                // create Pay-In
                this.Api.PayIns.CreateCardDirect(payIn);
            }

            return(this.Api.Wallets.Get(BaseTest._johnsWalletWithMoney.Id));
        }
Example #6
0
        protected CardPreAuthorizationPostDTO getPreAuthorization(string userId)
        {
            CardRegistrationPostDTO cardRegistrationPost = new CardRegistrationPostDTO(userId, CurrencyIso.EUR);
            CardRegistrationDTO     newCardRegistration  = this.Api.CardRegistrations.Create(cardRegistrationPost);

            CardRegistrationPutDTO cardRegistrationPut = new CardRegistrationPutDTO();
            String registrationData = this.GetPaylineCorrectRegistartionData(newCardRegistration);

            cardRegistrationPut.RegistrationData = registrationData;
            CardRegistrationDTO getCardRegistration = this.Api.CardRegistrations.Update(cardRegistrationPut, newCardRegistration.Id);

            CardPreAuthorizationPostDTO cardPreAuthorization = new CardPreAuthorizationPostDTO(userId, new Money {
                Amount = 10000, Currency = CurrencyIso.EUR
            }, SecureMode.DEFAULT, getCardRegistration.CardId, "http://test.com");

            return(cardPreAuthorization);
        }
Example #7
0
        /// <summary>Creates new wallet for John.</summary>
        /// <param name="amount">Initial wallet's money amount.</param>
        /// <returns>Wallet entity instance returned from API.</returns>
        protected async Task <WalletDTO> GetNewJohnsWalletWithMoney(int amount, UserNaturalDTO user = null)
        {
            UserNaturalDTO john = user;

            if (john == null)
            {
                john = await this.GetJohn();
            }

            // create wallet with money
            WalletPostDTO wallet = new WalletPostDTO(new List <string> {
                john.Id
            }, "WALLET IN EUR WITH MONEY", CurrencyIso.EUR);

            var johnsWalletWithMoney = await this.Api.Wallets.CreateAsync(wallet);

            CardRegistrationPostDTO cardRegistrationPost = new CardRegistrationPostDTO(johnsWalletWithMoney.Owners[0], CurrencyIso.EUR);
            CardRegistrationDTO     cardRegistration     = await this.Api.CardRegistrations.CreateAsync(cardRegistrationPost);

            CardRegistrationPutDTO cardRegistrationPut = new CardRegistrationPutDTO
            {
                RegistrationData = await this.GetPaylineCorrectRegistartionData(cardRegistration)
            };

            cardRegistration = await this.Api.CardRegistrations.UpdateAsync(cardRegistrationPut, cardRegistration.Id);

            CardDTO card = await this.Api.Cards.GetAsync(cardRegistration.CardId);

            // create pay-in CARD DIRECT
            PayInCardDirectPostDTO payIn = new PayInCardDirectPostDTO(cardRegistration.UserId, cardRegistration.UserId,
                                                                      new Money {
                Amount = amount, Currency = CurrencyIso.EUR
            }, new Money {
                Amount = 0, Currency = CurrencyIso.EUR
            },
                                                                      johnsWalletWithMoney.Id, "http://test.com", card.Id);

            payIn.CardType = card.CardType;

            // create Pay-In
            var result = await this.Api.PayIns.CreateCardDirectAsync(payIn);

            return(await this.Api.Wallets.GetAsync(johnsWalletWithMoney.Id));
        }
Example #8
0
        /// <summary>Creates PayIn Card Direct object.</summary>
        /// <param name="userId">User identifier.</param>
        /// <returns>PayIn Card Direct instance returned from API.</returns>
        protected PayInCardDirectDTO GetNewPayInCardDirect(String userId)
        {
            WalletDTO wallet = this.GetJohnsWalletWithMoney();

            if (userId == null)
            {
                UserNaturalDTO user = this.GetJohn();
                userId = user.Id;
            }

            CardRegistrationPostDTO cardRegistrationPost = new CardRegistrationPostDTO(userId, CurrencyIso.EUR);

            CardRegistrationDTO cardRegistration = this.Api.CardRegistrations.Create(cardRegistrationPost);

            CardRegistrationPutDTO cardRegistrationPut = new CardRegistrationPutDTO();

            cardRegistrationPut.RegistrationData = this.GetPaylineCorrectRegistartionData(cardRegistration);
            cardRegistration = this.Api.CardRegistrations.Update(cardRegistrationPut, cardRegistration.Id);

            CardDTO card = this.Api.Cards.Get(cardRegistration.CardId);

            // create pay-in CARD DIRECT
            PayInCardDirectPostDTO payIn = new PayInCardDirectPostDTO(cardRegistration.UserId, cardRegistration.UserId,
                                                                      new Money {
                Amount = 10000, Currency = CurrencyIso.EUR
            }, new Money {
                Amount = 0, Currency = CurrencyIso.EUR
            },
                                                                      wallet.Id, "http://test.com", card.Id);

            // payment type as CARD
            if (card.CardType == CardType.CB || card.CardType == CardType.VISA || card.CardType == CardType.MASTERCARD || card.CardType == CardType.CB_VISA_MASTERCARD)
            {
                payIn.CardType = CardType.CB_VISA_MASTERCARD;
            }
            else if (card.CardType == CardType.AMEX)
            {
                payIn.CardType = CardType.AMEX;
            }

            return(this.Api.PayIns.CreateCardDirect(payIn));
        }
Example #9
0
        public async Task <CardRegistrationDTO> Create(string idempotencyKey, CardRegistrationPostDTO cardRegistration)
        {
            var targetUrl = $"{_baseUrl}/cardregistrations";

            return(await CreateEntity <CardRegistrationDTO, CardRegistrationPostDTO>(targetUrl, cardRegistration, idempotencyKey));
        }
 /// <summary>Creates new card registration.</summary>
 /// <param name="idempotencyKey">Idempotency key for this request.</param>
 /// <param name="cardRegistration">Card registration object to create.</param>
 /// <returns>Card registration object returned from API.</returns>
 public async Task <CardRegistrationDTO> Create(String idempotencyKey, CardRegistrationPostDTO cardRegistration)
 {
     return(await this.CreateObject <CardRegistrationDTO, CardRegistrationPostDTO>(idempotencyKey, MethodKey.CardRegistrationCreate, cardRegistration));
 }
 /// <summary>Creates new card registration.</summary>
 /// <param name="cardRegistration">Card registration object to create.</param>
 /// <returns>Card registration object returned from API.</returns>
 public async Task <CardRegistrationDTO> Create(CardRegistrationPostDTO cardRegistration)
 {
     return(await Create(null, cardRegistration));
 }
 /// <summary>Creates new card registration.</summary>
 /// <param name="cardRegistration">Card registration object to create.</param>
 /// <returns>Card registration object returned from API.</returns>
 public CardRegistrationDTO Create(CardRegistrationPostDTO cardRegistration)
 {
     return(Create(null, cardRegistration));
 }
 /// <summary>Creates new card registration.</summary>
 /// <param name="cardRegistration">Card registration object to create.</param>
 /// <returns>Card registration object returned from API.</returns>
 public CardRegistrationDTO Create(CardRegistrationPostDTO cardRegistration)
 {
     return(this.CreateObject <CardRegistrationDTO, CardRegistrationPostDTO>(MethodKey.CardRegistrationCreate, cardRegistration));
 }