Skip to content

Commit

Permalink
1.0.2, Response.errorCode
Browse files Browse the repository at this point in the history
  • Loading branch information
philcruz committed Nov 29, 2011
1 parent 7c042df commit 6e177f5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
5 changes: 4 additions & 1 deletion README.txt
Expand Up @@ -22,11 +22,14 @@ Basic usage is like:
Implements all the functions of the Stripe API:
Charges, Customers, Plans, Coupons, Subscriptions, Invoice Items, Invoices, and Tokens

Supported CFML engines: ColdFusion 9.0.1 or Railo 3.3.1

Support: http://groups.google.com/group/stripecfc/

FW/1 (https://github.com/seancorfield/fw1) is the framework used for this web application
but that is not required to use Stripe.cfc in your own application.


Changes:
11/29/2011 - changes to Response.getRawResponse() to .getResult(), use a common view for errors, handle 400,404 status codes
11/29/2011 - 1.0.2,Response.errorCode
11/29/2011 - 1.0.1,changes to Response.getRawResponse() to .getResult(), use a common view for errors, handle 400,404 status codes
5 changes: 3 additions & 2 deletions stripe/Response.cfc
Expand Up @@ -2,9 +2,10 @@ component accessors="true"
{
property name="status"; //unprocessed, success, failure
property name="result"; //the deserialized json object from the API call
property name="errorType";
property name="errorType"; //error types: invalid_request_error, api_error, card_error, http_error
property name="errorCode";
property name="errorMessage";
property name="rawResponse"; //cfhttp.filecontent of the API http request
property name="rawResponse"; //the raw response from the cfhttp request

function init()
{
Expand Down
17 changes: 10 additions & 7 deletions stripe/Stripe.cfc
Expand Up @@ -27,7 +27,7 @@ component accessors="true"

function getVersion()
{
return "1.0.1";
return "1.0.2";
}

function updateSubscription(id,plan,prorate=true,trial_end="",card="")
Expand Down Expand Up @@ -298,17 +298,19 @@ component accessors="true"
switch(status)
{
case "400":
case "401":
case "402":
case "404":
response = deserializeJSON(httpResponse.fileContent);
stripeResponse.setStatus("failure");
stripeResponse.setErrorType(response.error.type);
response = deserializeJSON(httpResponse.fileContent);
stripeResponse.setErrorType(response.error.type);
stripeResponse.setErrorMessage(response.error.message);
if (isDefined('response.error.code')) stripeResponse.setErrorCode(response.error.code);
break;
default:
stripeResponse.setErrorType("http_error");
stripeResponse.setErrorMessage("Gateway returned unknown response: #status#: #httpResponse.errorDetail#");
stripeResponse.setStatus("failure");
}
stripeResponse.setErrorMessage("Gateway returned unknown response: #status#: #httpResponse.errorDetail#");
}
stripeResponse.setStatus("failure");
}
else
{
Expand All @@ -319,6 +321,7 @@ component accessors="true"
//failure
stripeResponse.setStatus("failure");
stripeResponse.setErrorType(response.error.type);
stripeResponse.setErrorCode(response.error.code);
stripeResponse.setErrorMessage(response.error.message);
}
else
Expand Down
3 changes: 2 additions & 1 deletion views/common/responseerror.cfm
@@ -1,7 +1,8 @@
<cfoutput>
<div class="errorMessage">
errorType: #stripeResponse.getErrorType()#<br />
errorType: #stripeResponse.getErrorType()#<br />
errorMessage: #stripeResponse.getErrorMessage()#<br />
<cfif len(stripeResponse.getErrorCode()) >errorCode: #stripeResponse.getErrorCode()#<br /></cfif>
<!--- #stripeResponse.getRawResponse().toString()# --->
</div>
</cfoutput>

0 comments on commit 6e177f5

Please sign in to comment.