Ostorya dev docs

Admin API/Store properties/Mutations

appCreditsCharge

mutationOstorya extension

Takes credits from the store's wallet for a paid app feature. Refused (NOT_ENOUGH_CREDITS) when the balance is short; the same idempotencyKey never charges twice. At most 5,000 credits a call.

Returns AppCreditsChargePayload!

mutation AppCreditsCharge($credits: Int!, $idempotencyKey: String!, $reason: String!) {
  appCreditsCharge(credits: $credits, idempotencyKey: $idempotencyKey, reason: $reason) {
    balance
    charged
    need
    userErrors {
      code
      message
      field
    }
  }
}

# Variables
{
  "credits": 1,
  "idempotencyKey": "",
  "reason": ""
}

Arguments

creditsInt!required
idempotencyKeyString!required
reasonString!required

Payload

balanceInt
The store's balance after the call.
chargedBoolean!required
True when the credits were taken now. A repeated idempotencyKey answers false with no error.
needInt
Set with NOT_ENOUGH_CREDITS: what the call needed. Show Ostorya's Add credits popup, never an error.
userErrors[UserError!]!required