CRE Secure Rounding Problem

7 replies [Last post]
isdept
Offline
Joined: 10/25/2011
Status: 
Answered

I am receiving an error in the error log when I try to change a membership plan using the CRE Secure module. I'm upgrading a $9/month plan to a $99/year plan. Here it is:

Unknown Error: Array ( [Warning:__explode()__function.explode]: Empty delimiter in /var/www/vhosts/cresecure.net/securepayments/includes/classes/authnetcim.php on line 472 code=E00003 [message] => The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:amount' element is invalid - The value '91.460184811828' is invalid according to its datatype 'Decimal' - The FractionDigits constraint failed. [error] => 1 [mPAN] => XXXXXXXXXXXX#### [type] => Visa [exp] => 0115 )Logged at ../modules/ms_core/gateways/ms_cres/ms_cres.module line 916

It appears that because the user has already been charged $9 for the month, your module is doing an automatic calculation on the $99/year to give him credit for his earlier payment and automatically charge the correct amount. However, it's passing a super-complex amount value which CRE Secure can't process: 91.460184811828. I believe CRE Secure can only accept 2 decimal places.

I don't know where in the code you feel would be best to round this value to two decimal places. Perhaps the best solution would be to round $credit in the ms_membership_change_membership_form_submit() function in ms_membership.module. For example, I fixed it by changing line 1825:

  1. $data['residual_credit'] = $credit;

to
  1. $data['residual_credit'] = round($credit, 2);

Would you be able to implement this or a similar fix?

isdept
Offline
Joined: 10/25/2011
I checked the new MS Core

I checked the new MS Core 7.x-2.4 release and noticed the above rounding suggestion wasn't implemented in ms_membership.module. I was curious if you had taken a different approach to fix this or if you were just postponing this fix to a later release?

Leighton Whiting
Offline
Joined: 06/02/2009
Sorry, I must have missed

Sorry, I must have missed this topic. I'll get the fix added in the next release. Thanks for reporting this!

Sincerely,

Leighton Whiting

isdept
Offline
Joined: 10/25/2011
Hello Leighton! I just

Hello Leighton!

I just upgraded to the latest MS Core 7.x-2.5 and MS Memberships 7.x-7.x-dev and this error still isn't fixed. Were you going to add the rounding code to the MS Core CRE Secure Module or in the ms_membership_change_membership_form_submit() function of the MS Memberships module as explained above?

Robert

Leighton Whiting
Offline
Joined: 06/02/2009
Hmm, I thought I had that one

Hmm, I thought I had that one kicked. Can you try this file and see if it fixes the issue?

-Leighton

AttachmentSize
ms_core.classes.zip 2.76 KB
isdept
Offline
Joined: 10/25/2011
I'm sorry, but this patch

I'm sorry, but this patch still doesn't fix the problem. Still getting the same error:

Unknown Error: <pre>Array ( [Warning:__explode()__function.explode]: Empty delimiter in /var/www/vhosts/cresecure.net/securepayments/includes/classes/authnetcim.php on line 472 code=E00003 [message] => The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:amount' element is invalid - The value '11.946551724138' is invalid according to its datatype 'Decimal' - The FractionDigits constraint failed. [error] => 1 [mPAN] => XXXXXXXXXXXX#### [type] => MasterCard [exp] => 0115 )Logged at .../modules/ms_core/gateways/ms_cres/ms_cres.module line 916

Rounding $data['residual_credit'] in ms_membership.module as explained above does work.

Leighton Whiting
Offline
Joined: 06/02/2009
I ended up rounding it in the

I ended up rounding it in the ms_core_calculate_credit() function. Should work now. It'll be in the next release. Probably tomorrow or Sunday.

-Leighton

isdept
Offline
Joined: 10/25/2011
Your fixed worked. The latest

Your fixed worked. The latest version of MS Core changes memberships without a problem. Thank you!

Twitter Feed