#prish-paymentmethod-default
1 messages · Page 1 of 1 (latest)
@mild vine you just dropped a huge json but I don't really know what you're asking "get default". Can you be a lot more specific about what you are trying to achieve?
We are calling get payment method api in that we are receiving default: "true"
Whaen we add card for customer
there's no concept of a default on PaymentMethod, so that doesn't really make sense to me yet
Can i share json with you
Can you try and take a small step back and clearly explain what you are doing, which APIs you are using, what you code looks at and what you are trying to achieve? If possible, try to do all of this in a few sentences all in one clear message, not really short sentences sequentially.
I'm calling Retrieve a Customer's PaymentMethod and in that, I receive one key default as true or false. But on some account, I do not receive that option.
Okay can you show me an example JSON where you see that?
{"object":"list","data":[{"id":"pm_1MrMy4BtpRr1bxasEUI7jrFM","object":"payment_method","billing_details":{"address":{"city":null,"country":null,"line1":null,"line2":null,"postal_code":null,"state":null},"email":null,"name":null,"phone":null},"card":{"brand":"visa","checks":{"address_line1_check":null,"address_postal_code_check":null,"cvc_check":"pass"},"country":"US","exp_month":2,"exp_year":2029,"fingerprint":"bDTsZKm7MKyXHq7t","funding":"credit","generated_from":null,"last4":"4242","networks":{"available":["visa"],"preferred":null},"three_d_secure_usage":{"supported":true},"wallet":null},"created":1680188449,"customer":"cus_NcYgmK2arQgsY5","livemode":false,"metadata":{},"type":"card","default":"true"}],"has_more":false,"url":"/v1/customers/cus_NcYgmK2arQgsY5/payment_methods"}
cardResponse = stripe.Customer.list_payment_methods(
stripe_id,
type="card",
)
thanks, let me have a look locally
ok
okay I can not reproduce. I'm trying to figure out what call you are making and what's different between yours and mine. Will take me a bit of time
@mild vine can you share your exact code? How are you printing the JSON exactly? Is this this specific customer or is sporadic?
stripe.Customer.modify(
stripe_id,
invoice_settings={"default_payment_method": payment_data.cardDetails},
)
in invoice setting we are setting above and then in get we recive that default option
yeah but I did that and I definitely don't see this behaviour
Can I ask you to call the Update PaymentMethod API?
Yeah if I call update it will work
what does "it will work" mean?
So when I updated my card with this setting then it start giving me default option in response json
@tender fog I'll keep for now please
@mild vine can you show me?
https://dashboard.stripe.com/test/logs/req_DG2xhJQ1xZGs2c this is an Update PaymentMethod request for example and it doesn't have default: true right?
if payment_data.cardDetails:
user = (
db.query(payments_model.User).filter(payments_model.User.id == customer.user_id).first()
)
try:
stripe.PaymentMethod.attach(
payment_data.cardDetails,
customer=stripe_id,
)
except stripe.error.CardError as e:
raise PaymentException(name="A payment error occurred: {}".format(e.user_message))
except stripe.error.InvalidRequestError as er:
raise PaymentException(name=er)
except Exception:
raise PaymentException(name="Another problem occurred, maybe unrelated to Stripe.")
else:
if payment_data.default:
try:
stripe.Customer.modify(
stripe_id,
invoice_settings={"default_payment_method": payment_data.cardDetails},
)
except stripe.error.CardError as e:
raise PaymentException(
name="A payment error occurred: {}".format(e.user_message)
)
except stripe.error.InvalidRequestError as er:
raise PaymentException(name=er)
except Exception:
raise PaymentException(
name="Another problem occurred, maybe unrelated to Stripe."
)
else:
return
return
this what we are doing