Exemplo n.º 1
0
        public void Test_Idempotency()
        {
            string key = DateTime.Now.Ticks.ToString();

            PayOutBankWireDTO payOut = null;

            // create bankwire
            try
            {
                WalletDTO      wallet  = this.GetJohnsWallet();
                UserNaturalDTO user    = this.GetJohn();
                BankAccountDTO account = this.GetJohnsAccount();

                PayOutBankWirePostDTO payOutPost = new PayOutBankWirePostDTO(user.Id, wallet.Id, new Money {
                    Amount = 10, Currency = CurrencyIso.EUR
                }, new Money {
                    Amount = 5, Currency = CurrencyIso.EUR
                }, account.Id, "Johns bank wire ref");
                payOutPost.Tag            = "DefaultTag";
                payOutPost.CreditedUserId = user.Id;

                payOut = this.Api.PayOuts.CreateBankWire(key, payOutPost);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsNotNull(payOut);


            // test existing key
            IdempotencyResponseDTO result = null;

            try
            {
                result = this.Api.Idempotency.Get(key);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsNotNull(result);


            // test not existing key
            result = null;
            try
            {
                result = this.Api.Idempotency.Get(key + "_no");

                // expect a response error
                Assert.Fail();
            }
            catch (Exception ex)
            {
                /* catch block intentionally left empty */
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PayOut([FromBody] PayOutEncaseDto payOutEncaseDto)
        {
            try
            {
                PayOutBankWireDTO result = null;
                var cryptoCredited       = await _blockChainService.SendCryptoToBurnAddress(payOutEncaseDto.UserId, payOutEncaseDto.PrivateKey, payOutEncaseDto.DebitedAmount);

                if (cryptoCredited)
                {
                    result = await _mangoPayService.CreatePayOut(payOutEncaseDto.UserId, payOutEncaseDto.DebitedAmount);
                }

                return(Ok(result));
            }
            catch (Exception ex)
            {
                Logger.LogException(Log, ex, MethodBase.GetCurrentMethod());
                return(new StatusCodeResult(503));
            }
        }
Exemplo n.º 3
0
        /// <summary>Creates PayOut Bank Wire object.</summary>
        /// <returns>PayOut Bank Wire instance returned from API.</returns>
        protected PayOutBankWireDTO GetJohnsPayOutForCardDirect()
        {
            if (BaseTest._johnsPayOutForCardDirect == null)
            {
                PayInCardDirectDTO payIn   = this.GetNewPayInCardDirect();
                BankAccountDTO     account = this.GetJohnsAccount();

                PayOutBankWirePostDTO payOut = new PayOutBankWirePostDTO(payIn.AuthorId, payIn.CreditedWalletId, new Money {
                    Amount = 10, Currency = CurrencyIso.EUR
                },
                                                                         new Money {
                    Amount = 5, Currency = CurrencyIso.EUR
                }, account.Id, "Johns bank wire ref");
                payOut.Tag            = "DefaultTag";
                payOut.CreditedUserId = payIn.AuthorId;

                BaseTest._johnsPayOutForCardDirect = this.Api.PayOuts.CreateBankWire(payOut);
            }

            return(BaseTest._johnsPayOutForCardDirect);
        }
Exemplo n.º 4
0
        protected PayOutBankWireDTO GetJohnsPayOutBankWire()
        {
            if (BaseTest._johnsPayOutBankWire == null)
            {
                WalletDTO      wallet  = this.GetJohnsWalletWithMoney();
                UserNaturalDTO user    = this.GetJohn();
                BankAccountDTO account = this.GetJohnsAccount();

                PayOutBankWirePostDTO payOut = new PayOutBankWirePostDTO(user.Id, wallet.Id, new Money {
                    Amount = 10, Currency = CurrencyIso.EUR
                }, new Money {
                    Amount = 5, Currency = CurrencyIso.EUR
                }, account.Id, "Johns bank wire ref");
                payOut.Tag            = "DefaultTag";
                payOut.CreditedUserId = user.Id;

                BaseTest._johnsPayOutBankWire = this.Api.PayOuts.CreateBankWire(payOut);
            }

            return(BaseTest._johnsPayOutBankWire);
        }