Note: We've had some reports of IAP not working properly. We're working on a fix, but this fix is going in our new version of the API we're building from the ground up. Stay tuned.

We're trying to make payments easy. Use this part of the API if you're looking to do transactions within your game.

Instantiate the payment class like so:

// Note that this doesn't do anything in itself, just creates the object
var pay = new Clay.Payment();

Items can be created in the developer section under your game and refer to specific in game items you want to give out. For example, you can create an item for a new set of levels to unlock. When creating the item, you'll specify a price, and that's how much the user will be charged when you initiate the call.

To add an item to a user's cart you can do so with the following code:

// Remember we are only using the var pay because it was instantiated above
// The 1 in this example refers the the item ID
pay.addItem( { id: 1 }, function() {
    // Callback for when the item is in the cart
    // This would be a good time to call pay.checkout()
} );

Once all the desired items are in a user's cart, you can prompt checkout with:

pay.checkout( function( response ) {
    // Callback with responses regarding payment
    console.log( response.success );
    console.log( response.status );
    console.log( response.error );
    console.log( response.completed);
    console.log( response.itemIds);

If you have encryption enabled for your game and have the method Payment.checkout added on the settings page for your game, a JWT string will be returned instead of the response object. See our encryption docs for info on how to decode this string into the response object. Using this encryption is an extra level of security and allows you to confirm the data was sent to you from


For testing, enable debug mode - read the docs here for more info.

For subsequent times the user plays your game, you can see which items they have purchased with Clay.Player.fetchItems - see here for documentation on this. takes a 30% cut on any purchases made through the API. Payment processor fees are included in this 30%, so you will get exactly 70% of the price you set.

Provide Feedback

We take customer support, and the quality of our developer tools and documentation very seriously. We want to hear how you think we can improve our documentation! Let us know if anything is missing, or unclear on this documentation page, and we'll get that fixed!