def create_bill(self, amount, pre_auth_id, name=None, description=None): """Creates a new bill under an existing pre_authorization :param amount: The amount to bill :param pre_auth_id: The id of an existing pre_authorization which has not expire :param name: A name for this bill :param description: A description for this bill """ return Bill.create_under_preauth(amount, pre_auth_id, self, name=name, description=description)
def create_bill(self, amount, pre_auth_id, name=None, description=None, charge_customer_at=None): """Creates a new bill under an existing pre_authorization :param amount: The amount to bill :param pre_auth_id: The id of an existing pre_authorization which has not expire :param name: A name for this bill :param description: A description for this bill :param charge_customer_at: When a payment will leave the customer's account """ return Bill.create_under_preauth(amount, pre_auth_id, self, name=name, description=description, charge_customer_at=charge_customer_at)
def test_create_bill_calls_client_api_post(self): client = mock.Mock() client.api_post.return_value = fixtures.bill_json result = Bill.create_under_preauth(10, "1234", client, name="aname", description="adesc") self.assertIsInstance(result, Bill) expected_params = { "bill":{ "amount":10, "pre_authorization_id":"1234", "name":"aname", "description":"adesc" } } client.api_post.assert_called_with("/bills", expected_params)
def test_create_bill_calls_client_api_post(self): client = mock.Mock() client.api_post.return_value = fixtures.bill_json result = Bill.create_under_preauth(10, "1234", client, name="aname", description="adesc", charge_customer_at="2013-08-27") self.assertIsInstance(result, Bill) expected_params = { "bill": { "amount": 10, "pre_authorization_id": "1234", "name": "aname", "description": "adesc", "charge_customer_at": "2013-08-27" } } client.api_post.assert_called_with("/bills", expected_params)
def create_bill(self, amount, pre_auth_id, name=None, description=None, currency=None): """Creates a new bill under an existing pre_authorization :param amount: The amount to bill :param pre_auth_id: The id of an existing pre_authorization which has not expire :param name: A name for this bill :param description: A description for this bill """ return Bill.create_under_preauth(amount, pre_auth_id, self, name=name, description=description, currency=currency)
def bill(self, id): """ Find a bill with id `id` """ return Bill.find_with_client(id, self)
def test_retry_post(self): client = mock.Mock() bill = Bill(fixtures.bill_json, client) bill.retry() retry_url = "/bills/{0}/retry".format(fixtures.bill_json["id"]) client.api_post.assert_called_with(retry_url)
def test_cancel_put(self): client = mock.Mock() bill = Bill(fixtures.bill_json, client) bill.cancel() cancel_url = "/bills/{0}/cancel".format(fixtures.bill_json["id"]) client.api_put.assert_called_with(cancel_url)
def test_refund_post(self): client = mock.Mock() bill = Bill(fixtures.bill_json, client) bill.refund() refund_url = "/bills/{0}/refund".format(fixtures.bill_json["id"]) client.api_post.assert_called_with(refund_url)