#OzzieNick
1 messages ยท Page 1 of 1 (latest)
sure the dataObject is what is received from Stripes Check out:
{
"id": "evt_1LkltDJbORVRPNqJZS0DPyBy",
"object": "event",
"api_version": "2022-08-01",
"created": 1663839615,
"data": {
"object": {
"id": "cs_live_b1odqNRnwPu6E6149ggaPQVRT7hmc98CpVxAeY73pGPG8XgYyvpicZjmIJ",
"object": "checkout.session",
"after_expiration": null,
"allow_promotion_codes": true,
"amount_subtotal": 7000,
"amount_total": 7000,
"automatic_tax": {
"enabled": false,
"status": null
},
"billing_address_collection": "required",
"cancel_url":
"http://localhost:4200/entrant/",
"client_reference_id": null,
"consent": null,
"consent_collection": null,
"currency": "aud",
"customer": "cus_MTj8Vtdpteoxgf",
"customer_creation": null,
"customer_details": {
"address": {
"city": "Seville Grove",
"country": "AU",
"line1": "13 Morgan Road",
"line2": null,
"postal_code": "6112",
"state": "WA"
},
"email": "mnc12004@gmail.com",
"name": "Michael Cockinos Redhot Internet Solut",
"phone": null,
"tax_exempt": "none",
"tax_ids": [
]
},
"customer_email": null,
"expires_at": 1663925965,
"livemode": true,
"locale": "auto",
"metadata": {
},
"mode": "payment",
"payment_intent": "pi_3LklsQJbORVRPNqJ0kAk9lov",
"payment_link": null,
"payment_method_collection": "always",
"payment_method_options": {
},
"payment_method_types": [
"card"
],
"payment_status": "paid",
"phone_number_collection": {
"enabled": false
},
"recovered_from": null,
"setup_intent": null,
"shipping_address_collection": null,
"shipping_cost": null,
"shipping_details": null,
"shipping_options": [
],
"status": "complete",
"submit_type": null,
"subscription": null,
"success_url": "http://localhost:4200/entrant/",
"total_details": {
"amount_discount": 0,
"amount_shipping": 0,
"amount_tax": 0
},
"url": null
}
},
"livemode": true,
"pending_webhooks": 3,
"request": {
"id": null,
"idempotency_key": null
},
"type": "checkout.session.completed"
}
there's no such field as payment_intent_data in a CheckoutSession object(which is what event.data.object is), so that's all totally expected and is why you get undefined.
there's a parameter you can pass to the Create CheckoutSession API called payment_intent_data but it's not a field that's returned, as it's not documented in the API reference at https://stripe.com/docs/api/checkout/sessions/object.
So I'm unclear what you were trying to do.
Hmmm. Yet this works on another unrelated site.
I don't think it could, event.data.object.payment_intent_data could never not be undefined.
maybe your other site has that Firebase ignoreUndefinedProperties config enabled and this one doesn't, for example. But from the Stripe side, there's no such thing as that field you're trying to access
I can show you in the working site (Still under developmet)
I don't need that really. Are you unblocked?
Unblocked where?
as in do you have an understanding of how to go from here to resolve your issue or can I provide further support?
I just did a test purchase on the working site and it worked as expected.
I'm stuck on this one and can't figure out why it works for one but not the other.
I'm stuck on this one and can't figure out why it works for one but not the other.
maybe your other site has that Firebase ignoreUndefinedProperties config enabled and this one doesn't, for example
my suggestion is to edit your code to remove payment_intent_data: dataObject.payment_intent_data and maybe change the Firebase model, that line makes no sense and there is no such field in the Stripe object that you're accessing, so you're always saving null/undefined from that line.
This is the log from the working cloudfunction:
Stripe Order: {"id":"cs_test_b1Lrniq5eUurSteTK2oFovrUD7f22w3If2DpFPn81Im8j8Mjhler0O9Z5E","object":"checkout.session","after_expiration":null,"allow_promotion_codes":true,"amount_subtotal":5000,"amount_total":5000,"automatic_tax":{"enabled":false,"status":null},"billing_address_collection":"required","cancel_url":"https://pcsmc.redhot.com.au/members/","client_reference_id":null,"consent":null,"consent_collection":null,"currency":"aud","customer":"cus_LwJkJHQ3XOD6VN","customer_creation":null,"customer_details":{"address":{"city":"Perth","country":"AU","line1":"123 The STreet","line2":"","postal_code":"6000","state":"WA"},"email":"michael.cockinos@bigpond.com","name":"Test Card","phone":null,"tax_exempt":"none","tax_ids":[]},"customer_email":null,"expires_at":1663931347,"livemode":false,"locale":"auto","metadata":{},"mode":"payment","payment_intent":"pi_3LknHEJm0IUyWAp01MQwGa32","payment_link":null,"payment_method_collection":"always","payment_method_options":{},"payment_method_types":["card"],"payment_status":"paid","phone_number_collection":{"enabled":false},"recovered_from":null,"setup_intent":null,"shipping":null,"shipping_address_collection":null,"shipping_options":[],"shipping_rate":null,"status":"complete","submit_type":null,"subscription":null,"success_url":"https://pcsmc.redhot.com.au/members/","total_details":{"amount_discount":0,"amount_shipping":0,"amount_tax":
ok, and what about it?
its the same code.
like that clearly shows you there is no such thing as payment_intent_data in the object(as I've been saying), so it should be clear why you get the error message you posted in your question
what can I clarify that is not already clear?
OK. I'm not trying to get under your skin mate. I really appreciate your help.
I will get both files side by side and see where the difference is, although, there shouldn't be any as I copied the function from one (working) to the other and expected them to work.
Wirher way I will let the thread know how I go.
Thanks again
sorry but I don't think you're understanding me
like, your code is wrong. You try to access this field that doesn't exist
maybe it works on one server because you have a configuration in Firestore to allow undefined variables
and maybe your other server doesn't have that config
so maybe that's the issue and something you can look into. I don't know how I can be clearer, the error message you got from the function is super clear, and I explained to you why you get an undefined variable from the Stripe side.
Yes I do. I can't explain how one works and the other doesn't is what I am trying to say too.
I mentioned three times a potential reason
and it's in your original error message
. If you want to ignore undefined values, enable ignoreUndefinedProperties.
Hmmm that may be a point. one is on a live sever the other is in dev on my local machine.