#abidcastaneda

1 messages · Page 1 of 1 (latest)

naive tuskBOT
tardy plume
#

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

verbal prism
#

Ok, let me get them, thanks

#

Invoice ID: pi_3OG8feA5kJw9cqTj0em99OfE
Customer ID: cus_LwDDvcCklDLOpc

tardy plume
#

that is a PaymentIntent ID

#

not Invoice ID

verbal prism
#

Oh, sorry, hold on, let me look for it

tardy plume
#

this is the Invoice in_1OG7hPA5kJw9cqTj2O315u4Q

#

for that PaymentIntent

verbal prism
#

Ok, thanks, yes, I just saw it

tardy plume
#

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??

verbal prism
#

Um, the API documentation didn't make much sense to me, so I asked Google Bard to help me with the code ....

tardy plume
#

yeah pls don't ask Google Bard

#

it likely doesn't index Stripe API docs

verbal prism
#

sorry

tardy plume
#

out of curiosity

#

what did you ask Google Bard, the exact question?

#

want to try an experiment

verbal prism
#

Sure, hold on, let me see if I can send you the link with the whole chate

#

chat

naive tuskBOT
verbal prism
#

Oh wow, now both you guys are going to get a laugh at it? LOL

tardy plume
#

thanks for sharing and lol no I didn't ask to laugh about it, I'm geniunely curious on what it responds with

verbal prism
#

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;
}
}
}
}

tardy plume
#

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:

  1. Retrieve the customer's invoices using the List Customer Invoices API by passing the customer ID.
  2. Iterate over the list of invoices to find the most recent one.
  3. 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

verbal prism
#

Yes sure, I would like to acces the beta as long as that helps me achieve my goal

tardy plume
#

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

verbal prism
#

Ok, so I'll see this in the support section?

tardy plume
#

also there's Stripe Shell in your Stripe Docs that allows you to test out API requests and even create PHP code snippets

#

anywhere in a Docs page

verbal prism
#

Oh, sorry, ok

#

Ok, I'm going through the documentation to see if I can do it, thank you.