#atul
1 messages ยท Page 1 of 1 (latest)
Hey tarzan
Suppose i have product of 1000,
I offered a promocode of 33% percent discount.
So actual amount paid by customer is 670.
While showing payment history to my customer i need to show,
How much amount they actually paid(670), what was actual price(1000) and how much they got got as discount(330)
I am using paymentIntent for this
as i need to show all failed and successful trancsaction
how are you integrating with Stripe? are you using Checkout?
yes
then you need to list the Checkout Sessions instead
to get the discounts
on the PaymentIntent there's only the payment amount
Which API i need to listen to get all payment history
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!
This thread has been archived. If you need help with anything else please ask in #dev-help or contact Stripe Support: https://support.stripe.com/contact
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
I also need card details, how can be achieved
Can you elaborate?
I am using session checkout for payment
Suppose i have product of 1000,
I offered a promocode of 33% percent discount.
So actual amount paid by customer is 670.
While showing payment history to my customer i need to show,
How much amount they actually paid(670), what was actual price(1000) and how much they got got as discount(330)
I also need payment method details, how the payment was made by customer
We only return a subset of those details, on the Payment Method object available on the Payment Intent object: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
i also need detail regarding the discount and total amount paid
Sure, you should be able to get all this in a single API call by 'expanding' these fields: https://stripe.com/docs/api/expanding_objects
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So use the Checkout Session list endpoint, but also expand the payment_intent.payment_method fields
If you're using Checkout, you likely want this endpoint: https://stripe.com/docs/api/checkout/sessions/list
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
What language are you using?
node
checkout.sessions.list({
customer: customer_id,
expand: ['data.payment_intent.payment_method']
});
Yep, should work!
But i am not getting the payment method details
Which details? What's the JSON output of the payment_method hash?
I cann't see payment_method instead payment_method_type is available
Can you share some of the JSON
I suspect its a incomplete (unpaid) Checkout Session/Payment Intent and so there's no payment_method set
You can't filter sessions by status unfortunately, so you'll get all sessions for that customer irregardless of whether they were completed
{"object":"list","data":[{"id":"cs_test_b13lfHiRnOzocIBYgI7SLfqUZJ4ruQfA0KFSYF4vKuw1bmzbEYaDSH5ncm","object":"checkout.session","after_expiration":null,"allow_promotion_codes":true,"amount_subtotal":53988,"amount_total":36172,"automatic_tax":{"enabled":false,"status":null},"billing_address_collection":"auto","cancel_url":"https://yap-dev-v2-presenter.yapsody.com/admin/settings/billing?canceled=true","client_reference_id":null,"consent":null,"consent_collection":null,"created":1667393270,"currency":"usd","customer":"cus_Mj8dt08HLP6Q1V","customer_creation":null,"customer_details":{"address":{"city":null,"country":"US","line1":null,"line2":null,"postal_code":"99508","state":null},"email":"atul.singh@yapsody.com","name":"Atul singh","phone":null,"tax_exempt":"none","tax_ids":[]},"customer_email":null,"expires_at":1667479670,"livemode":false,"locale":null,"metadata":{"account_id":"1003","operation":"create_subscription","plan_id":"20026bf8-7d76-4294-876e-81ed8672f59e","product_id":"7","whitelabel_id":"1"},"mode":"subscription","payment_intent":null,"payment_link":null,"payment_method_collection":"always","payment_method_options":null,"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":"sub_1LzgMiHxaKwf0RtdVyvLAgAC","success_url":"https://yap-dev-v2-presenter.yapsody.com/admin/settings/billing?success=true&session_id={CHECKOUT_SESSION_ID}","total_details":{"amount_discount":17816,"amount_shipping":0,"amount_tax":0},"url":null}],"has_more":false,"url":"/v1/checkout/sessions"}
Ah, it's a mode: 'subscription' session. payment_intent won't be set
You need to expand subscription.default_payment_method
ok let me check
just to confirm i need to use checkout API and expand subscription.default_payment_method
Hello ๐
Taking over as ynnoj needs to step away soon.
just to confirm i need to use checkout API and expand subscription.default_payment_method
yes that's correct. It should expand the whole object instead of just returning
"subscription":"sub_1LzgMiHxaKwf0RtdVyvLAgAC"in the response.
And in response i will get subscription
Yes as part of the checkout object
and from subscription i need to fetch default_payment_method
and this is alsway going to contain card orbject??
it would have a PaymentMethod object
https://stripe.com/docs/api/subscriptions/object#subscription_object-default_payment_method
yes I agree
inside default-payment-method
i have key named 'card', is this going to be always present ??
Yes it should be present if its a card payment method
https://stripe.com/docs/api/payment_methods/object#payment_method_object-card
can you confirm what else can be present there ??
instead of card what else can be present there
I require is to fetch the payment history, and also show from which mode(payment method) it was paid.
It can have other hashes depending on what type of payment method was used.
You can look at the type of the Payment Method object in order to identify what kind was it
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.