#phillip_best-practices

1 messages · Page 1 of 1 (latest)

atomic marlinBOT
simple lodgeBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

atomic marlinBOT
#

👋 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/1250789261255639112

📝 Have more to share? Add details, code, screenshots, videos, etc. below.

cunning folio
#

hi there!

#

will the amount you charge the user at the end of every month be the same, or will change every month?

ebon fjord
#

Hello soma, the amount will be different every month depending on how much ad budget he spent

cunning folio
#

then you can't really use Stripe Subscriptions. instead you'l have to:

  • save the customer's card on Stripe
  • at the end of every month, create a PaymentIntent for the saved card to charge the user. note that this step may fail if the bank request 3DS. in this case you'll have to ask the user to come back to your website and trigger the 3DS flow.
ebon fjord
#

Hm, I understand. So this is the only way to accomplish that?

"in this case you'll have to ask the user to come back to your website and trigger the 3DS flow." =>

  1. how can I check if this failed? Will the API for creating the payment intent return an error?
  2. How can I make him trigger the 3DS flow?
cunning folio
#

also note that the payment can also fail for many other reasons (insuffisant funds, card stolen, etc.). so your integration will have to take this into account.

ebon fjord
#

So every month I would have a cronjob which calls create payment intent. If it fails, the user will see a warning message in the frontend "Please confirm your payment [button]" -> user clicks button -> calling stripe.confirmCardPayment('{PAYMENT_INTENT_CLIENT_SECRET}')

=> correct?

Where would I get the PAYMENT_INTENT_CLIENT_SECRET from? Does it differ every time so I would need to store it in the DB if it fails?

cunning folio
#

run the cron job on your backend:

  • if it works, then nothing else to do
  • if it fails because of insuffisant funds or something like this: retry the payment later
  • if it fails because of 3DS, then notify the user to click on a button on your frontend to trigger the 3DS fow yes
simple lodgeBOT
cloud arrow
#

👋 stepping in here as soma needs to step away

#

The other option here would be to use Metered Billing where you record usage over the course of the month and then it would charge automatically for that usage at the end of the month

#

But the above works totally fine as well

ebon fjord
#

Hm okay.. Is there any other way to achieve this?

  • I've read the Stripe credit feature is still in development
  • Or can we block/reserve the ad budget the user is about to spent? For example, if the user wants to publish a Facebook campaign with a lifetime_budget of 200€ => can we block/reserve this amount?

My problem is this: Having the user to click a button every month to pay for his ad budget doesn't seem to be very intuitive to me

cloud arrow
#

You don't have to have your user click any button each month

#

You just have to collect their paymnet method

#

Then you can charge it off_session

#

You only bring them back on-session to handle 3DS if the payment attempt fails for authentication required, but this should be rare if you set up the payment method correctly when you collect it

ebon fjord
#

You mentioned metered billing which I would prefer and was looking into at first.
How would I set this up in my case?

As I mentioned earlier the subscription costs 99€ per month + the ad budget

I would like to do something like this:

  1. Cronjob: Every month make an API call to Facebook and get the amount of ad budget the user has spent this month.
  2. Make an API call to Stripe and fill some meter value, e.g. "user has spent 293€ this month"
  3. User receives invoice from us (via Stripe) 99€ Subscription + 293€ Ad budget

Is this possible?

#
  1. Oh most important part: The money is automatically deducted from the credit card which we have stored
cloud arrow
#

Yep that's possible

#

You would basically use two different Prices here

#

So one that is the 99 EUR and then a Metered Price

#

Do you want o charge that 99 EUR when the Subscription is created?

#

Or only after the first month?

ebon fjord
#

My dashboard is in German. I guess by metered price you mean Pay as you go.
Which other options would I need to choose here? (You can tell me the English values; I don't know where I can quickly change my dashboard language)

#

I'm offering a 14 days trial. After the trial has ended I want to charge 99€.
Of course the ad budget, if any ad budget has been spent, has to still be charged even though the subscription was canceled during the trial

cloud arrow
#

You want to charge for Ads during the 14 day trial?

#

I guess that makes sense

#

Just more complicated

ebon fjord
#

We would have to.
We pay the ad budget first to Facebook.

  1. User runs ad with a budget of 100€
  2. We pay the 100€ to Facebook
  3. Every month we need to deduct the subscription fee (99€) + the ad budget (100€ or 238€, whatever the user has spent)

But of course we are looking for the easiest solution so if there is a better way..

#

We know this includes some risk (e.g the ad budget has been spent but deducting the payment 1 month after fails) but it seems to be the easiest solution

cloud arrow
#

Okay so what you likely want to do in this case then is create two Prices -- one Metered and one Licensed (the Licensed Price is the 99 EUR Price). Then you create a Subscription with a 14 day trial with those two Prices.

For the first 14 days you will need to track usage on your side and then add an Invoice Item to charge for usage during that 14 day period, as the Meters API does not apply usage that is recorded during a trial. Then after the 14 days you start creating Meter Events to track the usage in Stripe and that will be charged each month

ebon fjord
#

This sounds doable 🙌 What do you mean by invoice item? Where would I attach it?

Lets say a user spent 100€ and cancels his subscription during the trial. Can we still automatically deduct the 100€ from his credit card?

cloud arrow
#

That Invoice Item will be picked up with the next finalized Invoice for that Customer

#

And you also pass the Subscription ID there too

ebon fjord
#

Okay I understand. The only thing I'm still confused about is how to configure the prices in the dashboard?

cloud arrow
#

Yeah that looks right. You set a per-unit amount and then when you report Meter Events you report a quantity.

#

So up to you for what that per-unit amount would be.

#

That depends on your model

#

Flat rate is the Licensed option I was mentioning above

#

(In place of Usage-based)

ebon fjord
#

Okay so this means my 2 prices should look like this. Correct?

cloud arrow
#

Yep that looks right to me

ebon fjord
#

And then every month I check with the Facebook API. If I get the value "user has spent 238€" I make an API call to Stripe and fill the metered value with 238?

cloud arrow
#

Yep

ebon fjord
#

Cool! Thanks for being so patient with me. I appreciate it. I'll start testing and then building it 🙏
Have a good day