Ejemplo n.º 1
0
 def api_pay(self, aw):
     action = TransactionAction.complete if self._isPayed == '1' else TransactionAction.cancel
     register_transaction(registrant=self._registrant,
                          amount=self._registrant.getTotal(),
                          currency=self._registrant.getCurrency(),
                          action=action)
     return {
         "paid": self._registrant.getPayed(),
         "amount_paid": self._registrant.getTotal()
     }
Ejemplo n.º 2
0
 def _process(self):
     action = TransactionAction.complete if self._isPayed == '1' else TransactionAction.cancel
     register_transaction(registrant=self._registrant,
                          amount=self._registrant.getTotal(),
                          currency=self._registrant.getCurrency(),
                          action=action,
                          provider='_manual',
                          data={'changed_by_name': session.user.full_name,
                                'changed_by_id': session.user.id})
     self._redirect(urlHandlers.UHRegistrantModification.getURL(self._registrant))
Ejemplo n.º 3
0
 def api_pay(self, aw):
     action = TransactionAction.complete if self._isPayed == '1' else TransactionAction.cancel
     register_transaction(registrant=self._registrant,
                          amount=self._registrant.getTotal(),
                          currency=self._registrant.getCurrency(),
                          action=action)
     return {
         "paid": self._registrant.getPayed(),
         "amount_paid": self._registrant.getTotal()
     }
Ejemplo n.º 4
0
 def _process(self):
     action = TransactionAction.complete if self._isPayed == '1' else TransactionAction.cancel
     register_transaction(registrant=self._registrant,
                          amount=self._registrant.getTotal(),
                          currency=self._registrant.getCurrency(),
                          action=action,
                          provider='_manual',
                          data={
                              'changed_by_name':
                              session.avatar.getFullName(),
                              'changed_by_id': session.avatar.getId()
                          })
     self._redirect(
         urlHandlers.UHRegistrantModification.getURL(self._registrant))
Ejemplo n.º 5
0
 def _process(self):
     pay = request.form.get("pay") == "1"
     if pay != self.registration.is_paid:
         event = self.registration.registration_form.event
         currency = payment_event_settings.get(event, "currency") if pay else self.registration.transaction.currency
         amount = self.registration.price if pay else self.registration.transaction.amount
         action = TransactionAction.complete if pay else TransactionAction.cancel
         register_transaction(
             registration=self.registration,
             amount=amount,
             currency=currency,
             action=action,
             data={"changed_by_name": session.user.full_name, "changed_by_id": session.user.id},
         )
     return jsonify_data(html=_render_registration_details(self.registration))
Ejemplo n.º 6
0
def test_register_transaction(mocker, new, double, status):
    mocker.patch('indico.modules.payment.util.db')
    mocker.patch('indico.modules.payment.util.notify_registration_state_update')
    ndp = mocker.patch('indico.modules.payment.util.notify_double_payment')
    cn = mocker.patch.object(PaymentTransaction, 'create_next')
    registration = MagicMock()
    db_transaction = MagicMock(status=status) if new else None
    cn.return_value = db_transaction, double
    transaction = register_transaction(registration, None, None, None)
    if new:
        assert transaction is db_transaction
        assert ndp.called == double
    else:
        assert transaction is None
        assert not ndp.called
Ejemplo n.º 7
0
def test_register_transaction(mocker, new, double, status):
    mocker.patch('indico.modules.payment.util.db')
    ndp = mocker.patch('indico.modules.payment.util.notify_double_payment')
    npc = mocker.patch('indico.modules.payment.util.notify_payment_confirmation')
    cn = mocker.patch.object(PaymentTransaction, 'create_next')
    db_transaction = MagicMock(status=status) if new else None
    cn.return_value = db_transaction, double
    transaction = register_transaction(None, None, None, None)
    if new:
        assert transaction is db_transaction
        assert ndp.called == double
        assert npc.called == (transaction.status == TransactionStatus.successful)
    else:
        assert transaction is None
        assert not ndp.called
        assert not npc.called
Ejemplo n.º 8
0
def test_register_transaction(mocker, new, double, status):
    mocker.patch('indico.modules.payment.util.db')
    ndp = mocker.patch('indico.modules.payment.util.notify_double_payment')
    npc = mocker.patch('indico.modules.payment.util.notify_payment_confirmation')
    cn = mocker.patch.object(PaymentTransaction, 'create_next')
    db_transaction = MagicMock(status=status) if new else None
    cn.return_value = db_transaction, double
    transaction = register_transaction(None, None, None, None)
    if new:
        assert transaction is db_transaction
        assert ndp.called == double
        assert npc.called == (transaction.status == TransactionStatus.successful)
    else:
        assert transaction is None
        assert not ndp.called
        assert not npc.called