Merchant Fee Muncher (PHP Function)

0 replies
Ok so here's how coffee break discussions go. The subject was merchant fees. PayPal specifically, but the merchant itself is irrelevant. Let's say you "as a merchant" receive $100. Based on PayPal's standard fee schedule of 2.9% of the total transaction and fixed rate amount of $0.30 you will receive the total net amount of $96.80. The main topic of the discussion I had was if that $96.80 was used to purchase something from another PayPal merchant based on the same fee schedule and then if that merchant spent his net amount with another merchant and so on, then how long would it take before the original $100 is completely consumed by the merchant (i.e. they keep all of it)? The answer is 81 transactions. In order to calculate this I built a quick php function so thought I would post it here just for fun. It will work with any merchant and not just PayPal, but by default the function is setup by default based on PayPal's fee schedule. Based on bigger numbers? PayPal will take $10,000,000 in 468 transactions if the orginal transaction is kept and spent within PayPal's system and passed on through merchant to merchant in exchange for goods and services. Staggering!

Anyway, here's the code:

PHP Code:
<?php

/*

Function Arguments

    amount = Original transaction amount.
    percent = Fee percentage taken by merchant per transaction.
    fixed = Fixed rate amount taken by merchant per transcation.
    nibble = Internal function use only!

*/

function fee_muncher($amount=100,$percent=2.9,$fixed=.3,$nibble=0)
{
    global 
$history;
    
$munched $amount * ((100-$percent) / 100) - $fixed;

    
$history[$nibble] = array('gross' => number_format($amount2'.'','),
                  
'net' => number_format($munched2'.'','),
                  
'fee' => number_format($amount $munched2'.'','),
                  
'transaction' => $nibble+1);

    if (
$munched .1)
        return (
fee_muncher($munched,$percent,$fixed,$nibble+1));
    else
        return (
$nibble+1);
}

/*

Example Usage:

*/

echo fee_muncher(5000,2.9,0.30); // Number of transactions before $5,000 USD is fully assimilated by merchant.
print_r($history); // Multi-dimensional array holding all the transaction info.

?>
Just for fun remember.
#fee #function #merchant #muncher #php

Trending Topics