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

Return Value 

Type: ConnectApi.PayExGratiaClaimCvrPaymentDetailRep

Example 

Class Definition

This is a sample Apex code to define the PayExGratiaClaimCvrPaymentDetail class to process ex gratia payment.

1public with sharing class PayExGratiaClaimCvrPaymentDetailCallable implements System.Callable {
2
3    public Object call(String action, Map<String, Object> args) {
4        // Retrieve the input and output maps from the arguments
5        Map<String, Object> inputMap = (Map<String, Object>) args.get('input');
6        Map<String, Object> outputMap = (Map<String, Object>) args.get('output');
7
8        // Check the action type
9        if (action == 'payExGratiaClaimCvrPaymentDetail') {
10            // Retrieve the required parameters from the input map
11            String claimId = (String) inputMap.get('claimId');
12            String claimCoverageId = (String) inputMap.get('claimCoverageId');
13            String paymentDetailId = (String) inputMap.get('paymentDetailId');
14
15            ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep payExGratiaInputRep =
16                (ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep) inputMap.get('PayExGratiaClaimCvrPaymentDetailInput');
17            if (payExGratiaInputRep == null) {
18                payExGratiaInputRep = new ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep();
19            }
20            payExGratiaInputRep.options = new ConnectApi.PayClaimCoveragePaymentDetailOptionsInputRep();
21            payExGratiaInputRep.options.shouldCheckFinancialAuthority = true;
22            payExGratiaInputRep.options.shouldVerifyReserveLimit = true;
23
24            System.debug('Start of connect API call to pay ex gratia claim coverage payment detail');
25            System.debug('Claim ID: ' + claimId);
26            System.debug('Claim Coverage ID: ' + claimCoverageId);
27            System.debug('Payment Detail ID: ' + paymentDetailId);
28
29            // Initialize the output representation
30            ConnectApi.PayExGratiaClaimCvrPaymentDetailRep payExGratiaResponse;
31
32            // Call the Connect API to pay ex gratia
33            try {
34                // Call the Connect API resource directly
35                // The endpoint is: /connect/insurance/claims/${claimId}/coverages/${coverageId}/payment-details/${paymentDetailId}/pay-ex-gratia
36                payExGratiaResponse = ConnectApi.InsuranceClaimFamily.PayExGratiaClaimCvrPaymentDetail(
37                    payExGratiaInputRep,
38                    claimId,
39                    claimCoverageId,
40                    paymentDetailId
41                );
42
43                System.debug('Pay ex gratia completed successfully: ' + payExGratiaResponse);
44
45                // Put the payExGratiaResponse in the output map
46                outputMap.put('payExGratiaResponse', payExGratiaResponse);
47                outputMap.put('isSuccess', payExGratiaResponse.isSuccess);
48
49                // Check if there are any errors
50                if (payExGratiaResponse.errors != null && !payExGratiaResponse.errors.isEmpty()) {
51                    outputMap.put('errors', payExGratiaResponse.errors);
52                    System.debug('Errors found: ' + payExGratiaResponse.errors);
53                }
54            }
55            catch (Exception e) {
56                System.debug('Error while paying ex gratia: ' + e.getMessage());
57                outputMap.put('error', e.getMessage());
58                outputMap.put('isSuccess', false);
59            }
60
61            return payExGratiaResponse;
62        }
63
64        // If the action is not recognized, return null
65        return null;
66    }
67}

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');
15Map<String, Object> optionsMap = new Map<String, Object>();
16optionsMap.put('shouldCheckFinancialAuthority', true);
17optionsMap.put('shouldVerifyReserveLimit', true);
18payExGratiaInputMap.put('options', optionsMap);
19
20// Convert the Map to ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep using JSON.deserialize
21String jsonString = JSON.serialize(payExGratiaInputMap);
22ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep payExGratiaInputRep =
23    (ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep) JSON.deserialize(jsonString, ConnectApi.PayExGratiaClaimCvrPaymentDetailInputRep.class);
24
25input.put('PayExGratiaClaimCvrPaymentDetailInput', payExGratiaInputRep);
26
27// Prepare the output map
28Map<String, Object> output = new Map<String, Object>();
29
30// Prepare the args map
31Map<String, Object> args = new Map<String, Object>();
32args.put('input', input);
33args.put('output', output);
34
35// Call the 'payExGratiaClaimCvrPaymentDetail' action
36Object result = callable.call('payExGratiaClaimCvrPaymentDetail', args);
37
38// Check the result
39if (result != null) {
40    System.debug('payExGratiaClaimCvrPaymentDetail processed successfully: ' + result);
41
42    // Access the processed payment data
43    ConnectApi.PayExGratiaClaimCvrPaymentDetailRep paymentData =
44        (ConnectApi.PayExGratiaClaimCvrPaymentDetailRep) result;
45
46    // Process the result as needed
47    System.debug('Pay Ex Gratia Payment Data: ' + paymentData);
48
49    // Check if the payment was successful
50    if (paymentData.isSuccess) {
51        System.debug('Pay Ex Gratia was successful');
52        System.debug('Paid Amount: ' + paymentData.paidAmount);
53        System.debug('Remaining Reserves: ' + paymentData.remainingReserves);
54        System.debug('Claim Payment Summary ID: ' + paymentData.claimPaymentSummaryId);
55        System.debug('Consumed Limit Count: ' + paymentData.consumedLimitCount);
56        System.debug('Exceeded Amount: ' + paymentData.exceededAmount);
57        System.debug('Exceeded Count: ' + paymentData.exceededCount);
58        System.debug('Has Financial Authority: ' + paymentData.hasFinancialAuthority);
59        System.debug('Is Financial Authority Configured: ' + paymentData.isFinancialAuthorityConfigured);
60        if (paymentData.warnings != null && !paymentData.warnings.isEmpty()) {
61            System.debug('Warnings: ' + paymentData.warnings);
62        }
63
64        if (paymentData.insPolicyLimitTrackingIds != null && !paymentData.insPolicyLimitTrackingIds.isEmpty()) {
65            System.debug('Insurance Policy Limit Tracking IDs: ' + paymentData.insPolicyLimitTrackingIds);
66        }
67    } else {
68        System.debug('Pay Ex Gratia failed');
69        if (paymentData.errors != null) {
70            System.debug('Error details: ' + paymentData.errors);
71        }
72    }
73} else {
74    System.debug('Error occurred: ' + output.get('error'));
75}