#sukatoa

1 messages · Page 1 of 1 (latest)

steel tree
#

Hi there, can you send me the invoice ID?

main elk
#

this one in_1LExjsHxUYbY7mq5QrsfZWzP

#

the subscription id sub_1LExVhHxUYbY7mq5Fbk9N8hp

#

We are using test clock here to simulate and get the actual subscription that have payment failure (there's no other way but this test clock as of the moment).

#

We've simulated 2 success payments, then change the CC to failing CC then advancing the time to make it unpaid

#

If this gets resolved, we'll then test the 2 or more months this is failing to face generated draft invoice and test it against the current code

steel tree
#

How did you trigger this error ? "This invoice is already finalized, you can't re-finalize a non-draft invoice"

#

Can you send me the request ID?

main elk
#

This happens during the finalizeInvoice trigger

#

here it is request-id: req_Tn670RmoiC6Qwq

#

I was thinking that, the update on invoice is enough to wait for the subscription to make it active?

#

But then I tried to follow the steps triggering the finalize part as recommended yesterday

#

Does updating auto_advance on invoice will do the automatic finalize itself?

#

If yes, then I think we can ignore that error and have the subscription set back automatically by stripe to "active", but the result is the same, "unpaid"

#

Here's the code we use (similar steps from the app)

#

`Example Code (Similar Steps from app extracted):
// Via frontend: User enters credit card credentials and stripe creates payment method, id passed
String paymentMethodId = "pm_testLISlifnajewbAIi2oi34o";

// Attach customer to payment method object
Stripe.apiKey = getApiKey();
PaymentMethod paymentMethod = PaymentMethod.retrieve(paymentMethodId);
Map<String, Object> params = new HashMap<>();
params.put("customer", customerId);
PaymentMethod ownedPaymentMethod = paymentMethod.attach(params);

// Attach to existing customer object
CustomerUpdateParams.InvoiceSettings invoiceSettings = CustomerUpdateParams.InvoiceSettings.builder()
.setDefaultPaymentMethod(paymentMethodId)
.build();
CustomerUpdateParams customerUpdateParams = CustomerUpdateParams.builder()
.setName(customerName)
.setInvoiceSettings(invoiceSettings)
.build();
Customer updatedCustomer = stripeObject.updateCustomer(customer.getId(), customerUpdateParams);`

#

Then on the invoice part

#

`// Latest Invoice
InvoiceListParams invoiceListParams = InvoiceListParams.builder()
.setSubscription(subscriptionId)
.build();
try {
Stripe.apiKey = getApiKey();
InvoiceCollection invoiceCollection = Invoice.list(invoiceListParams);
Invoice latestInvoice = invoiceCollection.getData().get(0);

        InvoiceUpdateParams invoiceUpdateParams = InvoiceUpdateParams.builder()
                .setAutoAdvance(true)
                .build();

        Invoice invoiceToUpdate = Invoice.retrieve(latestInvoice.getId);
        Invoice updatedInvoice = invoiceToUpdate.update(invoiceUpdateParams);

        Invoice invoiceToFinalize = Invoice.retrieve(invoiceId);
        InvoiceFinalizeInvoiceParams finalizeParams = InvoiceFinalizeInvoiceParams.builder()
                .setAutoAdvance(true)
                .build();
        invoiceToFinalize.finalizeInvoice(finalizeParams);
    } catch (StripeException se) {
        se.printStacktrace();
    }`
steel tree
#

The request that you made is to finalize an invoice. However, the invoice is already finalized and therefore the error.

#

If you want to finalize the invoice manually, please finalize it before Stripe finalize it.

main elk
#

"before Stripe finalize it" - I'm not so sure with this part - when this will happen.

The steps I've made:

  1. Collect new payment Information (we got new payment method and attached to existing customer both to each other)
  2. Turn automatic collection back (we've updated the auto_advance on the last stripe generated invoice)
  3. Then execute the Finalize, we assume Stripe will do the auto collection from there

The subscription still unpaid after this.

#

Do you mean, we'll not going to execute the step 3 (finalize) one instead?

#

and let Stripe do the automatic stuffs after we turned on the automatic collection in that latest Invoice?

#

One thing I forgot to note is the current status of that Invoice, if it's already finalized by Stripe or not yet. That part made me confused

steel tree
main elk
#

I haven't read this page, Thank you much for sharing. So therefore at least an hour is need to wait for the invoice to get finalized by Stripe

#

I'm going to re-create the same scenario in test clock, but this time, without calling the Invoice.finalizeInvoice() method

#

I'll get back here and provide feedback

steel tree
#

Sure, you can check the invoice status before attempt to finalize it, If the status is draft, you can finalize it.

main elk
#

aahhh, that one

#

thanks

#

but if the invoice status = open, we don't need to call finalize anymore, correct?

steel tree
#

Yup, it's already finalized if the status == open

main elk
#

hello @steel tree , I've made another one with subscription Id=sub_1LFCIYHxUYbY7mq5PRtLcrge and invoiceId=in_1LFCLnHxUYbY7mq5QOgjNHYt

Though the status is still unpaid, I can see this retry charge. Before doing further experiments. I have few questions:

  1. If we're going to click that retry charge button, I am expecting Stripe will attempt to charge the latest default credit card on customer for that Invoice, correct?
  2. If this button exists, then there must be a programmatically way to do it. Not able to find it on Invoice api doc, is there a smooth trigger to do that as well programmatically?
#
  1. Is there a way for Stripe to force to process it right away instead of waiting for an hour or so?
steel tree
main elk
#

@steel tree The problem now resolved, we're able to bring back the subscription into "active" after Invoice was set to open.

I'll try to make the monthly subscription be past few months to see if this still able to perform with latest invoice=drafts

#

Would you advice to replace the default payment method id of subscription?

#

or does it automatically be replaced with the CC that works when the payment succeeded?

steel tree
#

I'll recommend you to update the customer's invoice_settings.default_payment_method with a working payment_method that the same payment_method can also be used in other subscriptions.

main elk
#

@steel tree Oh yeah, on the code, it does replace the actual payment method (default) on Customer Object, but not on the subscription. So is it safe to assume that when the recurring charge occurs, The subscription will look for the default payment method ones on customer object, right?

steel tree
#

Stripe will use the customer's invoice_settings.default_payment_method if the subscription doesn't have a default_payment_method or default_source.