Buy credits

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.

  1. Implement our SDK.
  2. Call the "Buy" function in our SDK.

 

 

Implement our SDK

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>
  • {your-api-key}
    • The api key of your project. This can be found in the project's details page.
  • {your-clientid}
    • The client identifier. This can be found in the project's details page under the Unified Login tab.

 

 

Call the "Buy" function in our SDK.

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>
  • url
    • The URL of our buy functionality in the platform. This value must be set to 'https://platform.adultwork.com/Credits/Confirm'.
  • returnUri
    • The sdk will open a pop-up. You can choose to let the pop-up set the return URI of the opener (your page). For example you can refresh the current page on a successful purchase. If you don't want to use this parameter send in a empty string ('').
  • clientId
    • The client identifier. This can be found in the project's details page under the Unified Login tab.
  • paymentMethod
    • The payment method you wish to be selected as default. Possible values are CARD, CASH and BANK. The default is CARD.
  • amount
    • The amount of credits you wish to be selected as default. Possible values are 5, 10, 20, 30, 40, 50, 60, 70, 80, 90 and 100. The default is 10.
  • onClose
    • Optional callback function which the SDK will call when the pop-up closes.

 

If you choose to use the returnUri and let the Unified Login refresh your page, you can assume the user has bought credits.