PayExGratiaClaimCvrPaymentDetail(claimId, coverageId, paymentDetailId, PayExGratiaClaimCvrPaymentDetailInput)

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.

Example

Class Definition
This is a sample Apex code to define the PayExGratiaClaimCvrPaymentDetail class to process ex gratia payment.
1
2public with sharing class PayExGratiaClaimCvrPaymentDetailCallable implements System.Callable {
3
4    public Object call(String action, Map<String, Object> args) {
5        // Retrieve the input and output maps from the arguments
6        Map<String, Object> inputMap = (Map<String, Object>) args.get('input');
7        Map<String, Object> outputMap = (Map<String, Object>) args.get('output');
8        
9        // Check the action type
10        if (action == 'payExGratiaClaimCvrPaymentDetail') {
11            // Retrieve the required parameters from the input map
12            String claimId = (String) inputMap.get('claimId');
13            String claimCoverageId = (String) inputMap.get('claimCoverageId');
14            String paymentDetailId = (String) inputMap.get('paymentDetailId');
15            
16            ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep payExGratiaInputRep = 
17                (ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep) inputMap.get('PayExGratiaClaimCvrPaymentDetailInput');
18            
19            System.debug('Start of connect API call to pay ex gratia claim coverage payment detail');
20            System.debug('Claim ID: ' + claimId);
21            System.debug('Claim Coverage ID: ' + claimCoverageId);
22            System.debug('Payment Detail ID: ' + paymentDetailId);
23            
24            // Initialize the output representation
25            ConnectApi.PayExGratiaClaimCvrPaymentDetailRep payExGratiaResponse;
26            
27            // Call the Connect API to pay ex gratia
28            try {
29                // Call the Connect API resource directly
30                // The endpoint is: /connect/insurance/claims/${claimId}/coverages/${coverageId}/payment-details/${paymentDetailId}/pay-ex-gratia
31                payExGratiaResponse = ConnectApi.InsuranceClaimFamily.PayExGratiaClaimCvrPaymentDetail(
32                    payExGratiaInputRep,
33                    claimId, 
34                    claimCoverageId,
35                    paymentDetailId
36                );
37                
38                System.debug('Pay ex gratia completed successfully: ' + payExGratiaResponse);
39                
40                // Put the payExGratiaResponse in the output map
41                outputMap.put('payExGratiaResponse', payExGratiaResponse);
42                outputMap.put('isSuccess', payExGratiaResponse.isSuccess);
43                
44                // Check if there are any errors
45                if (payExGratiaResponse.errors != null && !payExGratiaResponse.errors.isEmpty()) {
46                    outputMap.put('errors', payExGratiaResponse.errors);
47                    System.debug('Errors found: ' + payExGratiaResponse.errors);
48                }
49            }
50            catch (Exception e) {
51                System.debug('Error while paying ex gratia: ' + e.getMessage());
52                outputMap.put('error', e.getMessage());
53                outputMap.put('isSuccess', false);
54            }
55            
56            return payExGratiaResponse;
57        }
58        
59        // If the action is not recognized, return null
60        return null;
61    }
62}
Usage Example
This example shows how to call the PayExGratiaClaimCvrPaymentDetail class and include the required input data.
1PayExGratiaClaimCvrPaymentDetailCallable callable = new PayExGratiaClaimCvrPaymentDetailCallable();
2
3// Prepare the input arguments
4Map<String, Object> input = new Map<String, Object>();
5
6// Set the required parameters
7input.put('claimId', '0ZkSB0000001AVH0A2');                    // Claim ID
8input.put('claimCoverageId', '0kPSB000000GHdu2AG');            // Claim Coverage ID
9input.put('paymentDetailId', '0l2SB000000CLsMYAW');           // Payment Detail ID
10
11// Create the input representation object
12// First create a Map with the properties
13Map<String, Object> payExGratiaInputMap = new Map<String, Object>();
14payExGratiaInputMap.put('reason', 'Customer service goodwill payment');
15
16// Convert the Map to ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep using JSON.deserialize
17String jsonString = JSON.serialize(payExGratiaInputMap);
18ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep payExGratiaInputRep = 
19    (ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep) JSON.deserialize(jsonString, ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep.class);
20
21input.put('PayExGratiaClaimCvrPaymentDetailInput', payExGratiaInputRep);
22
23// Prepare the output map
24Map<String, Object> output = new Map<String, Object>();
25
26// Prepare the args map
27Map<String, Object> args = new Map<String, Object>();
28args.put('input', input);
29args.put('output', output);
30
31// Call the 'payExGratiaClaimCvrPaymentDetail' action
32Object result = callable.call('payExGratiaClaimCvrPaymentDetail', args);
33
34// Check the result
35if (result != null) {
36    System.debug('payExGratiaClaimCvrPaymentDetail processed successfully: ' + result);
37    
38    // Access the processed payment data
39    ConnectApi.PayExGratiaClaimCvrPaymentDetailRep paymentData = 
40        (ConnectApi.PayExGratiaClaimCvrPaymentDetailRep) result;
41    
42    // Process the result as needed
43    System.debug('Pay Ex Gratia Payment Data: ' + paymentData);
44    
45    // Check if the payment was successful
46    if (paymentData.isSuccess) {
47        System.debug('Pay Ex Gratia was successful');
48        System.debug('Paid Amount: ' + paymentData.paidAmount);
49        System.debug('Claim Payment Summary ID: ' + paymentData.claimPaymentSummaryId);
50        System.debug('Consumed Limit Count: ' + paymentData.consumedLimitCount);
51        System.debug('Exceeded Amount: ' + paymentData.exceededAmount);
52        System.debug('Exceeded Count: ' + paymentData.exceededCount);
53        
54        if (paymentData.insPolicyLimitTrackingIds != null && !paymentData.insPolicyLimitTrackingIds.isEmpty()) {
55            System.debug('Insurance Policy Limit Tracking IDs: ' + paymentData.insPolicyLimitTrackingIds);
56        }
57    } else {
58        System.debug('Pay Ex Gratia failed');
59        if (paymentData.errors != null) {
60            System.debug('Error details: ' + paymentData.errors);
61        }
62    }
63} else {
64    System.debug('Error occurred: ' + output.get('error'));
65}