API returns json

Hello so i tried to use API to retrieve a test customer and converted into valid json format but the json it shows me was invalid as well as the data it shows me was invalid/hard to read so is there any way you guys can clean it off a bit or give me an example code to help me?


Hello Zhiyan,


Sorry for the delay in getting back to you. Could you copy-paste the converted information here to check on our end? 


Regards,
Shriram V
Chargebee 

i just directly print out custom using print_r function and the data below is what it returned


ChargeBee_Customer Object ( [allowed:protected] => Array ( [0] => id [1] => firstName [2] => lastName [3] => email [4] => phone [5] => company [6] => vatNumber [7] => autoCollection [8] => netTermDays [9] => allowDirectDebit [10] => createdAt [11] => createdFromIp [12] => taxability [13] => entityCode [14] => exemptNumber [15] => resourceVersion [16] => updatedAt [17] => locale [18] => consolidatedInvoicing [19] => billingDate [20] => billingDateMode [21] => billingDayOfWeek [22] => billingDayOfWeekMode [23] => cardStatus [24] => fraudFlag [25] => primaryPaymentSourceId [26] => backupPaymentSourceId [27] => billingAddress [28] => referralUrls [29] => contacts [30] => paymentMethod [31] => invoiceNotes [32] => preferredCurrencyCode [33] => promotionalCredits [34] => unbilledCharges [35] => refundableCredits [36] => excessPayments [37] => balances [38] => metaData [39] => deleted [40] => registeredForGst ) [_values:protected] => Array ( [id] => anni114 [first_name] => Anni [last_name] => Chen [email] => anni114@supermail.cf [auto_collection] => off [net_term_days] => 0 [allow_direct_debit] => [created_at] => 1515706017 [taxability] => taxable [updated_at] => 1516320819 [locale] => en-US [resource_version] => 1516320819302 [deleted] => [object] => customer [card_status] => no_card [promotional_credits] => 0 [refundable_credits] => 0 [excess_payments] => 0 [unbilled_charges] => 0 [preferred_currency_code] => USD ) [_subTypes:protected] => Array ( [billing_address] => ChargeBee_CustomerBillingAddress [referral_urls] => ChargeBee_CustomerReferralUrl [contacts] => ChargeBee_CustomerContact [payment_method] => ChargeBee_CustomerPaymentMethod [balances] => ChargeBee_CustomerBalance ) [_dependantTypes:protected] => Array ( ) [_data:protected] => Array ( [id] => anni114 [firstName] => Anni [lastName] => Chen [email] => anni114@supermail.cf [autoCollection] => off [netTermDays] => 0 [allowDirectDebit] => [createdAt] => 1515706017 [taxability] => taxable [updatedAt] => 1516320819 [locale] => en-US [resourceVersion] => 1516320819302 [deleted] => [object] => customer [cardStatus] => no_card [promotionalCredits] => 0 [refundableCredits] => 0 [excessPayments] => 0 [unbilledCharges] => 0 [preferredCurrencyCode] => USD ) )

Hey Zhiyan,


Sorry for the delay caused!


Could you look into the following sample codes for fetching subscriptions an try the similar code for retrieving the customer?


  • print_r($subscription->id); // To fetch a direct subscription attribute say 'id'
  • print_r($subscription->shippingAddress->country); //To fetch subscription subresource attribute say Shipping Address's 'country'
  • print_r($subscription->addons[0]->id); //To fetch subscription list subresource attribute say first Addon's 'id'


Hope this helps


Let us know if you have any other queries. 

Login or Signup to post a comment
×