{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"settings":"","params":[]},"next":{"description":"","pages":[]},"title":"Events","type":"basic","slug":"form-api-events","excerpt":"","body":"If you want to do some manual work, there are some events you can handle.\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"fundraisingBox:init\"\n}\n[/block]\nTriggered after the form has been sucessfully initialized. \nProvides a JSON with [Form Configuration](doc:form-configuration-json) and [Session](doc:session-json) / [Transaction](doc:transaction-json) and some additional info.\n[block:callout]\n{\n \"type\": \"warning\",\n \"title\": \"Consider this event for dynamic forms!\",\n \"body\": \"Don't forget: the initialization of the form is done asynchronously! You have to wait for this event until you can use the Plugin-functions. See [Functions](doc:form-api-functions).\"\n}\n[/block]\n\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n\\t\\\"status\\\": \\\"success\\\",\\n \\\"config\\\": {...}, // see Form Configuration JSON\\n \\\"session\\\": {...}, // see Session JSON\\n \\\"info\\\": {\\n \\\"credit_card_errors\\\": {\\n \\\"empty\\\": \\\"This is a required field.\\\",\\n \\\"luhn\\\": \\\"Invalid\\\",\\n \\\"bad\\\": \\\"Invalid\\\",\\n \\\"expire\\\": \\\"Invalid\\\",\\n \\\"system\\\": \\\"System error\\\",\\n \\\"syserror\\\": \\\"Credit card payment failed. Please try again or select a different payment method.\\\"\\n },\\n \\\"micropayment_project\\\": \\\"abc123\\\"\\n }\\n}\",\n \"language\": \"json\"\n }\n ]\n}\n[/block]\n**Example: adding visible items:**\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"<div id=\\\"items\\\"></div>\\n<script>\\n\\tmyForm.on(\\\"fundraisingBox:init\\\", function(event, json) {\\n \\tif(json.status == \\\"success\\\")\\n {\\n\\t\\t\\tvar items = myForm.getItems();\\n for(i=0; i<items.length; i++)\\n {\\n if(items[i].visible)\\n {\\n $(\\\"#items\\\").append(\\\"<div><input type='radio' name='payment[fb_item_id]' value='\\\"+items[i].id+\\\"' />\\\"+items[i].title+\\\" \\\"+items[i].amount+\\\"€</div>\\\");\\n }\\n }\\n ...\\n }\\n\\t});\\n</script>\",\n \"language\": \"javascript\"\n }\n ]\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"fundraisingBox:updateSession\"\n}\n[/block]\nTriggered after updateSession() is successfully done.\nProvides a JSON with the [Session](doc:session-json).\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n\\t\\\"status\\\": \\\"success\\\",\\n \\\"session\\\": {...} // see Session JSON\\n}\",\n \"language\": \"json\"\n }\n ]\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"fundraisingBox:payment\"\n}\n[/block]\nTriggered after doPayment() is successfully done.\n\n**On success:**\nProvides a JSON with the [Transaction](doc:transaction-json)\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n \\\"status\\\": \\\"success\\\",\\n \\\"payment_status\\\": \\\"success\\\", // or \\\"awaiting\\\" if redirect payment (PayPal, Sofortüberweisung, EPS)\\n \\\"redirect_url\\\": \\\"http://meineorga.de/spenden/danke.html?betrag=120\\\",\\n \\\"transaction\\\": {...} // see Transaction JSON\\n}\",\n \"language\": \"json\"\n }\n ]\n}\n[/block]\n**On error**\nProvides a JSON with errors.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n \\\"status\\\": \\\"success\\\",\\n \\\"payment_status\\\": \\\"error\\\",\\n \\\"errors\\\": { // see Errors JSON\\n \\\"current_fields\\\": { ... },\\n \\\"globals\\\": [ \\n \\\"Es ist ein Fehler aufgetreten. Bitte laden Sie die Seite neu und versuchen Sie es erneut.\\\"\\n ]\\n\\t}\\n}\",\n \"language\": \"json\"\n }\n ]\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"fundraisingBox:creditCardReady\"\n}\n[/block]\nTriggered after the additional credit card javascript is done.\nWait for this event if you want to use the credit card functions.\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"fundraisingBox:creditCardSuccess\"\n}\n[/block]\nTriggered after the token has been created successfully.\nProvides a JSON with token and obfuscated number and secure id.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{ \\n token: \\\"123456f0d83ef93830caaf25f94c19fbd\\\",\\n number: \\\"411111******1111\\\",\\n secure_id: \\\"***\\\"\\n}\",\n \"language\": \"json\"\n }\n ]\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"fundraisingBox:creditCardError\"\n}\n[/block]\nTriggered if it was not possible to create the credit card token.\nProvides [Errors JSON](doc:errors-json) with credit card errors in \"current_fields\".","updates":[],"order":4,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"57e110199ff1e21900a721bd","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Form-API (Enterprise)","slug":"form-api-jquery-plugin","order":3,"from_sync":false,"reference":false,"_id":"57e104db9ff1e21900a721ab","__v":1,"createdAt":"2016-09-20T09:43:55.998Z","version":"571f5e8cd8667f0e00a3c49b","project":"571f5e8cd8667f0e00a3c498"},"createdAt":"2016-09-20T10:31:53.021Z","parentDoc":null,"__v":1,"user":"5720c075db52d01700f5d1e4","githubsync":"","project":"571f5e8cd8667f0e00a3c498","version":{"version":"1","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["571f5e8cd8667f0e00a3c49c","571f73cfcb4baa0e00d13a80","571f7451cb4baa0e00d13a88","571f7d2720695f3400f38797","571f7fb0ac2a080e0014c661","571f884be54f2d0e003ebb0a","572200c9ecb38d0e00d80ebd","572c301e7c8eff0e00aaa174","57df91b2c6348d0e0020c452","57e104db9ff1e21900a721ab","57fd04caeaa77f19008b8202","5899c7113514ce0f0014da84","5cbeda4b862d090013abd413","5e60d6278f8b380072f0b1e3"],"_id":"571f5e8cd8667f0e00a3c49b","hasDoc":true,"releaseDate":"2016-04-26T12:26:52.312Z","__v":14,"hasReference":true,"createdAt":"2016-04-26T12:26:52.312Z","project":"571f5e8cd8667f0e00a3c498"}}