#devparry

1 messages · Page 1 of 1 (latest)

limber mistBOT
clever haven
#

Hello, apologies for the delay. There will be an initial invoice for the free trial that gets created along with the subscription and then there will be a paid invoice when the subscription renews

#

Are you running in to some behavior with this that you are having trouble figuring out?

charred crest
#

This is what i am getting right now so according to this no invoice will generate ?

clever haven
#

Can you tell me more about what you are trying to do here?

charred crest
#

okay, we have an admin dashboard under which we have to display a list of upcoming invoices of all the subscriptions. who's status is not cancel yet so now we have approx 100 subscriptions who's status is trialing but we dnt get any data under it.

#

so based on the screen-shot most of subscriptions will expire next year, so I want to know if trailing subscriptions don't have any upcoming invoice till next year I'll ignore the trialing subscription and get active status related subscriptions only from my local database.

clever haven
#

Are you using the API to get the data for this dashboard?

clever haven
charred crest
charred crest
# clever haven Are you using the API to get the data for this dashboard?

first, we get a list of subscriptions form our local database after that with the help of stripe API code

$subscription = \Stripe\Invoice::upcoming( ['customer' => $stripe_customer_id, ] ); $ReturnDueInvoiceData['data'] = $subscription->jsonSerialize();

we get upcoming invoices based on coustomer_id which we store under local db subscription table

#

now we get issue

#

which is: if record is more the 200 then the page hang becz \Stripe\Invoice::upcoming() function call is under loop which means each time system hit to \Stripe\Invoice::upcoming() API and page become too slow or sometimes it hangs

do you have any solution on how we can increase the speed of the page?

clever haven
#

Can you explain more of what you mean by "if record is more the 200 "? Are you saying that something loops if there are too many invoice items?

charred crest
#

no

#

let me explain again

#

under the dashboard, we have to display a list of upcoming invoices only.

  • So first we get all the records from our local database where subscription status is active
  • now we have a list of 200 records so we run for-each loop on the subscription list and we find upcoming invoices by using under mentioned code :

$subscription = \Stripe\Invoice::upcoming( ['customer' => $stripe_customer_id, ] ); $ReturnDueInvoiceData['data'] = $subscription->jsonSerialize();

now if we get invoice data returned by Stripe API we put the invoice value into a new array.

and print a list of the new array under the dashboard.

but now for 200 records, it takes too much time to display data on the dashboard.

clever haven
#

Ah gotcha, not sure if there is a good way to speed that up. that upcoming invoice call needs to be called for each subscription and I am guessing that making that call 200 times is the bulk of your load time here.

#

Maybe you can try making that call for each invoice beforehand and store the upcoming invoice so that when you load the page you are just loading the data that you already have instead of retrieving new data?

limber mistBOT