Search code examples
phpmysqlchargebee

ChargeBee - PHP create subscription breaks PHP loading the page


Working on a Chargebee integration, using their suggest PHP library.

I have the include statement at the top of the page, to include the library. And I set the environment variables with test server information copy-pasted from the control panel.

No matter what I try, when I use their sample code, my page load breaks and I get a white screen. Without this block of code, the page loads fine and all dbase calls works perfectly.

Is there more to know about the Chargebee library that I'm not catching?

        (in the top of the php)

                include("/app/includes/chargebee-php-master/lib/ChargeBee.php");

                ChargeBee_Environment::configure("SERVERNAME-test",
                  "test_KEYFROMCONTROLPANEL");


        (inline code in a function)

              $result = ChargeBee_Subscription::create(array(
                      "planId" => "pond_ripple", 
                      "customer" => array(
                        "email" => "[email protected]", 
                        "firstName" => "John", 
                        "lastName" => "Doe", 
                        "phone" => "+1-949-999-9999"
                      ), 
                      "billing_address" => array(
                        "firstName" => "John", 
                        "lastName" => "Doe", 
                        "line1" => "PO Box 9999", 
                        "city" => "Walnut", 
                        "state" => "CA", 
                        "zip" => "91789", 
                        "country" => "US"
                      )
                                      ));
                    $subscription = $result->subscription();
                    $customer = $result->customer();
                    $card = $result->card();
                    $invoice = $result->invoice();


                $sampleString = $customer["id"];

Solution

  • Is your include path correct?

    include("/app/includes/chargebee-php-master/lib/ChargeBee.php");
    

    Can you crosscheck whether it starts from a base directory? ie. /app/includes/chargebee-php-master/lib/ChargeBee.php or is it relative? i.e app/includes/chargebee-php-master/lib/ChargeBee.php

    If your path is right (full path), can you provide the error log to debug further? Also you need to access ChargeBee customer object as $customer->id and not as an array.