Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8267893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:41:41+00:00 2026-06-08T05:41:41+00:00

I am using the following PHP code to calculate a CRN for BPay: <?php

  • 0

I am using the following PHP code to calculate a CRN for BPay:

<?php
function LuhnCalc($number) {
  $chars = array_reverse(str_split($number, 1));
  $odd = array_intersect_key($chars, array_fill_keys(range(1, count($chars), 2), null));
  $even = array_intersect_key($chars, array_fill_keys(range(0, count($chars), 2), null));
  $even = array_map(function($n) { return ($n >= 5)?2 * $n - 9:2 * $n; }, $even);
  $total = array_sum($odd) + array_sum($even);
  return ((floor($total / 10) + 1) * 10 - $total) % 10;
}
print LuhnCalc($_GET['num']);
?>

However it seems that BPAY is version 5 of MOD 10, for which I can’t find any documentation. It seems to not be the same as MOD10.

The following numbers where tested:

2005,1597,3651,0584,9675

bPAY
2005 = 20052
1597 = 15976
3651 = 36514
0584 = 05840
9675 = 96752

MY CODE 
2005 = 20057 
1597 = 15974 
3651 = 36517 
0584 = 05843 
9675 = 96752

As you can see, none of them match the BPAY numbers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:41:43+00:00Added an answer on June 8, 2026 at 5:41 am

    This PHP function will generate BPay reference numbers based on the mod10 version 5 algorithm.

    Who knows why BPay can’t add this to their website. I only found an explanation by googling finding the algorithm being called “MOD10V05” instead of “Mod 10 version 5”.

    function generateBpayRef($number) {
    
        $number = preg_replace("/\D/", "", $number);
    
        // The seed number needs to be numeric
        if(!is_numeric($number)) return false;
    
        // Must be a positive number
        if($number <= 0) return false;
    
        // Get the length of the seed number
        $length = strlen($number);
    
        $total = 0;
    
        // For each character in seed number, sum the character multiplied by its one based array position (instead of normal PHP zero based numbering)
        for($i = 0; $i < $length; $i++) $total += $number{$i} * ($i + 1);
    
        // The check digit is the result of the sum total from above mod 10
        $checkdigit = fmod($total, 10);
    
        // Return the original seed plus the check digit
        return $number . $checkdigit;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code: PHP: // Generate Guid function NewGuid() { $s
I am using the following php shuffle function code to display a list of
Using this code: Calculate number of hours between 2 dates in PHP I want
I am using following PHP code for trigger creation but always get error, please
I'm using the following PHP code to return a json string: $itemURL = 'http://***.***.***/search?tag=Football&affiliate_id=&max_results=3';
I'm currently using the following PHP code: // Get all subordinates $subords = array();
So I'm using the following php code to set variables that are received from
OK, i was using following code to reverse a date to use in php
I am using the following code to generate excel from sql through php.this is
I'm using the following line of code to run my php file that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.