PHP code example of jn-devops / payment

1. Go to this page and download the library: Download jn-devops/payment library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jn-devops / payment example snippets


use Homeful\Payment\Payment;
use Homeful\Payment\Class\Term;

$payment = (new Payment)
    ->setPrincipal(850000.0)
    ->setTerm(new Term(20)) // 20 years
    ->setInterestRate(6.25 / 100);

$monthly = $payment->getMonthlyAmortization();
echo $monthly->format(); // e.g. PHP 6,213.00

use Homeful\Common\Classes\AddOnFeeToPayment;

$payment->addAddOnFeeToPayment(new AddOnFeeToPayment('fire insurance', 100, false));
$payment->addAddOnFeeToPayment(new AddOnFeeToPayment('mortgage redemption insurance', 200, false));

use Homeful\Common\Classes\DeductibleFeeFromPayment;

$payment->addDeductibleFee(new DeductibleFeeFromPayment('promo', 125, true));

echo $payment->getIncomeRequirement(); // e.g. PHP 20,710.00

use Homeful\Payment\PresentValue;
use Homeful\Payment\Class\Term;

$pv = (new PresentValue)
    ->setPayment(19978.48)
    ->setTerm(new Term(20))
    ->setInterestRate(7 / 100);

echo $pv->getDiscountedValue()->format(); // e.g. PHP 2,576,874.00

return [
    'default_percent_disposable_income' => 0.30,
    'max_years_to_pay' => 30,
    'max_months_to_pay' => 360,
];

$payment = (new Payment)
    ->setPrincipal(2900000)
    ->setTerm(new Term(30))
    ->setInterestRate(6.75 / 100);

echo $payment->getMonthlyAmortization()->format(); // PHP 18,809.00
bash
php artisan test --filter=Payment