|
13 | 13 | GetInvoicesSummaryResponse, |
14 | 14 | GetOrgBillingInformationRequest, |
15 | 15 | GetOrgBillingInformationResponse, |
| 16 | + CreateInvoiceAndChargeImmediatelyRequest, |
| 17 | + CreateInvoiceAndChargeImmediatelyResponse, |
16 | 18 | ) |
17 | 19 |
|
18 | 20 | LOGGER = logging.getLogger(__name__) |
@@ -141,3 +143,20 @@ async def get_org_billing_information(self, org_id: str, timeout: Optional[float |
141 | 143 | """ |
142 | 144 | request = GetOrgBillingInformationRequest(org_id=org_id) |
143 | 145 | return await self._billing_client.GetOrgBillingInformation(request, metadata=self._metadata, timeout=timeout) |
| 146 | + |
| 147 | + async def create_invoice_and_charge_immediately(self, org_id_to_charge: str, amount: float, description: Optional[str] = None, org_id_for_branding: Optional[str] = None) -> None: |
| 148 | + """Create a flat fee invoice and charge the organization on the spot. The caller must be an owner of the organization being charged. |
| 149 | + This function blocks until payment is confirmed, but will time out after 2 minutes if there is no confirmation. |
| 150 | +
|
| 151 | + :: |
| 152 | +
|
| 153 | + await billing_client.create_invoice_and_charge_immediately("<ORG-ID-TO-CHARGE>", <AMOUNT>, <DESCRIPTION>, "<ORG-ID-FOR-BRANDING>") |
| 154 | +
|
| 155 | + Args: |
| 156 | + org_id_to_charge (str): the organization to charge |
| 157 | + amount (float): the amount to charge in dollars |
| 158 | + description (str): a short description of the charge to display on the invoice PDF (must be 100 characters or less) |
| 159 | + org_id_for_branding (str): the organization whose branding to use in the invoice confirmation email |
| 160 | + """ |
| 161 | + request = CreateInvoiceAndChargeImmediatelyRequest(org_id_to_charge=org_id_to_charge, amount=amount, description=description, org_id_for_branding=org_id_for_branding) |
| 162 | + _: CreateInvoiceAndChargeImmediatelyResponse = await self._billing_client.CreateInvoiceAndChargeImmediately(request, metadata=self._metadata) |
0 commit comments