@@ -149,20 +149,31 @@ async def create_invoice_and_charge_immediately(
149149 description : Optional [str ] = None ,
150150 org_id_for_branding : Optional [str ] = None ,
151151 disable_email : bool = False ,
152- ) -> None :
152+ ) -> CreateInvoiceAndChargeImmediatelyResponse :
153153 """Create a flat fee invoice and charge the organization on the spot. The caller must be an owner of the organization being charged.
154- This function blocks until payment is confirmed, but will time out after 2 minutes if there is no confirmation.
154+ This function returns the invoice id once the payment intent is successfully sent for processing. Callers may poll the invoice for
155+ its status using the `get_invoices_summary` function and the returned invoice id. The status will be "payment_processing" if the
156+ payment is being processed, "paid" if it succeeds, or "outstanding" if it fails.
155157
156158 ::
157159
158- await billing_client.create_invoice_and_charge_immediately("<ORG-ID-TO-CHARGE>", <AMOUNT>, <DESCRIPTION>, "<ORG-ID-FOR-BRANDING>", False)
160+ invoice_id = await billing_client.create_invoice_and_charge_immediately(
161+ "<ORG-ID-TO-CHARGE>",
162+ <AMOUNT>,
163+ <DESCRIPTION>,
164+ "<ORG-ID-FOR-BRANDING>",
165+ False,
166+ )
159167
160168 Args:
161169 org_id_to_charge (str): the organization to charge
162170 amount (float): the amount to charge in dollars
163171 description (str): a short description of the charge to display on the invoice PDF (must be 100 characters or less)
164172 org_id_for_branding (str): the organization whose branding to use in the invoice confirmation email
165173 disable_email (bool): whether or not to disable sending an email confirmation for the invoice
174+
175+ Returns:
176+ viam.proto.app.billing.CreateInvoiceAndChargeImmediatelyResponse: the invoice id
166177 """
167178 request = CreateInvoiceAndChargeImmediatelyRequest (
168179 org_id_to_charge = org_id_to_charge ,
@@ -171,6 +182,4 @@ async def create_invoice_and_charge_immediately(
171182 org_id_for_branding = org_id_for_branding ,
172183 disable_email = disable_email ,
173184 )
174- _ : CreateInvoiceAndChargeImmediatelyResponse = await self ._billing_client .CreateInvoiceAndChargeImmediately (
175- request , metadata = self ._metadata
176- )
185+ return await self ._billing_client .CreateInvoiceAndChargeImmediately (request , metadata = self ._metadata )
0 commit comments