Process an ex gratia payment for a claim coverage payment detail record.
API Version
66.0
Requires Chatter
No
Signature
public static ConnectApi.PayExGratiaClaimCvrPaymentDetailRep PayExGratiaClaimCvrPaymentDetail(String claimId, String coverageId, String paymentDetailId, ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep PayExGratiaClaimCvrPaymentDetailInput)
Parameters
claimId
- Type: String
- ID of the claim.
coverageId
- Type: String
- ID of the coverage.
paymentDetailId
- Type: String
- ID of the payment detail.
PayExGratiaClaimCvrPaymentDetailInput
- Type: ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep
- Details to process the ex gratia payment.
Return Value
Example
Class Definition
This is a sample Apex code to define the PayExGratiaClaimCvrPaymentDetail class to process ex gratia payment.
public with sharing class PayExGratiaClaimCvrPaymentDetailCallable implements System.Callable { public Object call(String action, Map<String, Object> args) { // Retrieve the input and output maps from the arguments Map<String, Object> inputMap = (Map<String, Object>) args.get('input'); Map<String, Object> outputMap = (Map<String, Object>) args.get('output'); // Check the action type if (action == 'payExGratiaClaimCvrPaymentDetail') { // Retrieve the required parameters from the input map String claimId = (String) inputMap.get('claimId'); String claimCoverageId = (String) inputMap.get('claimCoverageId'); String paymentDetailId = (String) inputMap.get('paymentDetailId'); ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep payExGratiaInputRep = (ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep) inputMap.get('PayExGratiaClaimCvrPaymentDetailInput'); if (payExGratiaInputRep == null) { payExGratiaInputRep = new ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep(); } payExGratiaInputRep.options = new ConnectApi.PayClaimCoveragePaymentDetailOptionsInputRep(); payExGratiaInputRep.options.shouldCheckFinancialAuthority = true; payExGratiaInputRep.options.shouldVerifyReserveLimit = true; System.debug('Start of connect API call to pay ex gratia claim coverage payment detail'); System.debug('Claim ID: ' + claimId); System.debug('Claim Coverage ID: ' + claimCoverageId); System.debug('Payment Detail ID: ' + paymentDetailId); // Initialize the output representation ConnectApi.PayExGratiaClaimCvrPaymentDetailRep payExGratiaResponse; // Call the Connect API to pay ex gratia try { // Call the Connect API resource directly // The endpoint is: /connect/insurance/claims/${claimId}/coverages/${coverageId}/payment-details/${paymentDetailId}/pay-ex-gratia payExGratiaResponse = ConnectApi.InsuranceClaimFamily.PayExGratiaClaimCvrPaymentDetail( payExGratiaInputRep, claimId, claimCoverageId, paymentDetailId ); System.debug('Pay ex gratia completed successfully: ' + payExGratiaResponse); // Put the payExGratiaResponse in the output map outputMap.put('payExGratiaResponse', payExGratiaResponse); outputMap.put('isSuccess', payExGratiaResponse.isSuccess); // Check if there are any errors if (payExGratiaResponse.errors != null && !payExGratiaResponse.errors.isEmpty()) { outputMap.put('errors', payExGratiaResponse.errors); System.debug('Errors found: ' + payExGratiaResponse.errors); } } catch (Exception e) { System.debug('Error while paying ex gratia: ' + e.getMessage()); outputMap.put('error', e.getMessage()); outputMap.put('isSuccess', false); } return payExGratiaResponse; } // If the action is not recognized, return null return null; } }
Usage Example
This example shows how to call the PayExGratiaClaimCvrPaymentDetail class and include the required input data.
PayExGratiaClaimCvrPaymentDetailCallable callable = new PayExGratiaClaimCvrPaymentDetailCallable(); // Prepare the input arguments Map<String, Object> input = new Map<String, Object>(); // Set the required parameters input.put('claimId', '0ZkSB0000001AVH0A2'); // Claim ID input.put('claimCoverageId', '0kPSB000000GHdu2AG'); // Claim Coverage ID input.put('paymentDetailId', '0l2SB000000CLsMYAW'); // Payment Detail ID // Create the input representation object // First create a Map with the properties Map<String, Object> payExGratiaInputMap = new Map<String, Object>(); payExGratiaInputMap.put('reason', 'Customer service goodwill payment'); Map<String, Object> optionsMap = new Map<String, Object>(); optionsMap.put('shouldCheckFinancialAuthority', true); optionsMap.put('shouldVerifyReserveLimit', true); payExGratiaInputMap.put('options', optionsMap); // Convert the Map to ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep using JSON.deserialize String jsonString = JSON.serialize(payExGratiaInputMap); ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep payExGratiaInputRep = (ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep) JSON.deserialize(jsonString, ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep.class); input.put('PayExGratiaClaimCvrPaymentDetailInput', payExGratiaInputRep); // Prepare the output map Map<String, Object> output = new Map<String, Object>(); // Prepare the args map Map<String, Object> args = new Map<String, Object>(); args.put('input', input); args.put('output', output); // Call the 'payExGratiaClaimCvrPaymentDetail' action Object result = callable.call('payExGratiaClaimCvrPaymentDetail', args); // Check the result if (result != null) { System.debug('payExGratiaClaimCvrPaymentDetail processed successfully: ' + result); // Access the processed payment data ConnectApi.PayExGratiaClaimCvrPaymentDetailRep paymentData = (ConnectApi.PayExGratiaClaimCvrPaymentDetailRep) result; // Process the result as needed System.debug('Pay Ex Gratia Payment Data: ' + paymentData); // Check if the payment was successful if (paymentData.isSuccess) { System.debug('Pay Ex Gratia was successful'); System.debug('Paid Amount: ' + paymentData.paidAmount); System.debug('Remaining Reserves: ' + paymentData.remainingReserves); System.debug('Claim Payment Summary ID: ' + paymentData.claimPaymentSummaryId); System.debug('Consumed Limit Count: ' + paymentData.consumedLimitCount); System.debug('Exceeded Amount: ' + paymentData.exceededAmount); System.debug('Exceeded Count: ' + paymentData.exceededCount); System.debug('Has Financial Authority: ' + paymentData.hasFinancialAuthority); System.debug('Is Financial Authority Configured: ' + paymentData.isFinancialAuthorityConfigured); if (paymentData.warnings != null && !paymentData.warnings.isEmpty()) { System.debug('Warnings: ' + paymentData.warnings); } if (paymentData.insPolicyLimitTrackingIds != null && !paymentData.insPolicyLimitTrackingIds.isEmpty()) { System.debug('Insurance Policy Limit Tracking IDs: ' + paymentData.insPolicyLimitTrackingIds); } } else { System.debug('Pay Ex Gratia failed'); if (paymentData.errors != null) { System.debug('Error details: ' + paymentData.errors); } } } else { System.debug('Error occurred: ' + output.get('error')); }