I'm looking for some help using the invoice_created webhook.
IRC-Source_76421
koopajah: to test the effect of an active subscription cancelation I use the retrieveUpcoming ( invoice ) api
koopajah
weavermedia : what's the question/issue you have?
IRC-Source_76421 : Can you give me a lot more details, if possible into one long line
weavermedia
I'm using it to add an invoice item right before the invoice is charged, but for subscriptions with a trial period the invoice_created webhook is fired as soon as the trial starts.
koopajah
weavermedia : the invoice is always fired on subscription creation, no matter whether there's a trial or not. That first invoice is also always closed which you can see with `closed: true`
IRC-Source_76421
In the call I provide both subscription_proration_date and the subscription_trial_end date. I set both to now + 30 days to simulate ending the subscription in 30 days.
My question is: is this the correct way to do it?
In the reply I do get information such as:
subscription_proration_date: 1530392947,
subtotal: -1003,
tax: -191,
tax_percent: 19,
total: -1194,
koopajah
IRC-Source_76421 : Please stop doing that, I told you a few times. Do not copy paste values or code like this, it looks like spam
IRC-Source_76421
Oh, sorry.
koopajah
And I don't understand why you would simulate a cancelation and a trial and all that. I'm having real trouble following your logic/questions, I'm sorry
IRC-Source_76421
To calculate the prorate amount.
koopajah
but why is there any proration if it's on a trial, this does not make sense to me
IRC-Source_76421
I was told, I could do that by fetching an upcoming invoice.
Who said it is on trial? Its an active subscription.
weavermedia
koopajah: okay, thanks. Maybe I'm just confused by the UI. I'll try creating a new test customer and see if that helps.
IRC-Source_76421
Where do you get the information from that the subscription is on trial? I said clearly that I managed to update it into active status after adding a test card number to the test customer.
koopajah
"In the call I provide both subscription_proration_date and the subscription_trial_end date" you said that earlier.
IRC-Source_76421
Yes. As I understand, one must provide them to let stripe calculate the prorate.
weavermedia
koopajah: I created a new customer and saw that an invoice is created then immediately closed for the trial period. Then I see an 'upcoming invoice' that will be charged when the trial ends. Does the 'upcoming' part of that mean that the invoice hasn't been created yet? And when it's created the invoice_created webhook will fire?
koopajah
IRC-Source_76421 : that is not correct no. If the subscription is active and not trialing there's no reason to send a trial end date
weavermedia : correct!
IRC-Source_76421
Hmmm. I was told otherwise in the past.
weavermedia
koopajah: perfect! Thanks for your help :)
IRC-Source_76421
okay, I will try the call without the trial end date.
malcolm1 joined the channel
If I remove the trial end date from the call, then the prorate amount is not calculated for the upcoming invoice.
koopajah
I'm really sorry but you've lost me a while ago :(
A lot of this is likely obvious to you because you're deep in it. But I would need you to spend time explaining things in more details. If you could send clear example code, with comments, example values, example response, etc. it would likely help
IRC-Source_76421
Call to stripe.invoices.retrieveUpcoming WITH trial_end_date ( on active sub ) => prorate is calculated.
Call to stripe.invoices.retrieveUpcoming WITHOUT trial_end_date ( on active sub ) => prorate is NOT calculated.
that's it
koopajah
sure but none of that is true
IRC-Source_76421
?
koopajah
like it might be because you have a bug in your code or testing the wrong thing. But trial_end has no bearing on proration on active subscription unless you pass the wrong thing
IRC-Source_76421
I am flabbergasted.
koopajah
¯\_(ツ)_/¯ I'm not sure how to help you without a lot more details, reproducible examples, etc. It would take your 3 minutes to make a script that reproduces the exact issue
IRC-Source_76421
I am 99% sure that one stripe developer told me that is exactly how to calculate the prorate for an active subscription. By providing the trial end date to the call.
koopajah
Okay so you want to *simulate* a cancelation and to do this you fake a move back to a trial period so that Stripe prorates the amount? Sorry if that's what you meant, I read your questions multiple times and never got that from it
And IMO that's the wrong approach though yes that works
IRC-Source_76421
What would be the better approach?
koopajah
To change the quantity of the subscription item(s) to 0 instead which is cleaner/the right way. Though both work
IRC-Source_76421
koopajah: yes you are right. That is what I am trying to simulate.
koopajah
so okay, what's your issue when using trial end then? What is blocking you, what's the question behind the confusion?
IRC-Source_76421
The simulation is twofold: 1. because its all just test data. 2. because its just an upcoming invoice that is calculated.
ta_ joined the channel
koopajah: my question is: am I calculating the prorate the right way?
koopajah
it should work yes
you can just look at the results and make the math to confirm, it's fairly easy
beno
is setting the quantity to 0 better than deleting the subscription to cancel it?
IRC-Source_76421
Since I am providing both subscription_proration_date and subscription_trial_end in the call. That feels weird.
And both are the same date.
If I omit subscription_trial_end date, the proration is not calculated ( since subscription just remains active ).
You say, setting the subscription items to 0 would be cleaner.
koopajah
beno : no it is not, it's just to simulate a downgrade
IRC-Source_76421 : Just ignore everything I said, you're already confused and that will just make things worse. Just pass trial end and ignore proration date
IRC-Source_76421
Ah, I see.
Let me try.
hmmm. If I omit proration date, the proration is calculated for the full amount, not for the period from 30 days from now to end of subscription.
It seems I need to pass in both dates.
koopajah
lol yeah okay I still don't get what you are really trying to do and why you'd simulate a credit 30 days from now instead of just canceling immediately. But yes pass both with the same value in that case
IRC-Source_76421
heh
Tamara joined the channel
Tamara
Hi. What does it mean when a member receive this message "no stripe card token is present"
koopajah
Tamara : that's not really a Stripe error, it's likely an error in the platform/plugin you use
Tamara
Awesome. Thank you for your help!
IRC-Source_76421
Because I want to precalculate the prorate, tell the customer the amount, wait until he confirms and refund exactly what was calcualted.
*calculated
Tamara
I wanted to be clear before I reached out to them.
koopajah
IRC-Source_76421 : yeah I will give up on trying to understand the use-case. This is likely specific to your business model/logic and not important in this case. Ultimately what you explained does work
IRC-Source_76421
okay
Tamara has quit
tamara joined the channel
tamara has quit
cannap has quit
lukas__ joined the channel
Dreamesper joined the channel
lukas__
hey stripe, i have a client that is using stripe connect that is settling in a different currency than the one i am settling with them. how do i retrieve the amount that ive settled before stripe exchanges it for their connect account? i see that when i get the balance transaction, the amount and currency is shown in their stripe connect currency
Dreamesper has left the channel
i need to retrieve the amount that ive settled with their stripe connect account, for accounting purposes
koopajah
I don't know what you mean by that exactly unfortunately. But the charge is created in one currency and has the currency/amount and then the BT has the currency/amount for the connected account
Charge in USD, platform settles in USD, connected account settles in EUR
in this scenario, the balance transaction returns the amount and currency in EUR
i want the amount and currency in USD, the amount that i settled with them
koopajah
sure so charge is in USD and BT in EUR.
lukas__
Charge in CAD, platform settles in USD, connected account settles in EUR
in this case, how do i know what the settlement is after stripe converts from CAD to USD?
koopajah
then there's never a conversion to USD so we don't share that info at all.
it always goes from CAD to EUR
lukas__
but if they've connected with stripe connect, and the client ID is in USD, i assume i am getting my settlement exchanged from CAD to USD?
brendan_ joined the channel
brendan_
Hey is there a stripe physical card reader that i can integrate into my angular 5 (running chromium kiosk on an rpi) app that will give me a token to send to my backend?
larafale joined the channel
koopajah
lukas__ : not really, not on the charge at least.
korben
Aloha.
brendan_
aloha, thanks.
korben
brendan_: No, sorry. At least not one that I'm aware of. Swipe data is fine, but it's a whole big thing with certifications for the particular reader. You'd need to use one of our partner PoS systems.
brendan_
Ive seem them but none seem to support chromium on a linux build
koopajah has quit
lukas__
hmm so consider this niche scenario. charge is in CAD, the platform settlement is in USD, and the stripe connect settlement is in EUR, the stripe connect permissions are using a USD client ID
where does my platform's settlement go? does it go into our stripe connect USD client or our stripe connect EUR client?
korben
I'm totally lost, but regardless of your funds-- if you have a bank account associated with your account that isn't the account you settled your funds in, they'll be converted and deposited into your default bank account when you make a payout.
that isn't the currency you settled your funds in* rather
IRC-Source_76421 has quit
lukas__
from my understanding, users can connect a stripe connect account in a different currency than the one i am settling in (the client ID)
so how am i supposed to get that exchange settlement amount between the user and the platform?
korben
lukas__: They can. Yes.
lukas__: It'll get converted to whatever your settlement currency is.
Or your portion will rather.
lukas__
right but where do i get that? if i expand the balance transaction, it's in the currency settled with stripe
korben
lukas__: There are multiple balance transactions. One for the original charge and one for the transfer.
lukas__
ok so there would be two balance transactions in CAD->USD->EUR then? one for exchanging the charge from CAD->USD, and then another for exchaning the USD->EUR?
korben
lukas__: No. You've got Platform Account in USD, you've got Connected Account in EUR, and you've got transaction in CAD. (for example). Transaction gets charged in CAD. Funds are converted from CAD->EUR for Connected Accounta nd CAD->USD for Platform Account.
hkhk has quit
irctc802 joined the channel
weavermedia has quit
brendan_ has quit
lukas__
is it possible to retrieve the transaction "CAD->USD for Platform Account" inside of the charge request?
marqo09 has quit
korben
I believe so, but I'm not 100% sure on how off the top of my head. I think it's maybe the `source_transfer` attribute? I could be totally wrong though. Is this a direct charge or destination charge?
larafale has quit
lukas__
that would be a direct charge
on create
korben
lmc if I can get at it.
orbyt_ has quit
ta_ joined the channel
irctc802
hello, from my client i am sending a number like 321.79 to my server and then multiplying that by 100 to get it in pennies. Though after I multiply it by 100 i get 32179.000000000004. which obviously Stripe doesnt like.
anyone know the best way to go about this?
korben
lukas__: So you would expand ['application_fee', 'application_fee.balance_transaction']. That would give you the settlement currency and conversion.
irctc802: What language are you using? You just cast it to an integer most likely.
irctc802
korben: node
korben
`parseInt(your number here)` I think?
yeah. That's how. So just wrap your multiplication in a `parseInt()` function call.
irctc802
thanks ill test that out
korben
You might also consider doing some Javascript magic to prevent that kind of input if you don't want "cents". :)
irctc802
korben: could you elaborate
korben
irctc802: Like-- do some kind of form field validation. Check the value of your input box. If it's a decimal, complain to the user or convert it for them.