Shop.PurchaseAsync(item.Id).
Web checkout needs the Flock SDK for Unity 1.98.0 or later. It needs no extra package. On Android and
iOS the same calls pay through the phone’s store instead: see
In-App Purchases.
1
Connect your gateway to Flock
Open Monetization > Payments in the Flock dashboard and connect the gateway you sell through, with
your own keys. They stay on Flock’s server and never reach the player’s device. Use the gateway’s
test keys while you build: their purchases are marked as tests and left out of your revenue.Connect one gateway, or name the one to use in the game when several are active (below).
- Stripe
- Tap Payments
- Moyasar
In Stripe, under Developers > Webhooks, add an endpoint at
https://api-flock.qwacks.com/v1/shop/webhook/<your game id>/stripe with these events:
checkout.session.completed, checkout.session.expired, payment_intent.payment_failed,
charge.refunded and charge.dispute.closed. Then paste its signing secret into Flock.
Without it, a payment is still delivered, within about 15 minutes instead of at once.Stripe charges in the item’s currency and refuses a price below its smallest charge in your
account’s own currency (for an account that settles in dirhams, 2.00 AED).2
Price the items in real money
Price the item in one of the Real Currencies of your currency config, as for a store item. The price
is the gateway’s charge: 799 in SAR is 7.99 riyals. An item needs no store product id for web checkout.
3
Connect in your game
Connect once, after the SDK starts. On Windows, macOS, Linux and WebGL builds,
FlockStore connects a
web checkout by itself:store.IsWebCheckout is true on these builds, and store.GetPrice(item.Id).Text gives the item’s own
price to show; on a web checkout it is never null. The number is written in the player’s device format,
so SAR 7.99 is one example of how it can look.Buy
PurchaseAsync opens a checkout, opens its payment page, and waits until it is paid, declined or expired.
A checkout is never opened twice: if no answer comes back, the call fails rather than trying again.
- The player leaves the game before paying: the checkout stays open on the server. At the player’s
next sign-in it is found again, and
PurchaseCompletedreports it once paid. - Paid while the game was closed: Flock delivers it all the same, and it shows in the wallet and
inventory, but no
PurchaseCompletedis raised for it. - Cancelling the call (its cancellation token) stops the waiting, not the checkout: once paid,
PurchaseCompletedreports it. - Signing out ends the waiting. The checkout is found again at that player’s next sign-in.
WebGL
A browser opens a new tab only for a short time after the player’s click. The payment page opens as soon as the checkout is ready, about a second and a half after the click in our tests, and a Chromium browser (Chrome, Edge) opened it. Firefox allows a similar time; Safari allows about a second, so it may block the tab. For Safari, show your own Pay now button, whose click opens the page at once:Test before you ship
Connect the gateway’s test keys, then buy with one of its test cards (Stripe’s4242 4242 4242 4242, any future date and any CVC; Tap’s and Moyasar’s are in their own docs). A test
purchase is delivered like any other, marked as a test, and left out of your revenue. Leave one checkout
unpaid to see it close as Expired after the hour.
When something fails
Every failure’sMessage says what went wrong and, on a Fix: line, how to fix it.