#pareil_quotepdf-php

1 messages Ā· Page 1 of 1 (latest)

main haloBOT
#

šŸ‘‹ Welcome to your new thread!

ā±ļø We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!

šŸ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1212545545483321344

šŸ“ Have more to share? You can add more detail below, including code, screenshots, videos, etc.

ā²ļø We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question. Thank you for your patience!

crimson sluiceBOT
rose jungle
#

@eternal stump can you give me a Quote id for me to look at?

#

pareil_quotepdf-php

eternal stump
#

Its status is "open".

rose jungle
#

ack, looking, this is a pretty weird code example with that function in the middle

#

Connect is not in beta, it's been in production for 11+ years

#

Step 1: try without Connect though. Create a Quote on your own account and try to download the PDF first to see what happens

eternal stump
#

I Try

#

I am in Test mode, but when I try to create a quote, it does not display the clients from the connected account on which I am creating the quote, but rather those from my personal account, the same goes for the products.

rose jungle
#

it's just to debug so it doesn't matter. Use information from your own account (Customer, Price and Product, etc.) so that you can debug this

eternal stump
#

Sry

#

Sorry, I realized that the quote was created on my personal Stripe account instead of the Connect Plus account, even though I requested it to be done on the Connect Plus account.

rose jungle
#

The code example in our API Reference seems wrong though. I think what you want is this: ```$quotePdf = $stripe->quotes->pdf(
$quote->id,
function ($chunk) use (&$output) {
$output .= $chunk;
}
);

file_put_contents("./test.pdf", $output, FILE_APPEND);```

#

that works for me locally

eternal stump
#

With stripe connect ? Doesn't work for me

#
                $quote->stripe_quote_id,
                function ($chunk) use (&$output) {
                    $output .= $chunk;
                },[], ['stripe_account' => auth()->user()->stripe_connected_account_id]
            );

            file_put_contents("./test.pdf", $output, FILE_APPEND);
#

When I go through the dashboard, everything works correctly; it's when I use the API that it doesn't work.

#

What I don't understand is that I feel like the request is executing fine because the page takes time to load (the time to retrieve the API response).

rose jungle
#

I just tried that exact code and it works fine for me

#

so I think you should add clear debugging logs before/after those parts to track down what the problem is

#

You need the empty array. And then the "nothing downloads" you can add clear logs to figure out what's happening. Share exact final code with exact logs so that I can see what you are doing

eternal stump
#

What else can I implement to retrieve logs?

rose jungle
#

You are the developer, you write the code here. what you need to do is add a clear log before the PDF method and right after to understand what happened

#

what does that mean "no log return". You clearly added logs before and after and they appear?

#

Stripe will not log anything

#

you removed the code you shared

#

But my point was: now that you are certain the PDF call works (since you saw the log after) the next step is to log what is inside $output

eternal stump
#

I try when i dd($output) i have :
$quotePdf = $stripe->quotes->pdf(
$quote->stripe_quote_id,
function ($chunk) use (&$output) {
$output .= $chunk;
dd($output);
},
[],
['stripe_account' => auth()->user()->stripe_connected_account_id]
);

rose jungle
#

I don't know what that means. You said "I have" and then dump your PHP code

eternal stump
#
%PDF-1.4
\n
1 0 obj
\n
<<
\n
/Title (ā–  )
\n
/Creator (ā–  
\x00
w
\x00
k
\x00
h
\x00
t
\x00
m
\x00
l
\x00
t
\x00
o
\x00
p
\x00
d
\x00
f
\x00
\x00
0
\x00
.
\x00
1
 ā–¶
rose jungle
#

perfct

#

so clearly you have something in $output and it's working fine!

#

it's a "binary stream" so you have to now write that cleanly to a file on your file system

eternal stump
#

It's work thank !

#

The code

rose jungle
#

Amazing!

#

it's definitely a weird pattern in our PHP SDK partly because handling file streams in PHP is a bit harder

#

I hope we improve this in the future to just return a raw payload instad of this callback approach 😦

eternal stump
#

I understand, the main thing is that it works. Thanks again, have a great day!