Permalink
Browse files

Added fuzzy workarounds to normalize transparent post field name erro…

…rs accross all transparent post actions
  • Loading branch information...
1 parent 97f088d commit d732a910046377775fc5d6e7dc91abe4620bf3c6 @robrighter committed Apr 7, 2011
Showing with 26 additions and 1 deletion.
  1. +25 −0 lib/transparent.js
  2. +1 −1 package.json
View
25 lib/transparent.js
@@ -93,6 +93,7 @@
}
}
});
+ errors = handleFuzzyLogicSpecialCases(errors);
return {fields: fields, errors: errors};
}
@@ -202,6 +203,30 @@
}
return true;
}
+
+ function handleFuzzyLogicSpecialCases(errors){
+ var toreturn = []
+ errors.forEach(function(e){
+ switch(e.field){
+ case 'billing_info[verification_value]':
+ toreturn.push(copyWithNewName('billing_info[credit_card][verification_value]', e));
+ toreturn.push(copyWithNewName('credit_card[verification_value]', e));
+ break;
+ case 'credit_card[number]':
+ toreturn.push(copyWithNewName('billing_info[credit_card][number]', e));
+ toreturn.push(e);
+ break;
+ default:
+ toreturn.push(e);
+ break;
+ }
+ });
+ return toreturn;
+ }
+
+ function copyWithNewName(name, error){
+ return {field: name,reason: error.reason};
+ }
}//END CLASS
View
2 package.json
@@ -1,7 +1,7 @@
{ "name" : "node-recurly"
, "description" : "Library for accessing the api for the Recurly recurring billing service."
, "keywords" : [ "recurly", "e-commerce", "recurring billing" ]
-, "version" : "0.0.7"
+, "version" : "0.0.8"
, "homepage" : "https://github.com/robrighter/node-recurly"
, "author" : "Rob Righter <robrighter@gmail.com> (http://github.com/robrighter)"
, "contributors" :

0 comments on commit d732a91

Please sign in to comment.