Purchase credits
Starts a purchase of credits, paid with a card in Stripe Checkout. The caller's browser goes to the purchase's checkoutUri to pay, and comes back to returnUri. Its credits are granted once Stripe says it is paid. A suspended billing account buys none, which fails with failed_precondition and the reason ACCOUNT_SUSPENDED.
Starts a purchase of credits, paid with a card in Stripe Checkout.
The caller's browser goes to the purchase's checkoutUri to pay, and comes back to returnUri. Its credits are granted once Stripe says it is paid. A suspended billing account buys none, which fails with failed_precondition and the reason ACCOUNT_SUSPENDED.
bearerAuthorizationBearer <token>An access token, or an API key.
organization*stringThe organization's ID.
^org_[0-7][0-9a-hjkmnp-tv-z]{25}$application/json- body
amount*The credits to buy, in US dollars and whole cents, from $10 to $200; Stripe adds any tax.
autoReload?booleanWhether to save the card for auto-reload, and turn it on once paid.
returnUri*stringWhere Stripe sends the browser back, paid or not: a page of the console. Once paid, it has the query parameter purchase added, the purchase's ID.
uriCreated
application/json- response
amount*The credits it buys, before any tax; once paid, what Stripe charged.
checkoutUri*stringStripe's page to pay at, while it is open.
createTime*stringWhen it was started.
date-timecreditGrant*stringThe credits it bought, organizations/{organization_id}/creditGrants/{credit_grant_id}, once paid.
expireTime?stringWhen the checkout stops taking a payment, while it is open.
date-timefailure*stringWhy the card's bank declined it, once failed.
invoiceUri*stringThe invoice that Stripe hosts for it, once paid and Stripe has finalized it.
kind*stringHow it is paid for: CHECKOUT, in Stripe Checkout, by whoever started it; AUTO_RELOAD, by auto-reload, with the saved card.
"CHECKOUT""AUTO_RELOAD"name*stringResource name, organizations/{organization_id}/purchases/{purchase_id}.
receiptUri*stringStripe's receipt for an auto-reload, once paid.
state*stringWhere it stands: OPEN, waiting to be paid at checkoutUri; PAID, and its credits granted; EXPIRED, the checkout ended without a payment; FAILED, the card's bank declined an auto-reload; DISPUTED, paid, then disputed, and what was left of its credits taken back.
"OPEN""PAID""EXPIRED""FAILED""DISPUTED"updateTime*stringWhen it last changed, such as when it was paid.
date-timecurl -X POST 'https://api.kosem.ai/v1/organizations/string/billingAccount/purchase-credits' \
-H 'Content-Type: application/json' \
-d '{
"amount": {
"currencyCode": "string",
"nanos": -999999999,
"units": 0
},
"returnUri": "http://example.com"
}'{
"amount": {
"currencyCode": "string",
"nanos": -999999999,
"units": 0
},
"checkoutUri": "string",
"createTime": "2019-08-24T14:15:22Z",
"creditGrant": "string",
"expireTime": "2019-08-24T14:15:22Z",
"failure": "string",
"invoiceUri": "string",
"kind": "CHECKOUT",
"name": "string",
"receiptUri": "string",
"state": "OPEN",
"updateTime": "2019-08-24T14:15:22Z"
}