#abidcastaneda
1 messages · Page 1 of 1 (latest)
hello, so let's start here
and they have just payed one on november 25th
let's look at the source of truth
grab the Customer ID and the Invoice ID for that and share here
and we can work backwards from that
Ok, let me get them, thanks
Invoice ID: pi_3OG8feA5kJw9cqTj0em99OfE
Customer ID: cus_LwDDvcCklDLOpc
Oh, sorry, hold on, let me look for it
Ok, thanks, yes, I just saw it
ok cool so we've verified that that Invoice was associated with that Customer
cus_LwDDvcCklDLOpc and in_1OG7hPA5kJw9cqTj2O315u4Q
ah I see the issue
// Retrieve the latest invoice
$latestInvoice = $customer->latest_invoice;
where are you getting this from??
https://stripe.com/docs/api/customers/object the Customer object has no such field
Um, the API documentation didn't make much sense to me, so I asked Google Bard to help me with the code ....
sorry
out of curiosity
what did you ask Google Bard, the exact question?
want to try an experiment
Sure, hold on, let me see if I can send you the link with the whole chate
chat
Here you go: https://g.co/bard/share/4a40a3ce1ba8
Oh wow, now both you guys are going to get a laugh at it? LOL
thanks for sharing and lol no I didn't ask to laugh about it, I'm geniunely curious on what it responds with
lol, ok
I also got with the guys from support from PHPRUnner, since, I am making this web application with it and they sent me this piece of code, but didn't know how to customize it to fit my needs:
$email - user email
$skey - stripe secret key
$productname - product name
$isSubscription = false;
$response = runner_http_request("https://api.stripe.com/v1/search", "query=email:'".$email."'", "GET",
array("Authorization" => "Bearer ".$skey ,"content-type"=>"application/x-www-form-urlencoded"));
$result_secret = my_json_decode($response["content"]);
foreach($result_secret["data"] as $customer){
if(isset($customer["subscriptions"])){
foreach($customer["subscriptions"]["data"] as $subscriper){
$prodid = $subscriper["plan"]["product"];
$response2 = runner_http_request("https://api.stripe.com/v1/products/".$prodid,"", "GET",
array("Authorization" => "Bearer ".$skey ,"content-type"=>"application/x-www-form-urlencoded"));
$product = my_json_decode($response2["content"])["name"];
if(strtolower($product) == strtolower($productname) && (strtolower($subscriper["status"]) == "trialing" || strtolower($subscriper["status"]) == "active")){
$isSubscription = true;
}
}
}
}
so the reason I asked was
To check the payment status of the last invoice paid by a customer, you can retrieve the customer's invoices using the List Customer Invoices API. You can then iterate through the list of invoices and find the most recent one. Within each invoice, the status field will indicate the payment status, such as "paid" or "unpaid".
Here are the steps you can follow:
- Retrieve the customer's invoices using the List Customer Invoices API by passing the customer ID.
- Iterate over the list of invoices to find the most recent one.
- Check the status field of the invoice to determine the payment status.
For more information on retrieving invoices and checking their payment status, you can refer to the Invoices API documentation provided by Stripe: https://stripe.com/docs/api/invoices
that's roughly the answer from a beta project at Stripe that uses an LLM across Stripe Docs and API reference
FWIW that is the correct answer
would you like access to the beta?
also you won't need to iterate over the Invoices in the list as the most recent one will be the first one, they are reverse chronologically returned from the API
Yes sure, I would like to acces the beta as long as that helps me achieve my goal
sure let me figure that out internally, you'll see it on the Search box above, there's the "Get Answers from Docs AI" option once you write your question. It isn't converstational like Bard or ChatGPT but gives one off answers well since it has Stripe Docs injested
Ok, so I'll see this in the support section?
also there's Stripe Shell in your Stripe Docs that allows you to test out API requests and even create PHP code snippets
no, not in support, the search bar in stripe.com/docs
anywhere in a Docs page