Creditor reference as transaction ID

  • Jyrki Nousiainen
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 3 weeks ago #43561 by Jyrki Nousiainen
Creditor reference as transaction ID was created by Jyrki Nousiainen
Hi

Do plan to add support for creditor reference ( en.wikipedia.org/wiki/Creditor_Reference ) so that it could be shown to a registrant after registration with offline payment?
This would be a huge benefit compared to current offline payment model since the current transaction ID can only be given as a note when performing the payment. With the proper creditor reference code payments could be easily matched to correct registrant and such payments would be easier to handle with banks.
Usage of this creditor reference is common practice in every payment in European Union area so I would guess that there would also others interested of this kind of possibility.

BR,
Jyrki

Please Log in or Create an account to join the conversation.

  • Jyrki Nousiainen
  • Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 11 months ago - 9 years 11 months ago #44665 by Jyrki Nousiainen
Replied by Jyrki Nousiainen on topic Creditor reference as transaction ID
Hi

I managed to get correct kind of SEPA compatible creditor reference for billing by using the shown patch.
So far I've modified only the transaction ID but is there need to modify also the registrationCode?

I haven't yet figured out how to handle this kind of change using payment plugin, so is patching the only way?
Code:
Index: com_eventbooking/com_eventbooking/packages/com_eventbooking/site/models/register.php =================================================================== --- com_eventbooking/com_eventbooking/packages/com_eventbooking/site/models/register.php (revision 12) +++ com_eventbooking/com_eventbooking/packages/com_eventbooking/site/models/register.php (working copy) @@ -74,7 +74,7 @@ $user = JFactory::getUser(); $config = EventbookingHelper::getConfig(); $row = JTable::getInstance('EventBooking', 'Registrant'); - $data['transaction_id'] = strtoupper(JUserHelper::genRandomPassword()); + $data['transaction_id'] = $this->getReferenceNumber(10); if (!$user->id && $config->user_registration) { $userId = EventbookingHelper::saveRegistration($data); @@ -311,7 +311,7 @@ $sql = 'SELECT COUNT(*) FROM #__eb_registrants WHERE group_id=' . $data['group_id']; $db->setQuery($sql); $row->number_registrants = $db->loadResult(); - $data['transaction_id'] = strtoupper(JUserHelper::genRandomPassword()); + $data['transaction_id'] = $this->getReferenceNumber(10); if (!$user->id && $config->user_registration) { $userId = EventbookingHelper::saveRegistration($data); @@ -794,4 +794,48 @@ JRequest::setVar('group_id', $rowGroup->id); return true; } + + function convertToRfNumber($code) + { + $i = 0; + $output = ""; + + while(i < strlen($code)) { + if (ctype_alpha($code[$i])) { + $output .= ord(strtolower($code[$i])) - 96 + 10; // a == 10, z == 35 + } else { + $output .= $code[$i]; + } + + $i++; + } + return $output; + } + + function calculateCreditorRef($refCode) + { + // add rf and initial checksum + $tempCode = $refCode . "RF00"; + + // convert alphas + $converted = $this->convertToRfNumber($tempCode); + // calculate check digits + $cd = 98 - $converted % 97; + + // Add RF + zero padded CC to front + $credRef = "RF" . ($cd < 10 ? "0" : "") . $cd . $refCode; + return $credRef; + } + + function getReferenceNumber($length = 10) + { + $chars = "0123456789"; + $referenceNumber = ""; + srand((double) microtime() * 1000000); + for ($i = 0; $i < $length; $i++) + { + $referenceNumber .= $chars[rand() % strlen($chars)]; + } + return $this->calculateCreditorRef($referenceNumber); + } }


Rgds,
Jyrki
Last edit: 9 years 11 months ago by Jyrki Nousiainen.

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc