This page will explain how to let a user of your application buy AdultWork.com credits. A couple of steps are required and shown below.
Implementing our SDK is easy. Include the Javascript SDK on your page once, ideally right after the <body> openingtag.
<script>(function (d, s, id) { var js, ajs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) { return; } js = d.createElement(s); js.id = id; js.src = '//cdn.adultwork.com/platform/sdk/sdk.js#APIKey={your-api-key}&clientId={your-clientid}'; ajs.parentNode.insertBefore(js, ajs); }(document, 'script', 'adultwork-jssdk'));</script>
Once the reference is made with our sdk as described in Implement our SDK you can call the "Buy" function quite easy.
<script> function buyCredits(){ var url = 'https://platform.adultwork.com/Credits/Confirm'; var returnUri = 'https://example.com?yourreference=abc123456789'; var clientId = 'A1B2C3D4E5F6'; var paymentMethod = 'CASH'; var amount = '50'; AW.Buy.initcredits(url, returnUri, 'en-GB', clientId, paymentMethod, amount); AW.Buy.confirm_window(onClose); } function onClose(){ // optional on close callback function. } </script>
CARD
, CASH
and BANK
. The default is CARD
.5
, 10
, 20
, 30
, 40
, 50
, 60
, 70
, 80
, 90
and 100
. The default is 10
.
If you choose to use the returnUri and let the Unified Login refresh your page, you can assume the user has bought credits.