Nostraddeveloper documentationDocumentationDeveloper console

Selling inside your app

Sell things inside your app, such as coins, a level, a feature or a subscription, to people who signed in to it with Nostrad. They pay from their Nostrad credit on a Nostrad page, and Nostrad tells your server. It works like Google Play Billing and Apple's In-App Purchase: the same steps, the same rules, and the same names where it can. All of it goes through the Nostrad gateway at https://gateway.nostrad.ai. Back to the documentation.

The API definition is in openapi.json (OpenAPI 3.1).

How a purchase works

  1. Your app lists what's on sale: GET /v1/products.
  2. The person chooses something. Your server starts the purchase with their sign-in token: POST /v1/purchases. It answers a purchase_url on https://accounts.nostrad.ai.
  3. Send their browser there. Nostrad shows what it is, the price, their balance and their balance after, and Buy or Cancel. The page lasts 24 hours.
  4. They choose Buy. The price is taken from their credit; you get 70% of it and Nostrad keeps 30%. Nostrad sends their browser back to your return_url with purchase_token added, and sends your server a signed ONE_TIME_PRODUCT_PURCHASED notification.
  5. Your server checks the purchase with your app's API key: GET /v1/purchases/<token>. It delivers what was bought, then acknowledges it: POST /v1/purchases/<token>/acknowledge. A consumable can instead be consumed (POST /v1/purchases/<token>/consume), which acknowledges it and lets it be bought again.
  6. A purchase not acknowledged within 3 days is refunded in full and taken back. Acknowledge only after you deliver.

Two kinds of caller, as on Google Play:

Who callsWithCommands
Your app, for the signed-in personTheir Sign in with Nostrad access tokenGET /v1/products, POST /v1/purchases, GET /v1/purchases
Your serverAn API key of this app with Sales tickedEverything else: checking, acknowledging, consuming, orders, refunds, notifications. A key without Sales answers 403 sales_permission_needed

GET /v1/products takes either; with an API key it lists the products without owned.

Terms

TermWhat it means
ProductWhat you sell: consumable, non_consumable or subscription
Purchase tokenpt_...: names one purchase. A subscription keeps its token across renewals
Order IDNOS.1234-5678-9012-34567: names one charge. The buyer sees it on their receipt. Each subscription renewal is a new order
AcknowledgeYour server telling Nostrad it delivered what was bought
ConsumeYour server telling Nostrad a consumable was used up, so it can be bought again
RevokeTaking back what was bought, with or without a refund
Sales keyAn API key of your app with Sales ticked, kept on your server
License testerA Nostrad account whose purchases in your app are test purchases
CreditWhat buyers pay with: 1 credit is 1 US cent