{"_id":"57e110199ff1e21900a721bd","category":{"_id":"57e104db9ff1e21900a721ab","__v":0,"version":"571f5e8cd8667f0e00a3c49b","project":"571f5e8cd8667f0e00a3c498","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-09-20T09:43:55.998Z","from_sync":false,"order":4,"slug":"form-api-jquery-plugin","title":"Form-API"},"parentDoc":null,"__v":1,"user":"5720c075db52d01700f5d1e4","project":"571f5e8cd8667f0e00a3c498","version":{"_id":"571f5e8cd8667f0e00a3c49b","hasDoc":true,"__v":12,"hasReference":true,"project":"571f5e8cd8667f0e00a3c498","createdAt":"2016-04-26T12:26:52.312Z","releaseDate":"2016-04-26T12:26:52.312Z","categories":["571f5e8cd8667f0e00a3c49c","571f73cfcb4baa0e00d13a80","571f7451cb4baa0e00d13a88","571f7d2720695f3400f38797","571f7fb0ac2a080e0014c661","571f884be54f2d0e003ebb0a","572200c9ecb38d0e00d80ebd","572c301e7c8eff0e00aaa174","57df91b2c6348d0e0020c452","57e104db9ff1e21900a721ab","57fd04caeaa77f19008b8202","5899c7113514ce0f0014da84"],"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-09-20T10:31:53.021Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"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\".","excerpt":"","slug":"form-api-events","type":"basic","title":"Events"}
If you want to do some manual work, there are some events you can handle. [block:api-header] { "type": "basic", "title": "fundraisingBox:init" } [/block] Triggered after the form has been sucessfully initialized. Provides a JSON with [Form Configuration](doc:form-configuration-json) and [Session](doc:session-json) / [Transaction](doc:transaction-json) and some additional info. [block:callout] { "type": "warning", "title": "Consider this event for dynamic forms!", "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)." } [/block] [block:code] { "codes": [ { "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}", "language": "json" } ] } [/block] **Example: adding visible items:** [block:code] { "codes": [ { "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>", "language": "javascript" } ] } [/block] [block:api-header] { "type": "basic", "title": "fundraisingBox:updateSession" } [/block] Triggered after updateSession() is successfully done. Provides a JSON with the [Session](doc:session-json). [block:code] { "codes": [ { "code": "{\n\t\"status\": \"success\",\n \"session\": {...} // see Session JSON\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "fundraisingBox:payment" } [/block] Triggered after doPayment() is successfully done. **On success:** Provides a JSON with the [Transaction](doc:transaction-json) [block:code] { "codes": [ { "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}", "language": "json" } ] } [/block] **On error** Provides a JSON with errors. [block:code] { "codes": [ { "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}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "fundraisingBox:creditCardReady" } [/block] Triggered after the additional credit card javascript is done. Wait for this event if you want to use the credit card functions. [block:api-header] { "type": "basic", "title": "fundraisingBox:creditCardSuccess" } [/block] Triggered after the token has been created successfully. Provides a JSON with token and obfuscated number and secure id. [block:code] { "codes": [ { "code": "{ \n token: \"123456f0d83ef93830caaf25f94c19fbd\",\n number: \"411111******1111\",\n secure_id: \"***\"\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "fundraisingBox:creditCardError" } [/block] Triggered if it was not possible to create the credit card token. Provides [Errors JSON](doc:errors-json) with credit card errors in "current_fields".