#amfpaulo_terminal-subscription
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1260709743866023988
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
amfpaulo_terminal-subscription
@paper onyx We don't support Subscriptions for Terminal payments today. The best option is to collect the first payment as a one-off payment with Terminal and then start a Subscription with a trial or billing_cycle_anchor set to their future/next payment date.
Also Terminal is not for recurring payments. So when you say the Update Customer default_payment_method failed you likely passed the wrong PaymentMethod id. I assume you passed the pm_123 for the type: 'card_present' PaymentMethod which is incorrect.
What you want is to use the generated card that is a separate PaymentMethod with type: 'card'
where can I find more info on the docs or could you give me a high level guidance ?
I wish we had good docs for this, we don't, it's a huge mess.
So I think it depends which part of my answer you are asking about
ok, for the Payment method, after seting up the intent , I use this method from react native SDK to retrieve the payment method Id from the setupIntent:
const { setupIntent, error } = await collectSetupIntentPaymentMethod({
setupIntent: si,
customerConsentCollected: true,
enableCustomerCancellation: enableCustomerCancellation,
});
after that I call my backend to create the subscription:
await api.createSubscription({
customerId: 'cus_xxx',
priceId: 'price_xxx',
paymentMethodId: setupIntent.paymentMethodId,
});
yeah that's the wrong PaymentMethod id
how can I get the correct one ?
I think I can solve my problem If I can get the "generated card"
cool, I think I can progress a bit more with this information
Thank you. I appreciate your help
sure thing! You can test this in a few minutes so let me know if you get stuck. Note: all of this is server-side you can't do this client-side in the SDK
Thank you, Ya, I know, I am doing server side
It gave me the same error, also method returned to me the same id, this is my code
this si my create subscription that now, receives a intentId and find the correct generated card:
[HttpPost("create-subscription")]
public IActionResult CreateSubscription(SubscriptionRequest request)
{
var opt = new SetupIntentGetOptions
{
Expand = new List<string> { "latest_attempt" },
};
var srv = new SetupIntentService();
var i = srv.Get(request.SetupIntentId, opt);
var paymentMethodId = i.PaymentMethodId;
UpdateDeaultPayment(request.CustomerId, paymentMethodId);
var options = new SubscriptionCreateOptions
{
Customer = request.CustomerId,
Items = new List<SubscriptionItemOptions>
{
new SubscriptionItemOptions { Price = request.PriceId }
},
DefaultPaymentMethod = paymentMethodId,
};
var service = new SubscriptionService();
Subscription subscription = service.Create(options);
return Ok(subscription);
}
yeah you didn't do what's in the doc I shared at all. You did ``` var srv = new SetupIntentService();
var i = srv.Get(request.SetupIntentId, opt);
var paymentMethodId = i.PaymentMethodId;``` which is the `pm_123` for the `type: 'card_present'` here
This is the part of the doc that is crucial. I see you expanded but you never looked at the result
You need to access this instead: https://docs.stripe.com/api/setup_attempts/object#setup_attempt_object-payment_method_details-card_present-generated_card
You are correct, I just rush, because was looking simple... Ok, I find it the correct property
lets see now
yeah it's so hidden and deep ๐ฆ
I think I still doing something wrong, I find out the property i.LatestAttempt which I access the PaymentMethodId from the LatestAttempt, it returns to me the same card_present id
yes because you are still going way too fast I'm sorry
i.LatestAttempt.PaymentMethodDetails.CardPresent.GeneratedCard this is what you want
OMG
this is insane, anyways, GenerateCard as almost all objects was null, however like the norm, GeneratedCardId property was populated. Moreover WORKED !!!
You save the day, thank you.
I am thinking to contribute with . NET sample for the community after a finish this
thank you again
yeah GeneratedCard is for the full object if you expand it, if it's just an id it's null and you use GeneratedCardId
thank you again
happy to help!
last question, there is a quick way to check if the customer already has a default payment_method / card set ?
Call the Retrieve Customer API https://docs.stripe.com/pi/customers/retrieve and check invoice_settings[default_payment_method] before you update it (or track this in your database)
Cool, thank you man ! Have a great day