#burgershot240
1 messages ยท Page 1 of 1 (latest)
Hi ๐
Can you share a Customer ID for me to check
cus_OEpecP253nmnPM
This is test mode customer.
And when you retrieve this customer and simply echo $customer, what do you see?
I tried Laravel's Log::debug($customer) . Is that OK?
[2023-07-11 00:26:50] local.DEBUG: Stripe\Customer JSON: {
"id": "cus_OEpecP253nmnPM",
"object": "customer",
"address": {
"city": null,
"country": "JP",
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"balance": 0,
"created": 1689002808,
"currency": "jpy",
"default_source": null,
"delinquent": false,
"description": null,
"discount": null,
"email": "{email}",
"invoice_prefix": "07560AE5",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": [],
"name": "\u3042",
"next_invoice_sequence": 2,
"phone": null,
"preferred_locales": [
"ja"
],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
}
Hmmm... that is odd. I see the metadata on that Customer
Below is the full code of the Controller that recieve customer.subscription.created webhook.
// customer.subscription.created
case $stripeService::WEBHOOK_CUSTOMER_SUBSUCRIPTION_CREATED:
Log::debug($event->type . '(' . self::class. ':' .__LINE__ . ')');
$subscriptionData = $event->data->object;
$customerIdFromWebhook = $subscriptionData->customer;
Log::debug(self::class.':'.__LINE__ . ' customerId:'.$customerIdFromWebhook );
$stripeSecretKey = env('STRIPE_SECRET_KEY');
\Stripe\Stripe::setApiKey($stripeSecretKey);
Log::debug(self::class.':'.__LINE__);
// retrive customer data
$customer = \Stripe\Customer::retrieve($customerIdFromWebhook);
Log::debug($customer);
exit;
โ
Okay
Can you share the request ID for an API request where you retrieve the customer? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
This is it.
req_t6q3qEoROUJBUy
It has the metadata tho.. Is it my code's problem possibly.
Okay yes I can see it being returned there.
But retrieving the customer should return all the properties. metadata isn't a property that requires expansion to view.
I'm sorry. This is the exact request ID.
req_hjrzr5vP2BlLno
but that one doesn't show any responses...
Old one is POST method. I think Stripe shows GET log when I try to use \Stripe\Customer::retrieve().
We don't store logs of GET request payloads so that is expected
OKAY. So the metadata was empty at 2023-07-10 15:26:50 UTC when the GET request was made. The metadata was set at 2023-07-10 15:26:53 UTC
I got it. Thank you . I probably misunderstood that webhooks come my server customer.subscription.created webhook first when cusomer completes payment...
I set the metadata when checkout.session.completed webhook fired.
Is there any way to contain the metadata to customer.subscription.created webhook?
Should I try get the metadata at checkout.session.completed webhook ?
I see the metadata on that webhook's json.
Is there any way to contain the metadata to customer.subscription.created webhook?
This doesn't make sense to me. You decide when you update your Customer in your code. You can do it whenever you want.
when I received the webhook, there are not customer's metadata (empty array ) so that I thought I don't have any way to receive the metadata then.
but I think I could retrieve the metadata when I receive checkout.session.completed webhook.
Hello! I'm taking over and catching up...
It sounds like what you should do is listen for customer.updated Events so you can get the Event that fires when the Customer's metadata is updated: https://stripe.com/docs/api/events/types#event_types-customer.updated
Using the other Events you mentioned may not work in all cases because those fire before the metadata is set.
I see.
My app generates checkout link with metadata when customer starts checkout session on my aao to link checkout/stripe customer data and my app's database.
So when checkout session completed, I know that two events fire which is checkout.session.completed and customer.subscription.created.
When fired those events, I want to retrieve metadata of my app's user Id to link payment status between my app database and Stripe customer data.
From above info, I'm tried to ask like those questions.. Are there any misunderstanding yet..?
You mean customer.updated fires when above case?
I'm sorry for bad English though.
thank you.
Let me know if this is incorrect or not: as I understand it you have code listening for checkout.session.completed Events and when those Events happen you set metadata on the associated Customer. You then want to listen for an Event that will let you know that metadata was set on the Customer, correct?
as I understand it you have code listening for checkout.session.completed Events
That's correct.
when those Events happen you set metadata on the associated Customer. You then want to listen for an Event that will let you know that metadata was set on the Customer, correct?
Incorrect, I think.
I just want to get metadata when those events fired because I already set the metadata(== user ID of my app) when customer starts/generates checkout session from my app.
Okay, so what triggers you setting metadata on the Customer?
For link Customer data and my app's customer data when redirect after the payment succeed on stripe's modal.
No, sorry. You have code that's setting metdata on the Customer, right?
Oh, yes. I have the code below. (proper reply?)
$sessionParams = [
'line_items' => $lineItems,
'mode' => $mode,
// back to line
'success_url' => "https://line.me/R/oaMessage/{$line_account_id}/",
'cancel_url' => "https://line.me/R/oaMessage/{$line_account_id}/",
'automatic_tax' => [
'enabled' => true,
],
// here
'metadata' => [
'line_user_id' => $lineUserId,
],
];
$checkout_session = \Stripe\Checkout\Session::create($sessionParams);
return $checkout_session->url;
That's the code that creates a Checkout Session, but you're talking about metadata on a Customer. Where's the code that sets that?
// here
'metadata' => [
'line_user_id' => $lineUserId,
],
Is this invalid code to set customer's metadata when creating checkout session ?