예제 #1
0
    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)
예제 #2
0
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)
예제 #3
0
    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)
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
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)