#baby561

1 messages · Page 1 of 1 (latest)

gilded snowBOT
rigid turtle
#

TOBY!!!!!

#

my day is saved

#

this is the output, not sure why it didnt get carried over::

payment_web_hook_controller()
session:
{
"after_expiration": null,
"allow_promotion_codes": null,
"amount_subtotal": 5000,
"amount_total": 5000,
"automatic_tax": {
"enabled": false,
"status": null
},
"billing_address_collection": null,
"cancel_url": "http://localhost:3000/cancel",
"client_reference_id": null,
"consent": null,
"consent_collection": null,
"created": 1693315355,
"currency": "usd",
"currency_conversion": null,
"custom_fields": [],
"custom_text": {
"shipping_address": null,
"submit": null
},
"customer": null,
"customer_creation": null,
"customer_details": {
"address": {
"city": null,
"country": "US",
"line1": null,
"line2": null,
"postal_code": "33418",
"state": null
},
"email": "jcasasmail@gmail.com",
"name": "juan casas",
"phone": null,
"tax_exempt": "none",
"tax_ids": []
},
"customer_email": null,
"expires_at": 1693401755,
"id": "cs_test_a16shrrnhRSYEquptYwAYAo5si0tZNgWgsU4DCzyznhaNLVy0oYc6IFUQH",
"invoice": null,
"invoice_creation": null,
"livemode": false,
"locale": null,
"metadata": {},
"mode": "payment",
"object": "checkout.session",
"payment_intent": "pi_3NkRsNDwE30yzzvS2rO6mt8w",
"payment_link": null,
"payment_method_collection": null,
"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:3000/success",
"total_details": {
"amount_discount": 0,
"amount_shipping": 0,
"amount_tax": 0
},
"url": null
}

final wolf
#

Hello again 👋 taking a quick look at the session

rigid turtle
#

i saved some meta data when i created the user (user id in my system).

i can do the look up for the customer with the email "jcasasmail@gmail.com" but i dont thing that is best practices

final wolf
#

Can you tell me a bit more about how you're creating these Checkout Sessions? Are they coming a Payment Link or a Pricing Table?

rigid turtle
#

this is the react code::
async function handlePurchase(stripe_price_id) {
const stripe = await getStripe();
const { error } = await stripe.redirectToCheckout({
lineItems: [
{
price: stripe_price_id,
quantity: 1,
},
],
mode: 'payment',
successUrl: http://localhost:3000/success,
cancelUrl: http://localhost:3000/cancel,
// customerEmail: 'customer@email.com',
});
console.warn(error.message);
}

i guess i am redirecting to checkout.
the goal is to have the customer purchase tokens that are used in my system.
so when the transaction goes through, in my flask app i catch that completed session and credit the user.

let me know if that makes sense

final wolf
#

Ah, that's why I didn't recognize how those were being created, you're doing it with client-side code using a deprecated function. If this is a new integration you're working on building, then I would recommend implementing this differently. I would instead recommend you create the Checkout Session server-side, where you can provide the ID of the Customer object you already created so the Checkout Session will be associated with that Customer, and then direct your customer to the url generated when the session is created. The guide here walks through that flow:
https://stripe.com/docs/payments/accept-a-payment
the one change I would recommend making is the inclusion of the customer parameter and passing it the ID of the Customer object you created previously:
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer