def transfer(db, tipper, tippee, amount, context, **kw): t_id = db.one( """ INSERT INTO transfers (tipper, tippee, amount, context, team, status) VALUES (%s, %s, %s, %s, %s, 'pre') RETURNING id """, (tipper, tippee, amount, context, kw.get('team'))) get = lambda id, col: db.one( "SELECT {0} FROM participants WHERE id = %s".format(col), (id, )) tr = Transfer() tr.AuthorId = kw.get('tipper_mango_id') or get(tipper, 'mangopay_user_id') tr.CreditedUserId = kw.get('tippee_mango_id') or get( tippee, 'mangopay_user_id') tr.CreditedWalletID = kw.get('tippee_wallet_id') or get( tippee, 'mangopay_wallet_id') if not tr.CreditedWalletID: tr.CreditedWalletID = create_wallet(db, Participant.from_id(tippee)) tr.DebitedFunds = Money(int(amount * 100), 'EUR') tr.DebitedWalletID = kw.get('tipper_wallet_id') or get( tipper, 'mangopay_wallet_id') tr.Fees = Money(0, 'EUR') tr.Tag = str(t_id) tr = mangoapi.transfers.Create(tr) return record_transfer_result(db, t_id, tr)
def test_Disputes_CreateSettlementTransfer(self): self.refreshClientDisputes() dispute = None for d in self._clientDisputes: if (d.Status == DisputeStatus.CLOSED and d.DisputeType == DisputeType.NOT_CONTESTABLE): dispute = d break self.assertIsNotNone( dispute, 'Cannot test creating settlement transfer because there\'s no closed dispute in the disputes list.' ) repudiationId = self.sdk.disputes.GetTransactions(dispute.Id)[0].Id repudiation = self.sdk.disputes.GetRepudiation(repudiationId) debitedFunds = Money() fees = Money() debitedFunds.Currency = 'EUR' debitedFunds.Amount = 1 fees.Currency = 'EUR' fees.Amount = 0 post = Transfer() post.AuthorId = repudiation.AuthorId post.DebitedFunds = debitedFunds post.Fees = fees result = self.sdk.disputes.CreateSettlementTransfer( post, repudiationId) self.assertIsNotNone(result)
def test_Disputes_CreateSettlementTransfer(self): self.refreshClientDisputes() dispute = None for d in self._clientDisputes: if (d.Status == DisputeStatus.CLOSED and d.DisputeType == DisputeType.NOT_CONTESTABLE): dispute = d break self.assertIsNotNone(dispute, 'Cannot test creating settlement transfer because there\'s no closed dispute in the disputes list.') repudiationId = self.sdk.disputes.GetTransactions(dispute.Id)[0].Id repudiation = self.sdk.disputes.GetRepudiation(repudiationId) debitedFunds = Money() fees = Money() debitedFunds.Currency = 'EUR' debitedFunds.Amount = 1 fees.Currency = 'EUR' fees.Amount = 0 post = Transfer() post.AuthorId = repudiation.AuthorId post.DebitedFunds = debitedFunds post.Fees = fees result = self.sdk.disputes.CreateSettlementTransfer(post, repudiationId) self.assertIsNotNone(result)
def getJohnsTransfer(self, walletWithMoney=None, wallet=None): """Creates Pay-Out Bank Wire object""" if walletWithMoney == None: walletWithMoney = self.getJohnsWalletWithMoney() if wallet == None: wallet = Wallet() wallet.Owners = [walletWithMoney.Owners[0]] wallet.Currency = 'EUR' wallet.Description = 'WALLET IN EUR' wallet = self.sdk.wallets.Create(wallet) transfer = Transfer() transfer.Tag = 'DefaultTag' transfer.AuthorId = walletWithMoney.Owners[0] transfer.CreditedUserId = walletWithMoney.Owners[0] transfer.DebitedFunds = Money() transfer.DebitedFunds.Currency = 'EUR' transfer.DebitedFunds.Amount = 100 transfer.Fees = Money() transfer.Fees.Currency = 'EUR' transfer.Fees.Amount = 0 transfer.DebitedWalletId = walletWithMoney.Id transfer.CreditedWalletId = wallet.Id return self.sdk.transfers.Create(transfer)
def getJohnsTransfer(self, walletWithMoney = None, wallet = None): """Creates Pay-Out Bank Wire object""" if walletWithMoney == None: walletWithMoney = self.getJohnsWalletWithMoney() if wallet == None: wallet = Wallet() wallet.Owners = [walletWithMoney.Owners[0]] wallet.Currency = 'EUR' wallet.Description = 'WALLET IN EUR' wallet = self.sdk.wallets.Create(wallet) transfer = Transfer() transfer.Tag = 'DefaultTag' transfer.AuthorId = walletWithMoney.Owners[0] transfer.CreditedUserId = walletWithMoney.Owners[0] transfer.DebitedFunds = Money() transfer.DebitedFunds.Currency = 'EUR' transfer.DebitedFunds.Amount = 100 transfer.Fees = Money() transfer.Fees.Currency = 'EUR' transfer.Fees.Amount = 0 transfer.DebitedWalletId = walletWithMoney.Id transfer.CreditedWalletId = wallet.Id return self.sdk.transfers.Create(transfer)
def create(self, fees=None): transfer = Transfer() transfer.DebitedWalletId = self.mangopay_debited_wallet.mangopay_id transfer.CreditedWalletId = self.mangopay_credited_wallet.mangopay_id transfer.AuthorId =\ self.mangopay_debited_wallet.mangopay_user.mangopay_id transfer.CreditedUserId =\ self.mangopay_credited_wallet.mangopay_user.mangopay_id transfer.DebitedFunds = python_money_to_mangopay_money( self.debited_funds) transfer.Fees = python_money_to_mangopay_money(self.fees) client = get_mangopay_api_client() created_transfer = client.transfers.Create(transfer) self._update(created_transfer)
def transfer(db, tipper, tippee, amount, context, **kw): t_id = db.one(""" INSERT INTO transfers (tipper, tippee, amount, context, team, status) VALUES (%s, %s, %s, %s, %s, 'pre') RETURNING id """, (tipper, tippee, amount, context, kw.get('team'))) get = lambda id, col: db.one("SELECT {0} FROM participants WHERE id = %s".format(col), (id,)) tr = Transfer() tr.AuthorId = kw.get('tipper_mango_id') or get(tipper, 'mangopay_user_id') tr.CreditedUserId = kw.get('tippee_mango_id') or get(tippee, 'mangopay_user_id') tr.CreditedWalletID = kw.get('tippee_wallet_id') or get(tippee, 'mangopay_wallet_id') if not tr.CreditedWalletID: tr.CreditedWalletID = create_wallet(db, Participant.from_id(tippee)) tr.DebitedFunds = Money(int(amount * 100), 'EUR') tr.DebitedWalletID = kw.get('tipper_wallet_id') or get(tipper, 'mangopay_wallet_id') tr.Fees = Money(0, 'EUR') tr.Tag = str(t_id) tr = mangoapi.transfers.Create(tr) return record_transfer_result(db, t_id, tr)
def create(self, fees=None): transfer = Transfer() transfer.DebitedWalletId = self.mangopay_debited_wallet.mangopay_id transfer.CreditedWalletId = self.mangopay_credited_wallet.mangopay_id transfer.AuthorId =\ self.mangopay_debited_wallet.mangopay_user.mangopay_id transfer.CreditedUserId =\ self.mangopay_credited_wallet.mangopay_user.mangopay_id transfer.DebitedFunds = python_money_to_mangopay_money( self.debited_funds) if not fees: fees = PythonMoney(0, self.debited_funds.currency) transfer.Fees = python_money_to_mangopay_money(fees) client = get_mangopay_api_client() created_transfer = client.transfers.Create(transfer) self._update(created_transfer)
def Get(self, transfer_id): transfer = Transfer() transfer.Id = transfer_id transfer.ExecutionDate = 12312312 transfer.Status = "SUCCEEDED" return transfer