Skip to content
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

Closed
cschoenig opened this issue Feb 24, 2015 · 7 comments
Closed

Silently Failing #139

cschoenig opened this issue Feb 24, 2015 · 7 comments
Labels
V2 V2 Client

Comments

@cschoenig
Copy link

$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.

@drewish
Copy link

drewish commented Feb 24, 2015

Can you be more specific about what you mean by "silently fails"? You get a transaction or not?

@cschoenig
Copy link
Author

The function returns just fine without any exceptions but the transaction fails and does not appear in our recurly dashboard.

@ghost
Copy link

ghost commented Feb 24, 2015

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.

@drewish
Copy link

drewish commented Feb 24, 2015

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?

@bhelx bhelx reopened this Feb 24, 2015
@bhelx
Copy link
Contributor

bhelx commented Feb 24, 2015

@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.

@ghost
Copy link

ghost commented Feb 24, 2015

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.';
        }
    }
?>

@bhelx
Copy link
Contributor

bhelx commented Feb 26, 2015

I worked this out with @cschoenig and @brandonb1218 in IRC.

@bhelx bhelx closed this as completed Feb 26, 2015
@bhelx bhelx added the V2 V2 Client label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
Development

No branches or pull requests

3 participants