In this article, I am going to show how to create BPay Ref number (CRN) using c# based on the mod10 version 5 algorithm (MOD10V5).
protected void Page_Load(object sender, EventArgs e) { BPAYRefNumber bpay = new BPAYRefNumber(); string BPAYYref = bpay.generateValidMOD10V5Number("45895624"); Response.Write("MOD10V5 Number =" + BPAYYref); Response.Write("<br/>The number is valid =" + bpay.isNumberValidMOD10V5(BPAYYref)); } public class BPAYRefNumber { int checkDigit = 0; int digit = 0; Boolean result = false; String response = null; /** * Returns the checkbit for a number as per Luhn Mod 10 Version 5 * * @param number * @return */ public int getCheckDigitMod10V5(String number) { checkDigit = 0; digit = 0; try { for (int i = 0; i < number.Length; i++) { digit = int.Parse(number.Substring(i, 1)); checkDigit += digit * (i + 1); } checkDigit = checkDigit % 10; } catch { } return checkDigit; } /** * Checks if a number is valid per Luhn Mod 10 Version 5 * * @param number * @return */ public Boolean isNumberValidMOD10V5(String number) { try { result = ("" + getCheckDigitMod10V5(number.Substring(0, number.Length - 1)) ).Equals(number.Substring(number.Length - 1, 1)); } catch { result = false; } return result; } /** * Generates a valid MOD10V5 number * * @param number * @return */ public String generateValidMOD10V5Number(String number) { return number + this.getCheckDigitMod10V5(number); } }
BPAY Ref Number (BPAY CRN) using C# http://t.co/q7YVjS4yyJ
Ashish’s Blog : BPAY Ref Number (BPAY CRN) using C# http://t.co/SBSbmAsNAi #jQuery
Thanks, and here’s the BPAY CRN generation in PHP (just a few lines of code indeed), with a Check digit using Luhn algorithm mod 10 version 5 (MOD10V05) –
http://blog.silkcode.com/2013/12/bpay-payments-customer-reference-number.html
[…] How to create BPAY CRN http://www.ashishblog.com/bpay-ref-number-bpay-crn-using-c/ […]