#amfpaulo_api

1 messages ยท Page 1 of 1 (latest)

prime hillBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1343941899416895552

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

weary plinth
#

๐Ÿ‘‹
Checking..

neon rampart
#

thank you

#

This Id its just one example , I have others in the same situation:

sub_1QZGXsDn6CAQGXZn2V05plag
sub_1QXaPxDn6CAQGXZnlYtglZzY
sub_1QuQlUDn6CAQGXZnfyk3PB8C
sub_1QthYlDn6CAQGXZnJxblS7JK
sub_1QsXmjDn6CAQGXZnnQgunQ6P
sub_1QSs7bDn6CAQGXZnYNf2nvLV
sub_1QSs56Dn6CAQGXZnq88SuRRA
sub_1QSqbfDn6CAQGXZnQ2F6CE39
sub_1QSnPgDn6CAQGXZncLen5IyK
sub_1QpQ0KDn6CAQGXZn4WXYsVbA
sub_1QpiDGDn6CAQGXZnwOIzYZM8
sub_1QPATlDn6CAQGXZnPwekhn0s
sub_1QNRM8Dn6CAQGXZnFwiERwGT
sub_1QnlZSDn6CAQGXZnJ4DpJiBU
sub_1QN60TDn6CAQGXZncY3Ht2TN
sub_1Qn3EBDn6CAQGXZn2nH3Wc2h
sub_1QiKe8Dn6CAQGXZn6p8Lqb7H
sub_1QfZ4xDn6CAQGXZn5A89zsoc
sub_1QFRZRDn6CAQGXZn7twLniXI
sub_1QFRV4Dn6CAQGXZnkyZhCFpK
sub_1Qer8oDn6CAQGXZnROdGygs5
sub_1QAhh1Dn6CAQGXZnn1Hrlgus
sub_1Q9tXBDn6CAQGXZn2ozcrj5h
sub_1Q37FCDn6CAQGXZnPptaWRUk
sub_1Q2klMDn6CAQGXZnMsWekNVo
sub_1OVhurDn6CAQGXZnTTDg6zeY

#

In case you need more data to debug

prime hillBOT
verbal marsh
neon rampart
#

Ok, I understand that, but the code I have is the same, like I said, some subs show the payment method other don't

#

Just to make easier for me to understand, look this one, for this I have the payment method, this one has 24 hrs difference from the first Id I gave you: sub_1Qun75Dn6CAQGXZnazlBcDAr

verbal marsh
#

That one uses checkout

#

which sets default payment method at subscription level

#

sub_1QuQlUDn6CAQGXZnfyk3PB8C was created via the subscription api not checkout

neon rampart
#

Moreover, in my code, I am setting the PaymentMethod on the subscription options:

if (!string.IsNullOrEmpty(request.SetupIntentId))
{
paymentIntent = GetLastPaymentMethod(request.SetupIntentId);
var paymentMethodId = paymentIntent.LatestAttempt.PaymentMethodDetails.CardPresent.GeneratedCardId;

            UpdateCustomerDeaultPayment(request.CustomerId, paymentMethodId);

            options.DefaultPaymentMethod = paymentMethodId;
        }
verbal marsh
neon rampart
#

I see, this is so weird, I need to check with the client, I believe he is also spreading out links for the products

#

So the problem is with the ones created using the API ?

verbal marsh
#

Those you need to explicitly set default_payment_method on them, yeah

neon rampart
#

But I did, I just double check the link you sent to me

#

Ow, I think I know my mistake

#

Based on that I have a question for you,

#

How can I retrieve and set the default payment method for a subscription when a customer already has a card on file, but no new setupIntent is created?

I just realized that for a first-time purchase, we first set the card on file using a setupIntent, and then we create the subscription using that saved payment method (options.DefaultPaymentMethod).

However, for returning customers who already have a saved card, I am not setting options.DefaultPaymentMethod, because I only assign it when a setupIntent exists.

My question is:
How do I retrieve the customer's existing default payment method and set it for the subscription when there is no setupIntent?

#

becasue subscriptions use card on file by default I did not bother to set the card on file direct to the subscription generating this problem

verbal marsh
#

If they have it set at the customer level, then just retrieve the customer via the api

neon rampart
#

Ya I understand that, but the SDK is trick sometimes, Everytime I need to deal with payments I need a litle help:

Is this code making sense to you ?

                        **    var customerService = new CustomerService();
            var customer = customerService.Get(customerId);

            if (!string.IsNullOrEmpty(customer.InvoiceSettings.DefaultPaymentMethodId))
            {
                var paymentMethodService = new PaymentMethodService();
                var paymentMethod = paymentMethodService.Get(customer.InvoiceSettings.DefaultPaymentMethodId);
                paymentMethodId = paymentMethod?.Id!; // Is this the correct ID ?
            }**
verbal marsh
#

on first glance

#

you should test all this in test mode

#

But also having default payment set only at customer level is generally fine

#

You only need to set it on the subscription if you want to override what's set on the customer

neon rampart
#

I know, I'll test, I am just trying to get ahead here, bucause I remember getting trap on these payment method things, default source, etc

#

I understand that and I need to do this, becasue some customers have more member of the same family that have subs and they want use different cards for each subscription

#

My last question to you, If I go throught All subscriptions that are missing a defaultPayment method, and using the API update the payment method, is this causing any side effect ?

#

like client getting emails, or subscriptions being canceled, etc

#

or credit card flags firing "fraud alerts" to the clients...

#

things like that

verbal marsh
#

No if the only thing that you change is default_payment_method, then that shouldn't cause issues

neon rampart
#

ok cool, thank you for the help

#

Have a great day