#atul

1 messages ยท Page 1 of 1 (latest)

bright tapirBOT
plush crow
#

Hey tarzan

solid olive
#

๐Ÿ‘‹ happy to help

#

what APIs are you using?

plush crow
#

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

solid olive
#

how are you integrating with Stripe? are you using Checkout?

plush crow
#

yes

solid olive
#

then you need to list the Checkout Sessions instead

#

to get the discounts

#

on the PaymentIntent there's only the payment amount

plush crow
#

Which API i need to listen to get all payment history

solid olive
river lodge
#

Hey, taking over here. Let me know if there's any follow-up Qs I can answer!

gilded meteorBOT
#

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

river lodge
#

I also need card details, how can be achieved
Can you elaborate?

plush crow
#

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

river lodge
plush crow
#

i also need detail regarding the discount and total amount paid

river lodge
#

So use the Checkout Session list endpoint, but also expand the payment_intent.payment_method fields

plush crow
#

sorry

#

I am confussed which api to use and what to expand

river lodge
#

What language are you using?

plush crow
#

node

#

checkout.sessions.list({
customer: customer_id,
expand: ['data.payment_intent.payment_method']
});

river lodge
#

Yep, should work!

plush crow
#

But i am not getting the payment method details

river lodge
#

Which details? What's the JSON output of the payment_method hash?

plush crow
#

I cann't see payment_method instead payment_method_type is available

river lodge
#

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

plush crow
#

{"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"}

river lodge
#

Ah, it's a mode: 'subscription' session. payment_intent won't be set

#

You need to expand subscription.default_payment_method

plush crow
#

ok let me check

#

just to confirm i need to use checkout API and expand subscription.default_payment_method

silver glen
#

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.

plush crow
#

And in response i will get subscription

silver glen
#

Yes as part of the checkout object

plush crow
#

and from subscription i need to fetch default_payment_method
and this is alsway going to contain card orbject??

silver glen
plush crow
#

yes I agree

#

inside default-payment-method
i have key named 'card', is this going to be always present ??

silver glen
plush crow
#

can you confirm what else can be present there ??

silver glen
#

Not sure what you mean by what else can be present?

#

can you expand on this a bit?

plush crow
#

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.

silver glen
#

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