コード例 #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 */
            }
        }
コード例 #2
0
        public async Task Test_Idempotency_PayoutsBankwireCreate()
        {
            string    key    = DateTime.Now.Ticks.ToString();
            WalletDTO wallet = await this.GetJohnsWallet();

            UserNaturalDTO user = await this.GetJohn();

            BankAccountDTO account = await 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;
            await Api.PayOuts.CreateBankWire(key, payOut);

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

            Assert.IsInstanceOf <PayOutBankWireDTO>(result.Resource);
        }
コード例 #3
0
        public async Task <PayOutBankWireDTO> CreatePayOut(int userId, long debited)
        {
            var    user = _context.Users.Where(u => u.Id == userId).FirstOrDefault();
            string authorId;
            string debitedWalletId;
            Money  debitedFunds = new Money();
            Money  fees         = new Money();
            string bankAccountId;
            string bankWireRef;

            debitedWalletId = user.WalletId;
            var wallet = await _mangoPayApi.Wallets.Get(debitedWalletId);

            authorId = wallet.Owners[0];


            //-------------------------------------------------//////////////
            // temporaire creation d'un compte bancaire
            var bankAccounts = await _mangoPayApi.Users.GetBankAccounts(authorId);

            if (bankAccounts.Count == 0)
            {
                MangoPay.SDK.Entities.Address adress = new MangoPay.SDK.Entities.Address();
                adress.AddressLine1 = "1 Mangopay Street ";
                adress.AddressLine2 = "The Loop";
                adress.City         = "Paris";
                adress.Country      = CountryIso.FR;
                adress.Region       = "Ile de France";
                adress.PostalCode   = "75001";
                string iban = "FR7630004000031234567890143";
                BankAccountIbanPostDTO bankacount = new BankAccountIbanPostDTO("John doe", adress, iban);
                var Bankid = await _mangoPayApi.Users.CreateBankAccountIban(authorId, bankacount);

                bankAccountId = Bankid.Id;
            }
            else
            {
                bankAccountId = bankAccounts[0].Id;
            }
            // ---------------------------------------- ////////

            debitedFunds.Amount   = debited * 100;
            debitedFunds.Currency = CurrencyIso.EUR;
            fees.Amount           = 0;
            fees.Currency         = CurrencyIso.EUR;

            bankWireRef = "testAUTO";
            PayOutBankWirePostDTO payOut = new PayOutBankWirePostDTO(authorId, debitedWalletId, debitedFunds, fees, bankAccountId, bankWireRef);

            var transferObject = await CreateTransfertMoney(_stirblockCantonmentWalletId, debitedWalletId, debitedFunds.Amount, fees.Amount);

            var payOutResult = await _mangoPayApi.PayOuts.CreateBankWire(payOut);

            return(payOutResult);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
0
 /// <summary>Creates new PayOut object.</summary>
 /// <param name="idempotencyKey">Idempotency key for this request.</param>
 /// <param name="payOut">The PayOut object to be created.</param>
 /// <returns>Created PayOut object returned from API.</returns>
 public PayOutBankWireDTO CreateBankWire(String idempotencyKey, PayOutBankWirePostDTO payOut)
 {
     return(this.CreateObject <PayOutBankWireDTO, PayOutBankWirePostDTO>(idempotencyKey, MethodKey.PayoutsBankwireCreate, payOut));
 }
コード例 #7
0
 /// <summary>Creates new PayOut object.</summary>
 /// <param name="payOut">The PayOut object to be created.</param>
 /// <returns>Created PayOut object returned from API.</returns>
 public PayOutBankWireDTO CreateBankWire(PayOutBankWirePostDTO payOut)
 {
     return(CreateBankWire(null, payOut));
 }
コード例 #8
0
 /// <summary>Creates new PayOut object.</summary>
 /// <param name="payOut">The PayOut object to be created.</param>
 /// <returns>Created PayOut object returned from API.</returns>
 public async Task <PayOutBankWireDTO> CreateBankWire(PayOutBankWirePostDTO payOut)
 {
     return(await CreateBankWire(null, payOut));
 }
コード例 #9
0
        public async Task <PayOutBankWireDTO> CreateBankWire(string idempotencyKey, PayOutBankWirePostDTO payOut)
        {
            var targetUrl = $"{_baseUrl}/payouts/bankwire";

            return(await CreateEntity <PayOutBankWireDTO, PayOutBankWirePostDTO>(targetUrl, payOut, idempotencyKey));
        }
コード例 #10
0
 /// <summary>Creates new PayOut object.</summary>
 /// <param name="idempotencyKey">Idempotency key for this request.</param>
 /// <param name="payOut">The PayOut object to be created.</param>
 /// <returns>Created PayOut object returned from API.</returns>
 public async Task <PayOutBankWireDTO> CreateBankWireAsync(String idempotencyKey, PayOutBankWirePostDTO payOut)
 {
     return(await this.CreateObjectAsync <PayOutBankWireDTO, PayOutBankWirePostDTO>(idempotencyKey, MethodKey.PayoutsBankwireCreate, payOut));
 }
コード例 #11
0
 /// <summary>Creates new PayOut object.</summary>
 /// <param name="payOut">The PayOut object to be created.</param>
 /// <returns>Created PayOut object returned from API.</returns>
 public PayOutBankWireDTO CreateBankWire(PayOutBankWirePostDTO payOut)
 {
     return(this.CreateObject <PayOutBankWireDTO, PayOutBankWirePostDTO>(MethodKey.PayoutsBankwireCreate, payOut));
 }