Dates in stripe customer properties - date-format

I am not sure what format the current_period_start current_period_end fields are in when stripe returns me a customer object. I am trying to show my user when their next billing date is after they have subscribed to one of my plans. How are we supposed to parse these values?

Related

How to get the Twitter follower count of a user on a given date, or at the time of a tweet?

I have access to Twitter API for Academic Research, and I'd like to get the follower count on a given date of a user, or at the time of a tweet.
The doc mentions that "This fields parameter enables you to select which specific user fields will deliver in each returned Tweet.", so I assumed that by adding public_metrics to the users.field, the number of followers can be seen in each returned Tweet, however, in each returned Tweet, I can only see user_id. https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference.
Is it even possible to achieve what I want with Twitter API for Academic Research? Is there any other approach to make it?
Thank you so much.
You cannot get the follower count on a specific date; it will always be the count at the time you make the API call.
You may need to add expansions to your API call in order to receive the values you are trying to pull out.

How to get details (unit, quantity, price) from XTRF customer invoice API?

We are using the Customer Invoice Api, but we can'n get the details of the jobs, as unit, quantity and price. Only the "totalAgreed", that is the amount already calculated (quantity * price) of the job. How can we recovery this information?
Project.json and invoice.json do not brint this information.
You can use the Browser API from XTRF. This way, you first create a view within XTRF where all the information is present. Then you execute the Browser API with the Customer Invoice ID as a filter.

How can I get the reports by campaign and with date

I am getting the reports from the Adwords API. The formate is CampaignID, AdgroupID, Impressions, Clicks, Date.
I want to get the reports for only one campaign and the reports records should be ordered with date.
At least is there a way to get the reports for a particular campaign only.
You can pass the campaign id as a predicate (a filter) to get data from just one campaign.

Creating a subscription in Stripe - I'm confused

I use stripe subscriptions for my users with one plan for, say, $10 per month for 100 API requests and that's a standard price. However, if the user has used 150 API requests, I charge them $10 + $3. For 200 and more requests it's $10 + $7.
Say, I've subscribed the user on October 9th. On November 9th the webhook event invoice.created will be called by stripe. So if the user has used 150 API requests, I have to add $3 more to the basic price (I can do that only within 1 hours according to Stripe documentation https://support.stripe.com/questions/metered-subscription-billing).
if even.type == 'invoice.created'
Stripe::InvoiceItem.create(
customer: stripe_customer_id,
invoice: event.data.object.invoice
amount: 300,
currency: 'usd',
description: 'additional price'
)
The questions:
Will the event invoice.created, indeed, be called on November 9th for the first time?
Will that additional price of $3 be added to the current invoice of $10 for October 9th-November 9th or will it be added to the future invoice for November 9th-December 9th? From the documentation it's not clear.
How do I add metadata to the original invoice of $10? I can add metadata to the additional invoice but in case the user has used less 100 API request I don't have to create the additional invoice at all, so I can't rely to the additional invoice.
It says
Create any invoice items before your customer is subscribed to the
plan, and then create the subscription via an update customer
subscription call.
but I subscribe the user once and forever on October 9th! How can I create an InvoiceItem before or on that (on October 9th) date if one month hasn't passed yet, and thus it's not known how many API calls the user makes (on October 9th the user has made, obviously, zero API calls)? I can only create InvoiceItems in 30 days because it's when I know how much to charge them on top on the $10! On October 9th I don't know that. Don't I understand anything?
Each time an invoice is created, you get the event invoice.created on your webhook. So when you subscribe a customer to a monthly plan on the 9th of November, you will get this event on the 9th of November, on the 9th of December, on the 9th of January, etc.
The first invoice for a subscription (generated when you create a subscription) is always closed immediately, so it is not possible to add an invoice item at that point. If that's something you want to do (for a setup fee for example) you need to create the invoice item before creating the subscription. That way it would get added automatically to the first invoice created when subscribing your customer.
In your case, you want to add fees to the next invoice based on the number of API requests your customer made during the month that just ended. So in the invoice.created event you need to detect whether it's a new month starting or the first one. If it's a new month, you then need to decide whether you have to add an Invoice Item to the user or not (based on the number of API requests).
You can't add metadata to the previous invoice from the month before. You just need to add the invoice item to the current invoice (for the month that is starting) and put a description indicating that the extra line item is for the consumption for the previous month.

jBilling Error: An Invoice could not be generated

When I want to generate an invoice to an order following error is displayed:
"There has been an error:
An Invoice could not be generated. The purchase order does not have any applicable periods to be invoiced.
Verify the data of the purchase order or contact customer service to review your business rules."
I disabled pro-rating and I set following settings to plug-ins:
Invoice presentation
com.sapienter.jbilling.server.pluggableTask.InvoiceCompositionTask
Billing process: order periods calculation
com.sapienter.jbilling.server.pluggableTask.OrderPeriodTask
It is not working yet. Any Idea? help me quickly please.
Thanks a lot.
when you create order, you will see period filed on order screen which is one time or monthly.
select one time and try to create order. if you select monthly then only one invoice will create for that order because it is recurring order and then next bill set to next month.
if you want to create invoice again for same order then try to manage billing proces to next invoice date or update next bill date to curent month in purchase order table.

Resources