#jamie_97274
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- jamie_97274, 3 days ago, 64 messages
- jamie_97274, 6 days ago, 5 messages
Hmmm, I'm not sure. Let me check
Thank you, this is for a referral system, when a customer refers another user in our platform we add credit to the customer. When said credit is used we need to remove it from our local DB entries also - so need to identify when and how much credit has been used exactly whenever a succeeded invoice comes through
Ok, you'd actually look at total (which is the invoice amount pre balance) and amount_due
Balance isn't applied as a payment, it's more of a discount
so (total - amount_due) = balance used?
Yes, but be wary that other factors can influence the amount_due too (discounts/coupons, etc)
coupons are discounts no? So apart from checking for coupons is there anything else to take into account?
Well a Coupon transforms into a discount which are in the discounts field
I don't think so no
And there is absolutely no other property to check the amount of balance used? You always need to manually calculate this?
(or a different object?)
Well there'd be a customer.updated event that would fire on invoice payment to reflect the balance changing
that might be a cleaner way than checking on invoice succeeded for my use case? do you have any thoughts
Only issue would be mapping/tying the events together
I'm not sure I would need to do so? I just need to remove a balance entry in our database connected to the customer ID
Sure, that would work then
its something I will have to test, but customer.updated gives me another avenue to test
do you know off the top of your head if that event will give previous balance - current balance?
It'd have a balance field that would reflect the new balance post invoice payment. But then you can use previous_attributes[balance] to calculate a diff
i.e. If I applied all $100 of my balance to an invoice, balance: 0 and previous_attributes[balance]: -1000
-10000 (in cents) I assume?
Yes