client.billing()
इस नेमस्पेस का हर मेथड: उसका सिग्नेचर, उसके पैरामीटर, वह क्या लौटाता है और एक उदाहरण।
मेथड
The plan of the workspace and what it costs, as Plans & Billing shows them: the plan and its usage, the plans on sale, pay as you go, every charge with its invoice, and the links that start a checkout or open the billing portal. Only the workspace owner reaches it, and nothing is paid through the API.
billing().getbilling().listPlansbilling().getUsagebilling().listAlertsbilling().listCountriesbilling().getPayAsYouGobilling().setPayAsYouGobilling().setPayAsYouGoLimitbilling().confirmPayAsYouGobilling().startCheckoutbilling().openPortalbilling().listInvoicesbilling().getInvoicebilling().saveInvoiceDetailsbilling().listAddOnsbilling().startAddOnCheckoutbilling().cancelAddOn
billing().get
Read the plan
Map<String, Object> get(RequestOptions options)Returns the plan of the workspace and what it includes, as Plans & Billing shows it: how it is billed, when it renews or ends and the next charge, how many domains it holds, how much of this month's sends and today's AI actions are used, and pay as you go. metered is false when billing is off on the install, and then nothing is capped.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with plan, planName, interval, renewsAt, nextCharge, domains, usage and payAsYouGo.
उदाहरण
Map<String, Object> billing = client.billing().get(); System.out.println(billing.get("planName") + " " + billing.get("usage"));टिप्पणियाँ
A limit of
nullmeans the plan has none.
इनमें भी उपलब्ध
- API
GET /billing- TypeScript
billing.get()- Python
billing.get()- Ruby
billing.get- PHP
billing->get- Go
Billing.Get- C#
Billing.GetAsync- CLI
openemail billing get
billing().listPlans
List the plans
Map<String, Object> listPlans(RequestOptions options)Returns every plan, cheapest first, with its price in US cents and what it includes. available says whether it is sold on the install, and intervals the billing intervals it is sold at.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with data, a list with one map per plan.
उदाहरण
Map<String, Object> result = client.billing().listPlans(); System.out.println(result.get("object"));इनमें भी उपलब्ध
billing().getUsage
Read the usage history
Map<String, Object> getUsage(RequestOptions options)Returns the sends and AI actions of each day, and what pay as you go extras cost each month, as the Usage charts show them.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
options.daysint or StringHow many days back to go, from 1 to 3,660, or
all(BillingUsageWindows.ALL) for every day since the workspace was made. The server defaults to 30.options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with days, months, dailyAiActions and monthlySends.
उदाहरण
Map<String, Object> usage = client.billing().getUsage(RequestOptions.of("days", 90)); System.out.println(usage.get("days"));इनमें भी उपलब्ध
billing().listAlerts
List the billing alerts
Map<String, Object> listAlerts(RequestOptions options)Returns what the billing banner of the app would say now, most urgent first: a failed payment, paused pay as you go, sending or AI paused at a limit, a plan about to end, an allowance nearly used and a charge coming soon. An empty list means there is nothing to say.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with data, a list with one map per alert.
उदाहरण
Map<String, Object> result = client.billing().listAlerts(); System.out.println(result.get("object"));टिप्पणियाँ
An alert keeps its
idwhile the same thing is true, so one that was dismissed can stay dismissed.
इनमें भी उपलब्ध
billing().listCountries
List the billing countries
Map<String, Object> listCountries(RequestOptions options)Returns every country a billing address can be in, as the two-letter ISO 3166 codes saveInvoiceDetails takes as country.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with the codes in data, a list of strings.
उदाहरण
Map<String, Object> result = client.billing().listCountries(); System.out.println(result.get("object"));इनमें भी उपलब्ध
billing().getPayAsYouGo
Read pay as you go
Map<String, Object> getPayAsYouGo(RequestOptions options)Returns pay as you go on the workspace: whether usage past the allowances is billed, the monthly limit and what extras cost so far, the current billing period once it is set up, the limits that can be chosen and the prices.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with the state, limits, prices and period.
उदाहरण
Map<String, Object> payg = client.billing().getPayAsYouGo(); System.out.println(payg.get("enabled") + " " + payg.get("spentCents") + " " + payg.get("limitCents"));टिप्पणियाँ
Amounts are in US cents.
इनमें भी उपलब्ध
billing().setPayAsYouGo
Turn pay as you go on or off
Map<String, Object> setPayAsYouGo(Map<String, Object> body, RequestOptions options)Turns pay as you go on or off, as the switch on Plans & Billing does. Off takes effect at once, and usage stops at the allowances. On takes effect at once when a card is already saved. The first time, checkoutUrl is a link where the person adds a card, and pay as you go starts once they have: call confirmPayAsYouGo after they return.
Nothing is paid through the API: the person pays, changes the card or cancels on the billing provider's page the link opens, as they do from the app.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
body.enabledbooleanआवश्यकtrueto turn it on,falseto turn it off.body.themeStringlightordark, for the page the link opens, as inuk.openemail.constants.BillingThemes.body.localeStringA language tag such as
deorpt-PT, for the page the link opens.options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with enabled, suspended, activating and checkoutUrl.
उदाहरण
Map<String, Object> result = client.billing().setPayAsYouGo(Body.of("enabled", true)); System.out.println(result.get("checkoutUrl"));टिप्पणियाँ
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. An API key is never asked.Turning it on where pay as you go is not set up on the install is 503
billing_not_configured.The SDK does not retry it.
इनमें भी उपलब्ध
billing().setPayAsYouGoLimit
Set the pay as you go limit
Map<String, Object> setPayAsYouGoLimit(Map<String, Object> body, RequestOptions options)Sets the monthly spending limit of pay as you go, in US cents, one of the amounts getPayAsYouGo lists in limits. Extras stop for the rest of a calendar month once it is reached.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
body.limitCentsintआवश्यकThe limit in US cents: 1,000, 2,500, 5,000, 10,000, 25,000, 50,000, 100,000, 250,000 or 500,000, the amounts in
PayAsYouGoLimitsCents.ALL.options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with limitCents.
उदाहरण
Map<String, Object> result = client.billing().setPayAsYouGoLimit(Body.of("limitCents", 10000)); System.out.println(result.get("object") + " " + result.get("limitCents"));टिप्पणियाँ
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. An API key is never asked.A workspace where pay as you go was never set up is 409
pay_as_you_go_not_enrolled.The SDK does not retry it.
इनमें भी उपलब्ध
billing().confirmPayAsYouGo
Confirm pay as you go
Map<String, Object> confirmPayAsYouGo(RequestOptions options)Checks with the billing provider whether the card from a pay as you go checkout was saved, and records it, as the app does when the person comes back from the checkout. enabled says whether pay as you go is on now.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with enabled.
उदाहरण
Map<String, Object> result = client.billing().confirmPayAsYouGo(); System.out.println(result.get("object") + " " + result.get("enabled"));टिप्पणियाँ
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. An API key is never asked.It is safe to call again.
The SDK does not retry it.
इनमें भी उपलब्ध
billing().startCheckout
Start a checkout
Map<String, Object> startCheckout(Map<String, Object> body, RequestOptions options)Starts buying a paid plan for a workspace on Free, as choosing a plan in the app does, and returns the link to the checkout. Nothing is charged until the person pays there, and the plan starts once they have. A workspace that already pays for a plan changes it with openPortal instead.
Nothing is paid through the API: the person pays, changes the card or cancels on the billing provider's page the link opens, as they do from the app.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
body.planStringआवश्यकstarter,businessorenterprise, as inuk.openemail.constants.PaidPlanIds.body.intervalStringmonthoryear, as inuk.openemail.constants.BillingIntervals. Defaults tomonth.body.themeStringlightordark, for the page the link opens, as inuk.openemail.constants.BillingThemes.body.localeStringA language tag such as
deorpt-PT, for the page the link opens.options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with url.
उदाहरण
Map<String, Object> result = client.billing().startCheckout(Body.of("plan", "business", "interval", "year")); System.out.println(result.get("url"));टिप्पणियाँ
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. An API key is never asked.A workspace that already pays for a plan is 409
plan_conflict, and a plan or interval not sold on the install is 422plan_unavailable.The SDK does not retry it.
इनमें भी उपलब्ध
billing().openPortal
Open the billing portal
Map<String, Object> openPortal(Map<String, Object> body, RequestOptions options)Returns a link to the billing portal, where the person changes or cancels the plan, updates the card and downloads past invoices, as Manage does in the app.
Nothing is paid through the API: the person pays, changes the card or cancels on the billing provider's page the link opens, as they do from the app.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
body.themeStringlightordark, for the page the link opens, as inuk.openemail.constants.BillingThemes.body.localeStringA language tag such as
deorpt-PT, for the page the link opens.options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with url.
उदाहरण
Map<String, Object> result = client.billing().openPortal(Body.of("theme", "dark")); System.out.println(result.get("url"));टिप्पणियाँ
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. An API key is never asked.The SDK does not retry it.
इनमें भी उपलब्ध
billing().listInvoices
List the charges
Map<String, Object> listInvoices(RequestOptions options)Returns every charge of the workspace with the state of its invoice, a page at a time, as History on Plans & Billing lists them. search matches the plan, the invoice number, the charge id and the name billed.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
options.pageintWhich page, from 1.
options.limitintCharges per page, from 1 to 100. The server defaults to 25.
options.sortStringnewest, the default, oroldest, as inuk.openemail.constants.BillingInvoiceSorts.options.searchStringWords to look for, up to 120 characters.
options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with data, total, page, limit, hasMore and metered.
उदाहरण
Map<String, Object> result = client.billing().listInvoices(RequestOptions.create().limit(10)); System.out.println(result.get("object") + " " + result.get("total"));टिप्पणियाँ
A provider that does not answer is 502
billing_unreachable.
इनमें भी उपलब्ध
billing().getInvoice
Get the invoice of a charge
Map<String, Object> getInvoice(String orderId, RequestOptions options)Returns the link to the invoice of one charge, as a PDF, and its file name. An invoice that was not written yet is written first, which can take a few seconds. The link is signed by the billing provider, downloads the PDF and stops working after a while, so fetch it again rather than keeping it.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
orderIdStringआवश्यकThe charge id, as
listInvoicesreturns it.options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with url and fileName.
उदाहरण
Map<String, Object> invoice = client.billing().getInvoice("3b9f2c4e-7a1d-4e8b-9c0f-5d6a7b8c9d0e"); System.out.println(invoice.get("fileName") + " " + invoice.get("url"));टिप्पणियाँ
A charge with no billing name and address is 409
billing_details_required: save them withsaveInvoiceDetails. A draft or void charge is 409invoice_unavailable, and an invoice still being written is 504invoice_not_ready.
इनमें भी उपलब्ध
billing().saveInvoiceDetails
Save the billing details of a charge
Map<String, Object> saveInvoiceDetails(String orderId, Map<String, Object> body, RequestOptions options)Saves the name and address billed on a charge, as the Billing address dialog does, keeps the address for later charges, and starts writing its invoice. invoice is ready when the charge already had one, started when it is being written, and refused with the reason in message.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
orderIdStringआवश्यकThe charge id, as
listInvoicesreturns it.body.nameStringआवश्यकWho is billed, up to 200 characters.
body.line1Stringआवश्यकThe street address, up to 200 characters.
body.line2StringA flat, suite or building, up to 200 characters.
body.cityStringआवश्यकUp to 120 characters.
body.postalCodeStringUp to 40 characters.
body.stateStringThe state or region, up to 60 characters. In the US and Canada, its two-letter code.
body.countryStringआवश्यकA two-letter ISO 3166 code, one of those
listCountriesreturns.options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with invoice and message.
उदाहरण
Map<String, Object> result = client.billing().saveInvoiceDetails("3b9f2c4e-7a1d-4e8b-9c0f-5d6a7b8c9d0e", Body.of( "name", "Acme Ltd", "line1", "1 Market Street", "city", "London", "postalCode", "EC1A 1AA", "country", "GB")); System.out.println(result.get("invoice"));टिप्पणियाँ
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. An API key is never asked.An address the billing provider refuses is 422
billing_address_rejected.The SDK does not retry it.
इनमें भी उपलब्ध
billing().listAddOns
List add-ons
Map<String, Object> listAddOns(RequestOptions options)Returns what can be bought on top of the plan, today the dedicated sending IP: whether it is for sale, its price per IP a month in priceCents, whether the workspace has it and when it ends, the IPs it brought, and eligibility, which says whether the workspace qualifies. A dedicated IP needs the Business or Enterprise plan and at least 100,000 emails sent in a month, because below that volume it delivers worse than the shared IPs.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with one map per add-on in data: addOn, available, status, priceCents, endsAt, eligibility and ips.
उदाहरण
Map<String, Object> result = client.billing().listAddOns(); System.out.println(result.get("object"));टिप्पणियाँ
statusisnulluntil the workspace has the add-on.pendingis paid and being set up,warmingandactivesend through the dedicated IP, andreleasingis being taken down, the values inuk.openemail.constants.SendingPoolStatuses.A GET is retried automatically on network failure and on 408, 429, 500, 502, 503 and 504 responses, up to the client's
maxRetries.
इनमें भी उपलब्ध
billing().startAddOnCheckout
Start a checkout for an add-on
Map<String, Object> startAddOnCheckout(Map<String, Object> body, RequestOptions options)Starts buying an add-on, as the button under Plans & Billing does, and returns the link to the checkout. Nothing is charged until the person pays there. Once it is paid the dedicated IP is set up and warmed up, which sending().listDedicatedIps shows.
Nothing is paid through the API: the person pays on the billing provider's page the link opens, as they do from the app.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
body.addOnStringआवश्यकThe add-on to buy:
dedicated-ip, as inuk.openemail.constants.AddOns.body.themeStringlightordark, for the page the link opens, as inuk.openemail.constants.BillingThemes.body.localeStringA language tag such as
deorpt-PT, for the page the link opens.options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with addOn and url.
उदाहरण
Map<String, Object> result = client.billing().startAddOnCheckout(Body.of("addOn", "dedicated-ip")); System.out.println(result.get("url"));टिप्पणियाँ
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. An API key is never asked.A workspace that already has the add-on is 409
add_on_already_active, one that does not qualify is 409add_on_not_eligible, and when every IP is taken it is 409add_on_sold_out. An install that does not sell add-ons is 503add_on_unavailable.The SDK does not retry it.
इनमें भी उपलब्ध
billing().cancelAddOn
Cancel an add-on
Map<String, Object> cancelAddOn(String addOn, RequestOptions options)Cancels an add-on. It stays until the end of the month already paid for, which endsAt gives. Then the dedicated IP is released and mail leaves through the shared IPs again.
Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.
पैरामीटर
addOnStringआवश्यकThe add-on to cancel:
dedicated-ip, as inuk.openemail.constants.AddOns.options.apiKeyStringOverrides the client's API key for this call only.
लौटाता है
A map with the add-on, now with endsAt set.
उदाहरण
Map<String, Object> addOn = client.billing().cancelAddOn("dedicated-ip"); System.out.println(addOn.get("endsAt"));टिप्पणियाँ
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. An API key is never asked.A workspace that does not have the add-on, or whose add-on is already ending, is 409
add_on_not_active.The SDK does not retry a delete.