You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Scott Gray <sc...@hotwaxmedia.com> on 2009/12/06 20:40:16 UTC
Re: svn commit: r887464 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java
Hi Jacques,
It pays to be careful when doing this, if these values are being sent
out externally it can cause problems when the BigDecimal's are
converted to Strings, some APIs require that currency amounts are sent
with 2 decimal places. For example PayPal will return an error if
amounts are sent with anything other than 2dp.
It's okay to do it if the values are only used by OFBiz but be careful
that you're not changing anything that is leaving OFBiz.
Regards
Scott
HotWax Media
http://www.hotwaxmedia.com
On 5/12/2009, at 1:23 PM, jleroux@apache.org wrote:
> Author: jleroux
> Date: Sat Dec 5 00:23:48 2009
> New Revision: 887464
>
> URL: http://svn.apache.org/viewvc?rev=887464&view=rev
> Log:
> replace some new BigDecimal("0.00") by BigDecimal.ZERO
>
> Modified:
> ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/
> thirdparty/sagepay/SagePayPaymentServices.java
>
> Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/
> accounting/thirdparty/sagepay/SagePayPaymentServices.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java?rev=887464&r1=887463&r2=887464&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/
> thirdparty/sagepay/SagePayPaymentServices.java (original)
> +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/
> thirdparty/sagepay/SagePayPaymentServices.java Sat Dec 5 00:23:48
> 2009
> @@ -212,19 +212,19 @@
> }
> } else if (status != null && "INVALID".equals(status)) {
> Debug.logInfo("SagePay - Invalid authorisation
> request for order : " + vendorTxCode, module);
> - result =
> SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE,
> null, null, new BigDecimal("0.00"), "INVALID", vendorTxCode,
> statusDetail);
> + result =
> SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE,
> null, null, BigDecimal.ZERO, "INVALID", vendorTxCode, statusDetail);
> } else if (status != null && "MALFORMED".equals(status)) {
> Debug.logInfo("SagePay - Malformed authorisation
> request for order : " + vendorTxCode, module);
> - result =
> SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE,
> null, null, new BigDecimal("0.00"), "MALFORMED", vendorTxCode,
> statusDetail);
> + result =
> SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE,
> null, null, BigDecimal.ZERO, "MALFORMED", vendorTxCode, statusDetail);
> } else if (status != null && "NOTAUTHED".equals(status)) {
> Debug.logInfo("SagePay - NotAuthed authorisation
> request for order : " + vendorTxCode, module);
> - result =
> SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE,
> null, securityKey, new BigDecimal("0.00"), vpsTxId, vendorTxCode,
> statusDetail);
> + result =
> SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE,
> null, securityKey, BigDecimal.ZERO, vpsTxId, vendorTxCode,
> statusDetail);
> } else if (status != null && "REJECTED".equals(status)) {
> Debug.logInfo("SagePay - Rejected authorisation
> request for order : " + vendorTxCode, module);
> result =
> SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE,
> null, securityKey, new BigDecimal(amount), vpsTxId, vendorTxCode,
> statusDetail);
> } else {
> Debug.logInfo("SagePay - Invalid status " + status +
> " received for order : " + vendorTxCode, module);
> - result =
> SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE,
> null, null, new BigDecimal("0.00"), "ERROR", vendorTxCode,
> statusDetail);
> + result =
> SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE,
> null, null, BigDecimal.ZERO, "ERROR", vendorTxCode, statusDetail);
> }
> } catch(GenericServiceException e) {
> Debug.logError(e, "Error in calling
> SagePayPaymentAuthentication", module);
> @@ -394,7 +394,7 @@
> result =
> SagePayUtil.buildCardRefundPaymentResponse(Boolean.TRUE, txAuthNo,
> amount, vpsTxId, orderId, statusDetail);
> } else {
> Debug.logInfo("SagePay - Invalid status " + status +
> " received for order : " + orderId, module);
> - result =
> SagePayUtil.buildCardRefundPaymentResponse(Boolean.FALSE, null, new
> BigDecimal("0.00"), status, orderId, statusDetail);
> + result =
> SagePayUtil.buildCardRefundPaymentResponse(Boolean.FALSE, null,
> BigDecimal.ZERO, status, orderId, statusDetail);
> }
>
> } catch(GenericServiceException e) {
> @@ -437,13 +437,13 @@
> result =
> SagePayUtil.buildCardVoidPaymentResponse(Boolean.TRUE, amount,
> "SUCCESS", orderId, statusDetail);
> } else if (status != null && "MALFORMED".equals(status)) {
> Debug.logInfo("SagePay - Malformed void request for
> order : " + orderId, module);
> - result =
> SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, new
> BigDecimal("0.00"), "MALFORMED", orderId, statusDetail);
> + result =
> SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE,
> BigDecimal.ZERO, "MALFORMED", orderId, statusDetail);
> } else if (status != null && "INVALID".equals(status)){
> Debug.logInfo("SagePay - Invalid void request for
> order : " + orderId, module);
> - result =
> SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, new
> BigDecimal("0.00"), "INVALID", orderId, statusDetail);
> + result =
> SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE,
> BigDecimal.ZERO, "INVALID", orderId, statusDetail);
> } else if (status != null && "ERROR".equals(status)){
> Debug.logInfo("SagePay - Error in void request for
> order : " + orderId, module);
> - result =
> SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, new
> BigDecimal("0.00"), "ERROR", orderId, statusDetail);
> + result =
> SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE,
> BigDecimal.ZERO, "ERROR", orderId, statusDetail);
> }
>
> } catch(GenericServiceException e) {
>
>
Re: svn commit: r887464 - /ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java
Posted by Jacques Le Roux <ja...@les7arts.com>.
Hi Scott,
I think we already spoke about that.
So I did not change for other cases (ie PayPalServices.java & ValueLinkApi.java) where String are manipulated.
Here it was only ZERO initialisation, hence the change.
Thanks to care (it's restful to know, at least, someone do :)
Jacques
From: "Scott Gray" <sc...@hotwaxmedia.com>
> Hi Jacques,
>
> It pays to be careful when doing this, if these values are being sent out externally it can cause problems when the BigDecimal's
> are converted to Strings, some APIs require that currency amounts are sent with 2 decimal places. For example PayPal will
> return an error if amounts are sent with anything other than 2dp.
>
> It's okay to do it if the values are only used by OFBiz but be careful that you're not changing anything that is leaving OFBiz.
>
> Regards
> Scott
>
> HotWax Media
> http://www.hotwaxmedia.com
>
>
> On 5/12/2009, at 1:23 PM, jleroux@apache.org wrote:
>
>> Author: jleroux
>> Date: Sat Dec 5 00:23:48 2009
>> New Revision: 887464
>>
>> URL: http://svn.apache.org/viewvc?rev=887464&view=rev
>> Log:
>> replace some new BigDecimal("0.00") by BigDecimal.ZERO
>>
>> Modified:
>> ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/ thirdparty/sagepay/SagePayPaymentServices.java
>>
>> Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/ accounting/thirdparty/sagepay/SagePayPaymentServices.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/sagepay/SagePayPaymentServices.java?rev=887464&r1=887463&r2=887464&view=diff
>> = = = = = = = = ======================================================================
>> --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/ thirdparty/sagepay/SagePayPaymentServices.java (original)
>> +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/ thirdparty/sagepay/SagePayPaymentServices.java Sat Dec 5
>> 00:23:48 2009
>> @@ -212,19 +212,19 @@
>> }
>> } else if (status != null && "INVALID".equals(status)) {
>> Debug.logInfo("SagePay - Invalid authorisation request for order : " + vendorTxCode, module);
>> - result = SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE, null, null, new BigDecimal("0.00"),
>> "INVALID", vendorTxCode, statusDetail);
>> + result = SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE, null, null, BigDecimal.ZERO,
>> "INVALID", vendorTxCode, statusDetail);
>> } else if (status != null && "MALFORMED".equals(status)) {
>> Debug.logInfo("SagePay - Malformed authorisation request for order : " + vendorTxCode, module);
>> - result = SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE, null, null, new BigDecimal("0.00"),
>> "MALFORMED", vendorTxCode, statusDetail);
>> + result = SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE, null, null, BigDecimal.ZERO,
>> "MALFORMED", vendorTxCode, statusDetail);
>> } else if (status != null && "NOTAUTHED".equals(status)) {
>> Debug.logInfo("SagePay - NotAuthed authorisation request for order : " + vendorTxCode, module);
>> - result = SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE, null, securityKey, new
>> BigDecimal("0.00"), vpsTxId, vendorTxCode, statusDetail);
>> + result = SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE, null, securityKey, BigDecimal.ZERO,
>> vpsTxId, vendorTxCode, statusDetail);
>> } else if (status != null && "REJECTED".equals(status)) {
>> Debug.logInfo("SagePay - Rejected authorisation request for order : " + vendorTxCode, module);
>> result = SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE, null, securityKey, new
>> BigDecimal(amount), vpsTxId, vendorTxCode, statusDetail);
>> } else {
>> Debug.logInfo("SagePay - Invalid status " + status + " received for order : " + vendorTxCode, module);
>> - result = SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE, null, null, new BigDecimal("0.00"),
>> "ERROR", vendorTxCode, statusDetail);
>> + result = SagePayUtil.buildCardAuthorisationPaymentResponse(Boolean.FALSE, null, null, BigDecimal.ZERO,
>> "ERROR", vendorTxCode, statusDetail);
>> }
>> } catch(GenericServiceException e) {
>> Debug.logError(e, "Error in calling SagePayPaymentAuthentication", module);
>> @@ -394,7 +394,7 @@
>> result = SagePayUtil.buildCardRefundPaymentResponse(Boolean.TRUE, txAuthNo, amount, vpsTxId, orderId,
>> statusDetail);
>> } else {
>> Debug.logInfo("SagePay - Invalid status " + status + " received for order : " + orderId, module);
>> - result = SagePayUtil.buildCardRefundPaymentResponse(Boolean.FALSE, null, new BigDecimal("0.00"), status,
>> orderId, statusDetail);
>> + result = SagePayUtil.buildCardRefundPaymentResponse(Boolean.FALSE, null, BigDecimal.ZERO, status, orderId,
>> statusDetail);
>> }
>>
>> } catch(GenericServiceException e) {
>> @@ -437,13 +437,13 @@
>> result = SagePayUtil.buildCardVoidPaymentResponse(Boolean.TRUE, amount, "SUCCESS", orderId, statusDetail);
>> } else if (status != null && "MALFORMED".equals(status)) {
>> Debug.logInfo("SagePay - Malformed void request for order : " + orderId, module);
>> - result = SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, new BigDecimal("0.00"), "MALFORMED", orderId,
>> statusDetail);
>> + result = SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, BigDecimal.ZERO, "MALFORMED", orderId,
>> statusDetail);
>> } else if (status != null && "INVALID".equals(status)){
>> Debug.logInfo("SagePay - Invalid void request for order : " + orderId, module);
>> - result = SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, new BigDecimal("0.00"), "INVALID", orderId,
>> statusDetail);
>> + result = SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, BigDecimal.ZERO, "INVALID", orderId,
>> statusDetail);
>> } else if (status != null && "ERROR".equals(status)){
>> Debug.logInfo("SagePay - Error in void request for order : " + orderId, module);
>> - result = SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, new BigDecimal("0.00"), "ERROR", orderId,
>> statusDetail);
>> + result = SagePayUtil.buildCardVoidPaymentResponse(Boolean.FALSE, BigDecimal.ZERO, "ERROR", orderId,
>> statusDetail);
>> }
>>
>> } catch(GenericServiceException e) {
>>
>>
>
>