My flow has a screen where the users enters a value in a currency field that has 2 decimal places and that value gets passed to a variable in an Apex Action within the flow. For some reason, when I debug the flow, it shows it passing the decimal places (ex. $200.00) to the Apex, but once it gets passed to my Apex variable it is represented as only a whole number (200).
I'm using a Decimal variable in my method so I'm not sure why it is dropping the decimal points.
Do I need to specify the decimal points on the Decimal variable? I would think that it would just carry over.
Here's my flow debug:
And Here's what is showing in my debug log for the Apex Action:
This is how I'm declaring my variable in the Apex:
public without sharing class chargentAPI_PartialRefund_Flow {
public class FlowInputs {
@InvocableVariable public String transactionId;
@InvocableVariable public Decimal refundAmount;
}
EDIT to Add Screen shots of Error by 3rd party app:
Approved:
Not Approved:
Here is the full code:
public without sharing class chargentAPI_PartialRefund_Flow {
//Set the flow Input variables
public class FlowInputs {
@InvocableVariable public String transactionId;
@InvocableVariable public Decimal refundAmount;
}
@InvocableMethod
//Pass the input variables to the list
public static void issueRefund (List<FlowInputs> Request) {
String transactionId = request[0].transactionId;
Decimal refundAmount = request[0].refundAmount;
//Add the variables to the callout
callout(transactionId, refundAmount);
}
@future(callout = true)
//Pass the variables to the future callout
public static void callout(String transactionId, Decimal refundAmount) {
//Generate the input data based on Chargent API documentation
List<ChargentApiInput> createChargentApiInput = New List<ChargentApiInput>();
ChargentApiInput gtwyData = new ChargentApiInput();
gtwyData.ObjectId = transactionId;
gtwyData.amount = refundAmount;
createChargentApiInput.add(gtwyData);
String jsonRefundData = JSON.serialize(gtwyData);
System.debug('JSON Input: '+jsonRefundData);
//Invocate refund click json method on Chargent API with json data as a parameter
ChargentOrders.TChargentOperations.TChargentResult refundResult = ChargentOrders.TChargentOperations.RefundTransaction_ClickJSON(jsonRefundData);
System.debug('Refund Result :'+refundResult.Message);
String jsonString = refundResult.responseData;
//GetResponse respsonse = (GetResponse) JSON.deserialize(jsonString, GetResponse.class);
JSONParser parser = JSON.createParser(jsonString);
parser.nextToken();
parser.nextValue();
ID recordId = parser.getIdValue();
System.debug('Record Id' + recordId);
ChargentOrders__Transaction__c newTransaction = [SELECT Id, Main_Transaction__c FROM ChargentOrders__Transaction__c WHERE Id = :recordId];
newTransaction.Main_Transaction__c = TransactionId;
UPDATE newTransaction;
}
class ChargentApiInput{
String ObjectId;
Decimal Amount;
}
}
200.42
), do you still see the same result?