-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Silently Failing #139
Comments
Can you be more specific about what you mean by "silently fails"? You get a transaction or not? |
The function returns just fine without any exceptions but the transaction fails and does not appear in our recurly dashboard. |
Even though we've got code to catch errors, it will not catch the errors. Before we got it working, it would create the account but it would not create the transaction and would not pass billing information with no explanation as to why. It would not return anything, an exception or otherwise. The concern is, even though we've got it working now, if it's not throwing exceptions when it should, we could have a failure in the future that we don't know about until it has already caused a ton of problems. Another dev I spoke to believes this could be a bug in the php library and asked us to open an issue here. |
Sorry could you explain a bit more about what was happening. You create the billing info token using RJS v3, then pass it into that sample code. You get a subscription object back but its status is failed? |
@drewish I ran into this with them yesterday. I got their core issue resolved but couldn't figure out what was going on with exceptions. They were getting errors back in the xml responses but it wasnt throwing exceptions in php. @cschoenig preferably we'd like to see a complete script demonstrating the problem. Please include the call to get the account and your exception handling code. Just don't post any api keys. |
Hope this helps. <?php
Class Log{
public static function write($string){
echo $string;
}
}
function doTransaction($account_id, $token, $cents){
try{
$account = NULL;
if($account_id == NULL/*Create an account if this user does not have one*/){
CREATE_ACCOUNT:
$account = new Recurly_Account();
$account->billing_info->token_id = $token;
$account->create();
}
else/*Otherwise grab the existing recurly account*/{
try{
$account = Recurly_Account::get($account_id);
$account->billing_info->token_id = $token;
}catch (Recurly_NotFoundError $e){/*Invalid or no recurly account; lets make a new one*/
Log::write(get_class($e) . ': ' . $e->getMessage());
goto CREATE_ACCOUNT;
}
}
//Process the transaction
$transaction = new Recurly_Transaction();
$transaction->amount_in_cents = $cents;
$transaction->currency = 'USD';
$transaction->account = $account;
$transaction->create();
return 'OK';
}
catch (Recurly_ValidationError $e){
Log::write('Recurly_ValidationError: ' . implode("\n", explode(',', $e->getMessage())));
return 'There was an issue validating this transaction.<br>Reason: "' . $e->getMessage() . '"';
}
catch (Recurly_ServerError $e) {
Log::write(get_class($e) . ': ' . $e->getMessage());
return 'There was a problem communicating with our billing service.';
}
catch (Exception $e){
Log::write(get_class($e) . ': ' . $e->getMessage());
return 'There was an unexpected problem processing this transaction.';
}
}
?> |
I worked this out with @cschoenig and @brandonb1218 in IRC. |
$transaction = new Recurly_Transaction();
$transaction->amount_in_cents = $cents;
$transaction->currency = 'USD';
$transaction->account = new Recurly_Account();
$transaction->account->account_code = $account->account_code;
$transaction->account->billing_info->token_id = $token;
$transaction->create();
This silently fails on both our live and test servers. The transaction will go through as if no token was submitted.
The text was updated successfully, but these errors were encountered: