Storeware Docs
REST

App billing

What a shop pays your app: plans, one time charges and use.

Get your app’s billing on this shop

GET /api/v1/app-billing

The plan in force, this period’s usage, a cheaper plan waiting to start, the charges waiting for the merchant, the one-time charges approved among your last 50, and the plans your installed release declares, priced in the shop’s currency.

Answers only your app’s own token for the shop, and needs no permission.

Answers 200

FieldTypeDescription
dataobject
data.currencystringThe shop’s billing currency. Every amount here is in its minor unit: cents, pence, paise. One of usd, gbp, eur, inr.
data.subscriptionAppSubscription or null
data.usageAppUsage or nullOnly on a plan that charges by use.
data.scheduledAppSubscription or nullA cheaper plan the merchant approved, to start when this period ends.
data.pendingobject
data.pending.subscriptionsarray of AppSubscription
data.pending.purchasesarray of AppPurchase
data.purchasesarray of AppPurchaseOne-time charges approved, newest first.
data.plansarray of object
data.plans[].keystring
data.plans[].namestring
data.plans[].descriptionstring or null
data.plans[].intervalstringOne of month, year.
data.plans[].amountMinorintegerEach period’s price in the shop’s currency.
data.plans[].currencystringThe shop’s billing currency. Every amount here is in its minor unit: cents, pence, paise. One of usd, gbp, eur, inr.
data.plans[].trialDaysinteger
data.plans[].featuresarray of string
data.plans[].releaseIdstring (uuid) or nullThe release that declares it.
data.plans[].usageCapMinorinteger or null
data.plans[].usageTermsstring or null
curl "https://api.storeware.ai/api/v1/app-billing" \
  -H "Authorization: Bearer $TOKEN"

Ask the merchant to approve a plan

POST /api/v1/app-billing/subscriptions

Asks for one of the plans your installed release declares. Send the merchant to confirmationUrl: nothing is charged until they approve, and they have 48 hours to. returnUrl must be https on your app’s own address (its app.url, webhook URL or a redirect URI). Asking for the plan already in force answers with it and changes nothing. At most 5 charges may wait for an answer at once. Send the same idempotencyKey again and you are answered with the first result, so a retry never charges twice.

Answers only your app’s own token for the shop, and needs no permission.

Body

FieldTypeRequiredDescription
planstringYes1 to 32 characters.
returnUrlstring (uri)YesUp to 2,000 characters.
testbooleanNo
idempotencyKeystringNo1 to 200 characters.

Answers 201

FieldTypeDescription
dataAppSubscription
curl -X POST "https://api.storeware.ai/api/v1/app-billing/subscriptions" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d @body.json

End your plan on this shop

POST /api/v1/app-billing/subscriptions/{subscriptionId}/cancel

Ends the plan when the period the merchant has paid for ends. Until then it stays in force.

Answers only your app’s own token for the shop, and needs no permission.

Parameters

ParameterInTypeDescription
subscriptionIdpathstringThe subscription.

Answers 200

FieldTypeDescription
dataAppSubscription
curl -X POST "https://api.storeware.ai/api/v1/app-billing/subscriptions/$SUBSCRIPTION_ID/cancel" \
  -H "Authorization: Bearer $TOKEN"

Ask the merchant to approve a one-time charge

POST /api/v1/app-billing/purchases

Give a price in every currency: the shop is charged in its own, and nothing is converted. Send the merchant to confirmationUrl; nothing is charged until they approve, and they have 48 hours to. returnUrl follows the same rule as for a plan. Send the same idempotencyKey again and you are answered with the first result, so a retry never charges twice.

Answers only your app’s own token for the shop, and needs no permission.

Body

FieldTypeRequiredDescription
namestringYes1 to 120 characters.
pricesobjectYes
prices.usdintegerYesFrom 1 to 10,000,000.
prices.gbpintegerYesFrom 1 to 10,000,000.
prices.eurintegerYesFrom 1 to 10,000,000.
prices.inrintegerYesFrom 1 to 10,000,000.
returnUrlstring (uri)YesUp to 2,000 characters.
testbooleanNo
idempotencyKeystringNo1 to 200 characters.

Answers 201

FieldTypeDescription
dataAppPurchase
curl -X POST "https://api.storeware.ai/api/v1/app-billing/purchases" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d @body.json

Report what the shop used

POST /api/v1/app-billing/usage

Adds to this period’s usage, in the plan’s currency, on a plan that charges by use. It is billed when the period ends. Past the period’s cap it is refused with 402 app_usage_cap_reached, and on a plan with no usage with 409. Send the same idempotencyKey again and you are answered with the first result, so a retry never charges twice.

Answers only your app’s own token for the shop, and needs no permission.

Body

FieldTypeRequiredDescription
amountMinorintegerYesFrom 1 to 10,000,000.
descriptionstringYes1 to 200 characters.
idempotencyKeystringNo1 to 200 characters.

Answers 201

FieldTypeDescription
dataobject
data.idstring (uuid)
data.amountMinorinteger
data.currencystring
data.descriptionstring
data.createdAtstring (date-time)
data.usageAppUsageThe period’s usage after this record.
curl -X POST "https://api.storeware.ai/api/v1/app-billing/usage" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d @body.json

Credit the shop

POST /api/v1/app-billing/credits

Takes an amount off the shop’s next statement, in its billing currency. A credit can come to no more than the shop paid your app in the last year, less what it has already been credited; past that it is refused with 409. Send the same idempotencyKey again and you are answered with the first result, so a retry never charges twice.

Answers only your app’s own token for the shop, and needs no permission.

Body

FieldTypeRequiredDescription
amountMinorintegerYesFrom 1 to 10,000,000.
descriptionstringYes1 to 200 characters.
idempotencyKeystringNo1 to 200 characters.

Answers 201

FieldTypeDescription
dataobject
data.idstring (uuid)
data.amountMinorinteger
data.currencystring
data.descriptionstring
data.testbooleanTrue when no money moves.
data.createdAtstring (date-time)
curl -X POST "https://api.storeware.ai/api/v1/app-billing/credits" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d @body.json

On this page