#Jonah Librach

1 messages · Page 1 of 1 (latest)

nimble juncoBOT
stone oyster
#

hello! can you share the subscription id?

rugged gale
#

Sure, I just need to recreate an example. Might take a minute or so

nimble juncoBOT
rugged gale
#

sub_1N8F7nEqrfgopYncNpBxxwFE

#

According to the expiry_date it should expire/renew on July 31, 2000 at 10:00 AM, which would make sense... but it doesn't invoice again until Aug 3

outer harbor
#

Hi @rugged gale I'm taking over

rugged gale
#

Great. Thanks Jack

outer harbor
rugged gale
#

Okay wait, the invoices are created... which is good.

But then why is it taking so long to automatically pay those invoices?

#

Says finalized on Aug 2

#

Payment date Aug 2

outer harbor
#

So you are talking about this invoice in_1N8F86EqrfgopYncnU7vfmUY

rugged gale
#

I'm talking about this invoice which was paid 2 Aug 2000, 10:00 and created 31 Jul 2000, 10:00

in_1N8F7vEqrfgopYncdaWGLBuf

outer harbor
#

OK. From the event logs the invoice.created and invoice.paid happened almost at the same time.

outer harbor
#

It looks like be a bug with the test clocks, I'll feed back to the relevant team.

rugged gale
#

Where are you seeing that they are created and paid at nearly the same time?

outer harbor
#
rugged gale
#

Last time the support said it could be a timezone issue, but it doesn't make any sense. It's off by several days

outer harbor
#

No, I don't think it's a timezone issue.

rugged gale
#

Okay, thanks.

#

Another question:

I'm trying to set up a test that pays out on the first cycle, but then fails (due to credit card expiry) on the second.

What should I expect to happen when I update payment details to a working card at some later date?

How can I get it so the subscription cycle start is the date that the card worked and it ends 30-days later?

outer harbor
#

So you want to pause the subscription until the customer has set up a new card that works?

rugged gale
#

Yes.

#

Once they set up the new card and it charges successfully, that should be the new period_start

#

P.S. working with subscriptions is really hard.. meaning it's taken me 2 weeks to write tests etc to integrate with my app. Is this normal?

outer harbor
#

Yes, subscription is hard.

#

You can listen to invoice.payment_failed event and call API to pause the subscription (https://stripe.com/docs/billing/subscriptions/pause), once your customer has successfully paid the invoice (i.e., invoice.paid) you can unset the pause, and update the subscription's billing_cycle_anchor to now (https://stripe.com/docs/api/subscriptions/update?lang=curl#update_subscription-billing_cycle_anchor) to reset the cycle.

rugged gale
#

on a failed payment, will this failure be derivable from the customer.subscription.updated event

for example, will I get webhook_data.data.object.items.data[0].plan.active == False?

#

Sorry, that may be a tough one to answer lol

outer harbor
#

Not really, the subscritpiont's status won't be immediately updated upon a failed payment.

rugged gale
#

Okay, so I'm trying to test this on the CLI and UI now

#

Strategy is to use a card that just expires at the 2nd cycle.

How can I specify such a card in the Python bindings?

outer harbor
#

https://stripe.com/docs/testing#declined-payments you can use one of these card to simulate a decline

Use test cards to validate your Stripe integration without moving real money. Test a variety of international scenarios, including successful and declined payments, card errors, disputes, and bank authentication. You can also test non-card payment methods.

rugged gale
#

I want it to work the first time, then be decline the second time

outer harbor
#

So you create a subscription with 4242, once the inovice is paid, update its default_payment_method to one of the failing cards

rugged gale
#

Good idea

#

thanks I'll try it now

rugged gale
#

stripe.error.InvalidRequestError: Request req_rpsBVQdWXGZqyg: The customer does not have a payment method with the ID pm_1N8GKgEqrfgopYncreB3dIG7. The payment method must be attached to the customer.

#

I create customer as follows:

creationArgs = {
        "email":email,
        "payment_method":payment_method,
        "invoice_settings":invoice_settings,
        "test_clock":CLOCK_ID
    }

    customer = stripe.Customer.create(**creationArgs)
outer harbor
#

And attach the newly created payment method to your customer

rugged gale
#

Ty.

#

For card,

stripe.PaymentMethod.create(
  type="card",
  card={
    "number": "4242424242424242",
    "exp_month": 8,
    "exp_year": 2024,
    "cvc": "314",
  },
)

Should I set card="pm_card_visa_chargeDeclined""?

outer harbor
#
  "token": "tok_visa_chargeDeclined"
}```
rugged gale
#

stripe.error.InvalidRequestError: Request req_7CbHBt8GTkeb9s: The customer does not have a pa
yment method with the ID pm_1N8GWTEqrfgopYncr1lsyvto. The payment method must be attached to
the customer.

#

This is after:

pm = stripe.PaymentMethod.create(
          type="card",
          card={ "token":"tok_visa_chargeDeclined" },
        )
#

Oh, still need to attach. sry

rugged gale
#

I'm just confused why the default behaviour is to have the subscription continue to be active if the payment fails.

stone oyster
rugged gale
#

How do I set that up from the API call on Subscription.create

stone oyster
#

you can't, it's an Account level setting

rugged gale
#

What? I'm not talking about my billing

#

I'm talking about creating a Subscription that cancels if the payment fails

stone oyster
#

if you want a Subscription to automatically cancel if a payment fails, like i mentioned, that's an account level setting

#

you cannot configure it per Subscription

rugged gale
#

Can you explain that to me?

#

Why that's the case?

#

What if I want one product to cancel on fail, but another one not to

stone oyster
#

then you would have to set the account level settings to leave the subscription and invoice "as it is" even if payment fails and implement your own logic to cancel subscriptions for a particular product if payment for it fails

rugged gale
#

Okay, thanks, that makes sense.

Which events should I be listening for to make sure that the payment has successfully gone through for my subscription?

Currently, I'm listening to customer.subscription.updated, but that obviously isn't going to work.

#

Hunch is invoice.payment_succeeded, but then there's the invoice.finalized that looks far more final, haha

#

ChatGPT says I should use invoice.payment_succeeded.

Can you confirm?

outer harbor
#

Listen to invoice.paid

rugged gale
#

Jack you're a hero

outer harbor