#Reinhardt

1 messages · Page 1 of 1 (latest)

low parcelBOT
fading pecan
#

Do you see this with other calls/objects or just the customer?

patent root
#

Just this Customer object

#

and oddly enough just one Customer when others work perfectly fine

fading pecan
low parcelBOT
patent root
#

well luckily I just found the Request ID for the weird Customer
req_IRKD6Dp0FebtDz

#

I'll find one for a successful one

leaden crypt
#

Thank you, once i have the other request id, I can help further debug this.

patent root
#

ok here is another
req_F322FymK5oTmKS

#

however that one actually. has the bug intermittently

#

I'll find another just in case

leaden crypt
#

From looking at the two requests I see that you're using the same php and SDK version. Since we don't log what is returned on these GET requests I was unable to see the issue.

#

When you say intermittent, how often does this happen?

#

Has it just started happening? Are you able to share a screenshot of when this happens vs. when it's working?

patent root
#

hmmm ok it is no longer intermittent

#

it seems to be an issue any time I do the Customer Retrieval

#

this is the error I get


Mar 21 19:28:29 3.99.252.237 logger [2023-03-22 02:28:28] staging.ERROR: Attempt to read property "id" on string {"userId":136,"exception":"[object] (ErrorException(code: 0): Attempt to read property \"id\" on string at /var/task/src/Domains/Payments/Doyo/Actions/AddCustomerPaymentMethodAction.php:60)
#

And when logging the API call I get this:

#

"Stripe\\Customer JSON: {
\"id\": \"cus_NZ1yJR4jqu193z\",
\"object\": \"customer\",
\"address\": null,
\"balance\": 0,
\"created\": 1679361753,
\"currency\": null,
\"default_source\": null,
\"delinquent\": false,
\"description\": null,
\"discount\": null,
\"email\": \"eden+client1@jetpack.to\",
\"invoice_prefix\": \"0249EABF\",
\"invoice_settings\": {
\"custom_fields\": null,
\"default_payment_method\": null,
\"footer\": null,
\"rendering_options\": null
},
\"livemode\": false,
\"metadata\": [],
\"name\": \"Eden Client\",
\"next_invoice_sequence\": 1,
\"phone\": null,
\"preferred_locales\": [],
\"shipping\": null,
\"tax_exempt\": \"none\",
\"test_clock\": null
}"} 
#

and a json_decode of this just results to a NULL

frank siren
#

@patent root can you share more code? There's no reason at all for you to use json_decode when using stripe-php

#

Like ultimately, you can do this

$stripe = new \Stripe\StripeClient('sk_test_123');
$customer = $stripe->customers->retrieve('cus_ABC', []);
echo $customer->id;```
So I'd recommend trying that first. I assume the error is not where you think it is
patent root
#

that is exactly where the error is

#

the error the log tells me,
shows up when I do

'customer' => $stripeCustomer->id,

frank siren
#

Sure but that's one line of code. Where is $stripeCustomer coming from? Please share your exact code surrounding that line

patent root
#

ok

#
$stripeCustomer = Stripe::client()->customers->retrieve($user->stripe_customer_id, $params);
#

where Stripe::client() sets the API key in the background

frank siren
#

Sure, then take that, and switch to my example, hardcode the key, hardcode the customer id, log the response, see what happens

patent root
#

ok

frank siren
#

let me know what you get (and share the exact code, except hide your API key)

patent root
#

That seems to work in isolation

#

is there any settings in Laravel that might prevent this from working as expected?

frank siren
#

No, my guess is that the code that is erroring is not what you think really

#

I'm fairly confident that if you change your code to

echo $stripeCustomer->id;``` that code just works fine. So the problem is somewhere else in your code, but it wouldn't be what our library returns at least
patent root
#

Thanks unfortunately. that still doesn't work for some reason.
But I have thought of a work around at this point

#

thanks for your time!

frank siren
#

I'm really confused how this could not work unless Stripe::client() is not what you think it is and is a Laravel only thing