Exemplo n.º 1
0
 def test_active_participant_can_browse(self, get_payin):
     get_payin.return_value = DirectPayIn()
     self.browse_setup()
     bob = self.make_participant('bob', balance=EUR(50))
     bob.set_tip_to(self.david, EUR('1.00'))
     self.david.set_tip_to(bob, EUR('0.50'))
     self.browse(auth_as=self.david)
Exemplo n.º 2
0
 def get_pay_in(self):
     author = self.mangopay_user.get_user()
     credited_wallet = self.mangopay_wallet.get_wallet()
     card = ''  # TODO: Add Card
     return DirectPayIn(author=author,
                        debited_funds=python_money_to_mangopay_money(
                            self.debited_funds),
                        fees=python_money_to_mangopay_money(self.fees),
                        credited_wallet=credited_wallet,
                        secure_mode_return_url=self.secure_mode_return_url,
                        secure_mode=SECURE_MODE_CHOICES.default,
                        payment_type=PAYIN_PAYMENT_TYPE.card)
Exemplo n.º 3
0
def charge(db, route, amount, return_url):
    """Charge the given credit card (`route`).

    Amount should be the nominal amount. We'll compute fees below this function
    and add it to amount to end up with charge_amount.

    """
    assert isinstance(amount, (Decimal, Money)), type(amount)
    assert route
    assert route.network == 'mango-cc'

    participant = route.participant

    amount = Money(amount, 'EUR') if isinstance(amount, Decimal) else amount
    charge_amount, fee, vat = upcharge_card(amount)
    amount = charge_amount - fee

    wallet = participant.get_current_wallet(amount.currency, create=True)
    e_id = record_exchange(db, route, amount, fee, vat, participant, 'pre').id
    payin = DirectPayIn()
    payin.AuthorId = participant.mangopay_user_id
    payin.CreditedWalletId = wallet.remote_id
    payin.DebitedFunds = charge_amount.int()
    payin.CardId = route.address
    payin.SecureModeReturnURL = return_url
    payin.Fees = fee.int()
    payin.Tag = str(e_id)
    try:
        test_hook()
        payin.save()
    except Exception as e:
        error = repr_exception(e)
        return record_exchange_result(db, e_id, '', 'failed', error, participant)

    if payin.SecureModeRedirectURL:
        raise Redirect(payin.SecureModeRedirectURL)

    return record_exchange_result(
        db, e_id, payin.Id, payin.Status.lower(), repr_error(payin), participant
    )
Exemplo n.º 4
0
 def Get(self, pay_in_id):
     pay_in = DirectPayIn()
     pay_in.Id = pay_in_id
     pay_in.ExecutionDate = 12312312
     pay_in.ExecutionDetails = PayInExecutionDetailsDirect()
     pay_in.ExecutionDetails.SecureModeRedirectURL = "https://test.com"
     pay_in.Status = "SUCCEEDED"
     return pay_in
Exemplo n.º 5
0
def charge(db, route, amount, return_url):
    """Charge the given credit card (`route`).

    Amount should be the nominal amount. We'll compute fees below this function
    and add it to amount to end up with charge_amount.

    """
    assert isinstance(amount, (Decimal, Money)), type(amount)
    assert route
    assert route.network == 'mango-cc'

    participant = route.participant

    amount = Money(amount, 'EUR') if isinstance(amount, Decimal) else amount
    charge_amount, fee, vat = upcharge_card(amount)
    amount = charge_amount - fee

    wallet = participant.get_current_wallet(amount.currency, create=True)
    e_id = record_exchange(db, route, amount, fee, vat, participant, 'pre').id
    payin = DirectPayIn()
    payin.AuthorId = participant.mangopay_user_id
    payin.CreditedWalletId = wallet.remote_id
    payin.DebitedFunds = charge_amount.int()
    payin.CardId = route.address
    payin.SecureModeReturnURL = return_url
    payin.Fees = fee.int()
    payin.Tag = str(e_id)
    try:
        test_hook()
        payin.save()
    except Exception as e:
        error = repr_exception(e)
        return record_exchange_result(db, e_id, '', 'failed', error, participant)

    if payin.SecureModeRedirectURL:
        raise Redirect(payin.SecureModeRedirectURL)

    return record_exchange_result(
        db, e_id, payin.Id, payin.Status.lower(), repr_error(payin), participant
    )
Exemplo n.º 6
0
 def test_admin_can_browse(self, get_payin):
     get_payin.return_value = DirectPayIn()
     self.browse_setup()
     admin = self.make_participant('admin', privileges=1)
     self.browse(auth_as=admin)
Exemplo n.º 7
0
def charge(db, participant, amount, return_url):
    """Charge the participant's credit card.

    Amount should be the nominal amount. We'll compute fees below this function
    and add it to amount to end up with charge_amount.

    """
    typecheck(amount, Decimal)

    route = ExchangeRoute.from_network(participant, 'mango-cc')
    assert route

    charge_amount, fee, vat = upcharge_card(amount)
    amount = charge_amount - fee

    e_id = record_exchange(db, route, amount, fee, vat, participant, 'pre')
    payin = DirectPayIn()
    payin.AuthorId = participant.mangopay_user_id
    if not participant.mangopay_wallet_id:
        create_wallet(db, participant)
    payin.CreditedWalletId = participant.mangopay_wallet_id
    payin.DebitedFunds = Money(int(charge_amount * 100), 'EUR')
    payin.CardId = route.address
    payin.SecureModeReturnURL = return_url
    payin.Fees = Money(int(fee * 100), 'EUR')
    payin.Tag = str(e_id)
    try:
        test_hook()
        payin.save()
    except Exception as e:
        error = repr_exception(e)
        return record_exchange_result(db, e_id, 'failed', error, participant)

    if payin.SecureModeRedirectURL:
        raise Redirect(payin.SecureModeRedirectURL)

    return record_exchange_result(db, e_id, payin.Status.lower(), repr_error(payin), participant)