Sportsbook
Launch the BSW and ElectroBets sportsbooks, boot the BSW frame and learn how sportsbook bets, wins and rollbacks reach your wallet.
Launch the sportsbook
The catalogue lists each sportsbook as a game: the BSW sportsbook has the provider betting_software and the ElectroBets sportsbook has the provider electrobets. To launch one, create a session with its game_id, as for a game. A sportsbook has no demo mode, so use the mode value real; a demo launch is refused with DEMO_NOT_SUPPORTED. Every page load is a new launch: when the player reloads the page, create a new session.
The BSW sportsbook answers frame, the data that its frame boots with, in place of game_url. The ElectroBets sportsbook answers a game_url for an iframe.
Boot the BSW frame
Do these steps on your page:
- Add a container element with the id from
container_id:sport_div_iframeon desktop andapplication-containeron mobile. - Load the two
scriptsin their order: the integration loader first, then the bootstrapper. - On desktop, call
SportFrame.framewith the pairsserver,token,parent,currentPage,languageandsportPartner. - On mobile, call
Bootstrapper.bootIframewithserver,containerId,token,parent,defaultLanguageandsportPartner, and the mode{ name: 'Mobile' }.
Your page supplies parent and currentPage; they are not in the answer. The sample uses [location.host] and 'Home'. For mobile, defaultLanguage is the language of the answer: the sample passes frame.language.
The token is a one-time credential: give it only to the frame and never write it to a log. The JavaScript frame is the only way to launch the BSW sportsbook; a mobile app shows it in a webview. The SDK API guide has a sample that does these steps.
BSW has no staging. The development environment uses the production BSW partner with a small test balance, so use only test players.
Open the ElectroBets iframe
Open the game_url in an iframe on your page. The ElectroBets page posts events to your page; Sessions and launch lists them and tells you to check event.origin first. A reload of the page is a new launch, so do not use a game_url two times.
Currencies and refused launches
The aggregator opens one provider account for each player and currency, so a player who plays in two currencies has two sportsbook accounts. The aggregator writes BSW amounts with two decimals, and serves only TRY, USD and EUR.
These launches are refused with 422 before the aggregator calls the provider:
CURRENCY_NOT_SUPPORTED: the sportsbook or your client cannot serve the currency.DEMO_NOT_SUPPORTED: the request asks for demo mode.COUNTRY_RESTRICTED: the sportsbook must not serve the country of the request.
An unknown or disabled sportsbook gives 404 with NOT_FOUND. When the provider refuses or fails the launch, you get 502 with INTERNAL_ERROR. Errors lists every code.
Sportsbook money in your wallet
The sportsbook adds no new webhook: its money reaches your wallet through the same five wallet webhooks as a game. One round is one sportsbook bet, and provider_round_id is the bet id of the provider.
The aggregator changes each BSW operation into wallet webhooks:
player_balance: a balance check. It is abalancewebhook to your wallet and moves no money.debit: a bet, which opens the round. Your wallet must answer it within the bet deadline of 3 seconds; Wallet webhooks tells more.credit: a win, which settles the bet; oneround-finishedfollows.lose: a win of0, which settles the bet; oneround-finishedfollows.cancel_debit: a rollback of the bet before it is settled.cancel_credit: a rollback of the win. This rollback can make the balance less than zero, so your wallet must not refuse it withINSUFFICIENT_FUNDSorPLAYER_LIMIT_REACHED.- Cash-out: a win of the cash-out amount, which settles the bet.
Settlement after the round closed
A sportsbook bet can stay open for days. The round does not close when the session expires or after a time limit, and the aggregator accepts the settlement after the session expired.
The provider can change a settled bet. A resettlement is a rollback of the win, then a new win on the same round. A partial cancel of a win is a rollback of the full win, then a win of the remaining amount. These webhooks can come after round-finished, so accept a win and a rollback on a finished round. The aggregator sends round-finished only one time for a round. The aggregator refuses a cancel_debit after the bet is settled and a cancel_credit of a lose. The aggregator refuses any other order of operations toward the provider and sends nothing to your wallet.
Idempotency
Each provider operation has its own key. For BSW, debit and lose use transaction_id; credit, cancel_debit and cancel_credit use id_transaction_from_duplicates. For ElectroBets, a bet uses <TicketId>:0:bet and a refund uses <TicketId>:0:refund. The aggregator sends each operation to your wallet one time, with its own transaction_id. When the aggregator sends a webhook again, it uses the same transaction_id, so your wallet must give the first answer again and move no money; Idempotency tells how. When the provider sends a callback again, the aggregator gives it the stored answer and does not call your wallet again.
ElectroBets tickets
ElectroBets calls three endpoints of the aggregator: /player, /balance and /bet. ElectroBets always answers HTTP 200 with an envelope, and it never sends a /bet again. The aggregator therefore answers a /bet within the callback time limit. provider_round_id is the TicketId.
/balance: a balance check. It is abalancewebhook to your wallet and moves no money./bet: one stake debit for one ticket. It is adebitwebhook to your wallet and opens the round. Its key is<TicketId>:0:bet.- Refund: about one minute after a debit, the aggregator reads the ticket status from ElectroBets. If ElectroBets cancelled the ticket, the aggregator sends a
rollbackwebhook to your wallet. Its key is<TicketId>:0:refund. - A rollback targets bets only. It always names the debit of the ticket.
If the status is unclear, the aggregator moves no money and raises an alert.