Charging merchants
Create a subscription for your app, send the merchant to approve it, and check what the store pays for.
Your app charges a store through the Admin API. The merchant approves each charge in the store dashboard, and it is added to the store's Tanqory bill. On a development store every charge is a test charge.
- Your app → Tanqory appSubscriptionCreate: name, price, returnUrl
- Tanqory → Your app confirmationUrl; the subscription is PENDING
- Your app → Merchant Opens confirmationUrl at the top of the browser
- Merchant → Tanqory Approve charge, within 48 hours (store owner or admin)
- Tanqory The subscription is ACTIVE; an app_subscriptions/update webhook goes to your app
- Merchant → Your app Comes back to returnUrl with charge_id
- Your app → Tanqory Checks activeSubscriptions before unlocking the plan
- Tanqory Each period, the charge goes on the store's Tanqory bill (never a test charge)
- Tanqory → Your organization Your share, paid out on the 1st and the 16th once your payout account and tax form are set up
1. Create the charge
mutation Subscribe($name: String!, $returnUrl: URL!, $lineItems: [AppSubscriptionLineItemInput!]!, $test: Boolean) {
appSubscriptionCreate(name: $name, returnUrl: $returnUrl, lineItems: $lineItems, test: $test) {
appSubscription { id status }
confirmationUrl
userErrors { field message }
}
}{
"name": "Basic",
"returnUrl": "https://example.com/billing/return",
"test": true,
"lineItems": [
{ "plan": { "appRecurringPricingDetails": { "price": { "amount": 9.99, "currencyCode": "USD" }, "interval": "EVERY_30_DAYS" } } }
]
}The subscription starts as PENDING, and the answer carries a confirmationUrl.
2. Send the merchant to approve it
Open confirmationUrl at the top level of the browser, not inside your frame. An embedded app does this with App Bridge's redirect.remote.
The page Approve app charge shows your app, the plan, the price, the first charge date and the currency, and on a development store "This is a test charge. You won't be billed." The merchant selects Approve charge or Decline charge. The request expires after 48 hours.
After approving, the merchant comes back to your returnUrl, with charge_id added to it.
3. Check what is active
{
currentAppInstallation {
activeSubscriptions {
name
status
test
currentPeriodEnd
lineItems { plan { pricingDetails { ... on AppRecurringPricing { price { amount currencyCode } interval } } } }
}
}
}An approved subscription is ACTIVE. Check this on your server before you unlock what the merchant paid for; never trust the return alone.
Other kinds of charges
appPurchaseOneTimeCreate: a single payment, approved the same way.appUsageRecordCreate: a charge for usage, on a subscription line item that has a usage pricing plan with a capped amount.appSubscriptionCancel: ends a subscription; its status becomesCANCELLED.
The prices in your app must match the pricing plans in your listing.
What reaches the store's bill
Only an approved, non-test charge in US dollars on a store that is not a development store is put on the store's Tanqory bill, and only that earns you a share. Two kinds of charge are accepted but held instead, never billed and never paid out:
- Charges on a development store. Every charge there is a test charge, whatever
testyou send, so you can try the whole flow for free. - Charges in another currency. The store's bill is in USD for now. A charge whose
currencyCodeis notUSDcan still be created and approved, but it is held and not billed. Price your plans in USD.