Recurly subscription object not found

482 views Asked by At

I have a form where the user can enter their credit information. When they submit I keep getting 'Object not found'.

I checked the keys and subdomain everything is correct. What could be the issue?

public function createSubscription($plan,$token,$email,$fname,$lname,$currency,$starts_at,$company_name)
{

    try {

        $subscription = new \Recurly_Subscription();
        $subscription->plan_code = $plan;
        $subscription->currency = $currency;
        $subscription->starts_at = $starts_at;

        $account = new \Recurly_Account();
        $account->account_code = $email;
        $account->first_name = $fname;
        $account->last_name = $lname;
        $account->email = $email;
        $account->company_name = $company_name;

        $billing_info = new \Recurly_BillingInfo();
        $billing_info->token_id = $token;

        $account->billing_info = $billing_info;
        $subscription->account = $account;
        $subscription->create();
    }
    catch (\Recurly_ValidationError $e){
        throw new CreditDeclined($e->getMessage());
    }
    catch ( \Exception $e) {
        throw new InvalidGeneral($e->getMessage());
    }
}
2

There are 2 answers

0
drewish On

The two things I'd check first are that the plan code and billing token are valid.

The other thing to check is that you've loaded our PHP libraries. You need to have this someplace in your code:

require_once('lib/recurly.php');
0
Ashish Chaturvedi On

Require the lib/recurly.php script and setup your authentication credentials:

<?php
require_once('lib/recurly.php');
// Required for the API
Recurly_Client::$subdomain = 'your-subdomain';
Recurly_Client::$apiKey = 'abcdef01234567890abcdef01234567890';
?>

It should be correct.Please re-check.