How to calculate credit card minimum payment amount paid and time to pay off

Posted on 2009-02-18
Last Modified: 2012-05-06
How can I use php to calculate how long it will take to pay off a credit card debt using a minimum payment option.

Here are the variables:
Credit Card Balance: $ccb
APR: $apr
Minimum Payment percentage of balance: $mmp

Number of months to pay off: $mos
Amount Paid: $amt

Credit cards offer a minimum payment option, typically 3% of the balance due.  If you make only the minimum payment and your balance is say $20000 how long will it take to pay off the entire balance and how much money will have been spent to pay off the balance?

I need the formula to be written in PHP.
Question by:lexo
    LVL 26

    Accepted Solution

    I am not a php expert so cannot give you a complete free PHP program but the outline will be something like
    A loop including
    $newbalance  = $ccb ($ccb*100*$mmp) +$ccb *100/12*$apr
    Iterate (putting $newbalance for $ccb) until $newballance = 0
    $amt = sum of all terms in ()
    Details  such as how often interest is charged to the account (monthly, daily,?), how to handle the last iteration, number of payments required in year (not always 12), have to be addressed.
    LVL 17

    Expert Comment

    You night need to look at the back of a statement to see how they compute it.  Or, give them a call.  And, it might depend on your past payment history.  Paying the minimum on a credit card is not a good idea unless it has a very low interest rate.

    Author Comment

    @dhsindy your comment is neither informative nor helpful.  I dont have a personal credit issue, this is to build an online credit card calculator.  Your comments aren't needed here, thank you.

    @Aburr, thank you. I will try to take your formula to the php experts.
    LVL 31

    Expert Comment

    Aburr has you on the right track, but one note of caution. Since the payment is based on a percentage and the interest applied is also based on a percentage, a calculation of the new balance will only asymptotically reach 0. I would suggest that your loop be along the lines of "while new_balance > 100" or some manageable final payment amount. As an aside, if you had a $20,000 balance with a 3% minimum payment rate, and an annual interest rate of 12%, assuming an even monthly payment, it would take 22 years to payoff (no new charges) and you would pay nearly $30,000.
    LVL 1

    Expert Comment

    i can give you some formulae (not in PHP though), and iterations are not needed:
    asume $mm is the minimum of the accpetable minimal payment, e.g. 100 in awking00's comment;
    let $mr be the monthly interest rate as $apr/12.0
    let $r = (1.0-$mmp)*(1.0+$mr) and this is the acctual rate of your balance decreasing.

    then N+1 months is needed to pay off the debt, where
    N = floor( log($mm/$ccb)/log($r)), floor(R) is the largest integer that <=R
    $mos = N+1
    and in the end, an amount of
    $amt = $ccb*($mmp*(1.0-$r^(N-1))/(1-$r)+$r^N)
    has been paid in total.

    let me know if this is not detailed enough.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    Article by: Nadia
    Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…
    Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now