#prish-paymentmethod-default

1 messages · Page 1 of 1 (latest)

marble pecanBOT
restive wigeon
#

@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?

mild vine
#

We are calling get payment method api in that we are receiving default: "true"

#

Whaen we add card for customer

restive wigeon
#

there's no concept of a default on PaymentMethod, so that doesn't really make sense to me yet

mild vine
#

Can i share json with you

restive wigeon
#

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.

mild vine
#

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.

restive wigeon
#

Okay can you show me an example JSON where you see that?

mild vine
#

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

restive wigeon
#

huh

#

what call did you write to get this JSON?

#

prish-paymentmethod-default

mild vine
#

cardResponse = stripe.Customer.list_payment_methods(
stripe_id,
type="card",
)

restive wigeon
#

thanks, let me have a look locally

mild vine
#

ok

restive wigeon
#

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

restive wigeon
#

@mild vine can you share your exact code? How are you printing the JSON exactly? Is this this specific customer or is sporadic?

mild vine
#

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

restive wigeon
#

yeah but I did that and I definitely don't see this behaviour

#

Can I ask you to call the Update PaymentMethod API?

mild vine
#

Yeah if I call update it will work

restive wigeon
#

what does "it will work" mean?

marble pecanBOT
mild vine
#

So when I updated my card with this setting then it start giving me default option in response json

restive wigeon
#

@tender fog I'll keep for now please

#

@mild vine can you show me?

mild vine
#

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

restive wigeon
#

if payment_data.default:

#

I have a feeling this is something in your own code/logic and not Stripe

#

I mean I am reading the code for our API and I don't see a default property anywhere

#

can you explain where you defined payment_data?

#

cc @mild vine