예제 #1
0
def sdd():
    return SepaDD({
        "name": "TestCreditor",
        "IBAN": "NL50BANK1234567890",
        "BIC": "BANKNL2A",
        "batch": True,
        "creditor_id": "DE26ZZZ00000000000",
        "currency": "EUR"
    }, schema="pain.008.003.02")
예제 #2
0
def sdd():
    return SepaDD({
        "name": "TestCreditor",
        "IBAN": "NL50BANK1234567890",
        "BIC": "BANKNL2A",
        "batch": True,
        "creditor_id": "000000",
        "currency": "EUR"
    })
예제 #3
0
def test_invalid_config():
    with pytest.raises(Exception):
        return SepaDD({
            "name": "TestCreditor",
            "BIC": "BANKNL2A",
            "batch": True,
            "creditor_id": "000000",
            "currency": "EUR"
        })
예제 #4
0
    def post(self, request, *args, **kwargs):
        config = {
            "name": request.event.settings.payment_sepadebit_creditor_name,
            "IBAN": request.event.settings.payment_sepadebit_creditor_iban,
            "BIC": request.event.settings.payment_sepadebit_creditor_bic,
            "batch": True,
            "creditor_id":
            request.event.settings.payment_sepadebit_creditor_id,
            "currency": request.event.currency
        }
        sepa = SepaDD(config, schema='pain.008.003.02')

        valid_payments = []
        for payment in self.get_unexported():
            if not payment.info_data:
                # Should not happen
                # TODO: Notify user
                payment.state = OrderPayment.PAYMENT_STATE_FAILED
                payment.save()
                payment.order.status = Order.STATUS_PENDING
                payment.order.save()
                continue

            payment_dict = {
                "name":
                payment.info_data['account'],
                "IBAN":
                payment.info_data['iban'],
                "BIC":
                payment.info_data['bic'],
                "amount":
                int(payment.amount * 100),
                "type":
                "OOFF",
                "collection_date":
                max(now().date(),
                    dateutil.parser.parse(payment.info_data['date']).date()),
                "mandate_id":
                payment.info_data['reference'],
                "mandate_date": (payment.order.datetime if payment.migrated
                                 else payment.created).date(),
                "description":
                _('Event ticket {event}-{code}').format(
                    event=request.event.slug.upper(), code=payment.order.code)
            }
            sepa.add_payment(payment_dict)
            valid_payments.append(payment)

        if valid_payments:
            with transaction.atomic():
                exp = SepaExport(event=request.event, xmldata='')
                exp.xmldata = sepa.export().decode('utf-8')
                exp.save()
                SepaExportOrder.objects.bulk_create([
                    SepaExportOrder(order=p.order,
                                    payment=p,
                                    export=exp,
                                    amount=p.amount) for p in valid_payments
                ])
            messages.success(request, _('A new export file has been created.'))
        else:
            messages.warning(request, _('No valid orders have been found.'))
        return redirect(
            reverse('plugins:pretix_sepadebit:export',
                    kwargs={
                        'event': request.event.slug,
                        'organizer': request.event.organizer.slug,
                    }))