#JenniferJenna - Default Card
1 messages · Page 1 of 1 (latest)
Hello! Can you provide more details about what "I then update the customer's default payment card." means? A request ID would be great if you can provide one.
I'm not sure where I would find that Id. The call to update the default card seems to work. Here is that code. C# and using the stripe libraries. I can see it is updated in the dashboard. Here is that image too.
var options = new CustomerUpdateOptions();
options.InvoiceSettings = new CustomerInvoiceSettingsOptions()
{
DefaultPaymentMethod = cardRequest.CardId
};
options.AddExpand(DefaultSourceProperty);
Customer stripeCustomer;
CustomerService customerService;
try
{
customerService = await this.stripeServices.CustomerServiceAsync().ConfigureAwait(false);
stripeCustomer = await customerService.UpdateAsync(cardRequest.CustomerId, options).ConfigureAwait(false);
}
catch (StripeException e)
{
throw this.CreateStripeUtilityException(e);
}
return this.mapper.Map<CustomerModel>(stripeCustomer);
Gotcha, so you're updating the Customer's default_source it sounds like, which is a legacy API. Can you give me the request ID showing the error you mentioned about the default not existing? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
The logs only seem to show Posts. Prior to making the subsequent charge, I Get the customer to confirm they have a default card. That is the call that is failing.
I also tried the above code with options.DefaultSource = cardRequest.CardId to set the default card, but I get the same results when I try to retrieve it for a subsequent charge
You can show GET requests as well by changing the filter option at the top.
Err, Method option.
ha 🙂 req_TfOpsWKz3og15a
Awesome! Taking a look...
Ah, okay, so that Customer does not have a default_source set. They have a Payment Method attached which is set as their invoice_settings.default_payment_method though: https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method
Payment Methods cannot be set as a default_source, as that property is legacy for our older Token/Card/Source objects.
Does that help?
well not exactly. What if I try the other way? Should that work? Ie,
options.DefaultSource = cardRequest.CardId
Basically, I need to set the card they used on their initial intent as their default for re-charges. How can I accomplish that?
That depends on several factors... are you using a mix of legacy objects (Tokens/Cards/Sources) and new ones (Payment Methods)? How are they being re-charged?
I am just using payment intents. So when they setup a paymentIntent the first time, I create a customer and associated with the intent. Then the UI calls Confirm and the card is created, and associated with the customer and the payment goes through.
Then when they re-charge I create a new paymentIntent, but first I look up the customer to grab their default card. That's where my problem is.
Okay, so you need to look at the Customer's invoice_setting.default_payment_method and not use default_source at all.
Okay, so the code to set the card is correct then. Let me try to see if I am retrieving it correctly.
Thanks Rubeus. I have some re-mapping and setup to do. It's kinda late here, so I will ensure that I'm looking at invoice_setting.default_payment_method in the morning, and confirm success w/you.
Sounds good!