{"__v":7,"_id":"570a5df09d7b6e0e003a96cd","category":{"project":"56abbf55f25f160d00e17f4e","version":"56abbf55f25f160d00e17f51","_id":"570a5676ade45d0e00c1ad33","__v":0,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-04-10T13:34:46.864Z","from_sync":false,"order":3,"slug":"client-side-api","title":"Client Side API"},"parentDoc":null,"project":"56abbf55f25f160d00e17f4e","user":"56abbec30b9e0b0d00616274","version":{"__v":12,"_id":"56abbf55f25f160d00e17f51","project":"56abbf55f25f160d00e17f4e","createdAt":"2016-01-29T19:36:53.665Z","releaseDate":"2016-01-29T19:36:53.665Z","categories":["56abbf56f25f160d00e17f52","56abca6bf9757e0d007c6650","56acddfa0ab3c00d00ce3332","56af65da9d32e30d0006d30f","56af66cab34d210d003d9ad0","56af6afcd21e9c0d00b628d1","56af6d6ecc4cbd0d00ce2c88","5705b12221cfed0e00e8c580","570a5676ade45d0e00c1ad33","570d7d25d1e4b82000d9e385","570eac3c3160d10e0041df0e","575709000fd6a3200010dded"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-04-10T14:06:40.559Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":true,"order":9,"body":"## Requesting Remote/Dynamic Item Purchase\n\nYou may start the [Dynamic Purchasing API](doc:api-dynamic-purchasing) purchase flow using the `purchaseItemsRemote` method on the `mtx` services object. It accepts an order info string which will be passed to your API callback as a [signed request](doc:concepts-signed-requests), as well as a callback function which should be called with the result of the purchase:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`order_information`\",\n    \"0-1\": \"String\",\n    \"0-2\": \"An order info string that will be passed to your server in an API callback.\",\n    \"1-0\": \"`callback`\",\n    \"1-1\": \"Function\",\n    \"1-2\": \"A callback function for when the purchase dialog is closed.\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\nThe callback function is passed a single object with the following fields:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`success`\",\n    \"0-1\": \"Boolean\",\n    \"0-2\": \"A flag indicating whether or not the purchase was successful.\",\n    \"1-0\": \"`item_order_id`\",\n    \"1-1\": \"Integer\",\n    \"1-2\": \"The unique ID of the transaction, or undefined if the purchase failed\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\n**Example:** Starting a dynamic item purchase with order info set to 'sword':\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"kongregate.mtx.purchaseItemsRemote(\\\"sword\\\", onPurchaseResult);\\n \\nfunction onPurchaseResult(result:Object):void {\\n  trace(\\\"Purchase success:\\\" + result.success + \\\", id: \\\" + result.item_order_id);\\n}\",\n      \"language\": \"haxe\",\n      \"name\": \"ActionScript 3\"\n    },\n    {\n      \"code\": \"kongregate.mtx.purchaseItemsRemote(\\\"sword\\\", onPurchaseResult);\\n \\nfunction onPurchaseResult(result) {\\n  trace(\\\"Purchase success:\\\" + result.success + \\\", id: \\\" + result.item_order_id);\\n}\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\nOnce the purchase dialog is invoked, the `item_order_request` signed request callback will be initiated to your API callback URL so that your game server can define the items to be purchased dynamically.","excerpt":"Start the dynamic item purchase flow\n`purchaseItemsRemote(order_information, callback)`","slug":"client-api-mtx-purchaseitemsremote","type":"fn","title":"Mtx.PurchaseItemsRemote"}

Mtx.PurchaseItemsRemote

Start the dynamic item purchase flow `purchaseItemsRemote(order_information, callback)`

## Requesting Remote/Dynamic Item Purchase You may start the [Dynamic Purchasing API](doc:api-dynamic-purchasing) purchase flow using the `purchaseItemsRemote` method on the `mtx` services object. It accepts an order info string which will be passed to your API callback as a [signed request](doc:concepts-signed-requests), as well as a callback function which should be called with the result of the purchase: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "`order_information`", "0-1": "String", "0-2": "An order info string that will be passed to your server in an API callback.", "1-0": "`callback`", "1-1": "Function", "1-2": "A callback function for when the purchase dialog is closed." }, "cols": 3, "rows": 2 } [/block] The callback function is passed a single object with the following fields: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "`success`", "0-1": "Boolean", "0-2": "A flag indicating whether or not the purchase was successful.", "1-0": "`item_order_id`", "1-1": "Integer", "1-2": "The unique ID of the transaction, or undefined if the purchase failed" }, "cols": 3, "rows": 2 } [/block] **Example:** Starting a dynamic item purchase with order info set to 'sword': [block:code] { "codes": [ { "code": "kongregate.mtx.purchaseItemsRemote(\"sword\", onPurchaseResult);\n \nfunction onPurchaseResult(result:Object):void {\n trace(\"Purchase success:\" + result.success + \", id: \" + result.item_order_id);\n}", "language": "haxe", "name": "ActionScript 3" }, { "code": "kongregate.mtx.purchaseItemsRemote(\"sword\", onPurchaseResult);\n \nfunction onPurchaseResult(result) {\n trace(\"Purchase success:\" + result.success + \", id: \" + result.item_order_id);\n}", "language": "javascript", "name": null } ] } [/block] Once the purchase dialog is invoked, the `item_order_request` signed request callback will be initiated to your API callback URL so that your game server can define the items to be purchased dynamically.