Exemplo n.º 1
0
def customer_delete(request):
    """Delete and return customer

    """
    company = auth_api_key(request)
    model = CustomerModel(request.session)
    customer = get_and_check_customer(request, company)
    if customer.deleted:
        return HTTPBadRequest('Customer {} was already deleted'
                              .format(customer.guid))
    with db_transaction.manager:
        model.delete(customer.guid)
    customer = model.get(customer.guid)
    return customer
Exemplo n.º 2
0
    def test_create_subscription_to_a_deleted_customer(self):
        from billy.models.customer import CustomerModel

        customer_model = CustomerModel(self.testapp.session)

        with db_transaction.manager:
            customer_guid = customer_model.create(company_guid=self.company_guid)
            customer_model.delete(customer_guid)

        self.testapp.post(
            "/v1/subscriptions",
            dict(customer_guid=customer_guid, plan_guid=self.plan_guid, amount="123", payment_uri="MOCK_CARD_URI"),
            extra_environ=dict(REMOTE_USER=self.api_key),
            status=400,
        )