Created
May 15, 2013 21:10
-
-
Save mjallday/5587412 to your computer and use it in GitHub Desktop.
handle both bank accounts and cards in callback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function responseCallbackHandler(response) { | |
switch (response.status) { | |
case 400: | |
// missing or invalid field - check response.error for details | |
console.log(response.error); | |
break; | |
case 404: | |
// your marketplace URI is incorrect | |
console.log(response.error); | |
break; | |
case 201: | |
// WOO HOO! MONEY! | |
// response.data.uri == URI of the bank account resource you | |
// should store this bank account URI to later credit it | |
console.log(response.data); | |
$.post('/somewhere/on/your/server', response.data).success(function () { | |
// TODO: redirect somewhere | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment