Skip to content

Instantly share code, notes, and snippets.

@mjallday
Created May 15, 2013 21:10
Show Gist options
  • Save mjallday/5587412 to your computer and use it in GitHub Desktop.
Save mjallday/5587412 to your computer and use it in GitHub Desktop.
handle both bank accounts and cards in callback
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