diff --git a/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/payment/AmountChargeHandler.java b/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/payment/AmountChargeHandler.java index 0c12fe6..89d93a4 100644 --- a/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/payment/AmountChargeHandler.java +++ b/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/payment/AmountChargeHandler.java @@ -159,7 +159,7 @@ public boolean handle(MessageContext context) throws Exception { } sendingAddress = PaymentUtil.decodeSendingAddressIfMasked(executor, context, sendingAddress); - JSONObject objAmountTransaction = jsonBody.getJSONObject("amountTransaction"); + JSONObject objAmountTransaction = jsonBody.getJSONObject(AttributeConstants.AMOUNT_TRANSACTION); if (!objAmountTransaction.isNull(AttributeConstants.CLIENT_CORRELATOR)) { clientCorrelator = nullOrTrimmed(objAmountTransaction.get(AttributeConstants.CLIENT_CORRELATOR).toString()); } @@ -183,9 +183,11 @@ public boolean handle(MessageContext context) throws Exception { clientCorrelator = clientCorrelator + ":" + hubGatewayId + ":" + appId; } - if (objAmountTransaction.getJSONObject("paymentAmount").has("chargingMetaData")) { + JSONObject paymentAmount = objAmountTransaction.getJSONObject(AttributeConstants.PAYMENT_AMOUNT); + if (paymentAmount.has(AttributeConstants.CHARGING_META_DATA) && + !paymentAmount.isNull(AttributeConstants.CHARGING_META_DATA)) { - JSONObject chargingMeta = objAmountTransaction.getJSONObject("paymentAmount").getJSONObject("chargingMetaData"); + JSONObject chargingMeta = paymentAmount.getJSONObject(AttributeConstants.CHARGING_META_DATA); boolean isAggregator = PaymentUtil.isAggregator(context); diff --git a/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/payment/AmountRefundHandler.java b/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/payment/AmountRefundHandler.java index f7ae3cd..94eff5a 100644 --- a/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/payment/AmountRefundHandler.java +++ b/mediation-old/src/main/java/com/wso2telco/dep/mediator/impl/payment/AmountRefundHandler.java @@ -29,14 +29,11 @@ import com.wso2telco.dep.mediator.internal.ApiUtils; import com.wso2telco.dep.mediator.internal.Type; import com.wso2telco.dep.mediator.internal.UID; -import com.wso2telco.dep.mediator.mediationrule.OriginatingCountryCalculatorIDD; import com.wso2telco.dep.mediator.service.PaymentService; import com.wso2telco.dep.mediator.util.*; import com.wso2telco.dep.oneapivalidation.exceptions.CustomException; import com.wso2telco.dep.oneapivalidation.service.IServiceValidate; import com.wso2telco.dep.oneapivalidation.service.impl.payment.ValidateRefund; -import com.wso2telco.dep.subscriptionvalidator.util.ValidatorUtils; -import com.wso2telco.dep.user.masking.configuration.UserMaskingConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpStatus; @@ -45,7 +42,6 @@ import org.apache.synapse.core.axis2.Axis2MessageContext; import org.json.JSONException; import org.json.JSONObject; -import org.wso2.carbon.utils.CarbonUtils; import java.io.File; import java.util.HashMap; @@ -194,11 +190,12 @@ public boolean handle(MessageContext context) throws Exception { clientCorrelator = clientCorrelator + ":" + hubGatewayId + ":" + appId; } - JSONObject paymentAmount = objAmountTransaction.getJSONObject("paymentAmount"); + JSONObject paymentAmount = objAmountTransaction.getJSONObject(AttributeConstants.PAYMENT_AMOUNT); - if (paymentAmount.has("chargingMetaData")) { + if (paymentAmount.has(AttributeConstants.CHARGING_META_DATA) && + !paymentAmount.isNull(AttributeConstants.CHARGING_META_DATA)) { - JSONObject chargingMetaData = paymentAmount.getJSONObject("chargingMetaData"); + JSONObject chargingMetaData = paymentAmount.getJSONObject(AttributeConstants.CHARGING_META_DATA); boolean isAggregator = PaymentUtil.isAggregator(context); if (isAggregator && !chargingMetaData.isNull("onBehalfOf")) { diff --git a/mediation-old/src/main/java/com/wso2telco/dep/mediator/util/AttributeConstants.java b/mediation-old/src/main/java/com/wso2telco/dep/mediator/util/AttributeConstants.java index f1d0f6e..1e8b2a1 100644 --- a/mediation-old/src/main/java/com/wso2telco/dep/mediator/util/AttributeConstants.java +++ b/mediation-old/src/main/java/com/wso2telco/dep/mediator/util/AttributeConstants.java @@ -22,5 +22,7 @@ public class AttributeConstants { public static final String AMOUNT_TRANSACTION = "amountTransaction"; public static final String CLIENT_CORRELATOR = "clientCorrelator"; public static final String PURCHASE_CATEGORY_CODE = "purchaseCategoryCode"; + public static final String CHARGING_META_DATA = "chargingMetaData"; + public static final String PAYMENT_AMOUNT = "paymentAmount"; }