CreateClaimCoveragePaymentDetail(CreateClaimCoveragePaymentDetailInput, claimId, coverageId)

Create a claim coverage payment detail record.

API Version 

65.0

Requires Chatter 

No

Signature 

public static ConnectApi.CreateClaimCoveragePaymentDetailRep CreateClaimCoveragePaymentDetail(ConnectApi.CreateClaimCovPaymentDetailInputRep CreateClaimCoveragePaymentDetailInput, String claimId, String coverageId)

Parameters 

CreateClaimCoveragePaymentDetailInput

claimId

  • Type: String
  • ID of the claim.

coverageId

  • Type: String
  • ID of the claim coverage.

Return Value 

Type: ConnectApi.CreateClaimCoveragePaymentDetailRep

Example 

Here’s an example of how to invoke the Create CCPD API by using Apex.

1public with sharing class CreateCCPDIPTest3 implements System.Callable {
2    public Object call(String action, Map<String, Object> args) {
3        System.debug('>>> Action: ' + action);
4        System.debug('>>> Args: ' + JSON.serializePretty(args));
5
6        Map<String, Object> bodyMap = new Map<String, Object>();
7
8        // Extract 'input' and 'output'
9        Map<String, Object> inputMap = (Map<String, Object>) args.get('input');
10        Map<String, Object> outputMap = (Map<String, Object>) args.get('output');
11
12        if (inputMap != null) {
13            if (inputMap.containsKey('claimId') && inputMap.get('claimId') != null) {
14                bodyMap.put('claimId', String.valueOf(inputMap.get('claimId')));
15            }
16            if (inputMap.containsKey('claimCoverageId') && inputMap.get('claimCoverageId') != null) {
17                bodyMap.put('claimCoverageId', String.valueOf(inputMap.get('claimCoverageId')));
18            }
19            if (inputMap.containsKey('claimedAmount') && inputMap.get('claimedAmount') != null) {
20                bodyMap.put('claimedAmount', String.valueOf(inputMap.get('claimedAmount')));
21            }
22            if (inputMap.containsKey('coveragePaymentType') && inputMap.get('coveragePaymentType') != null) {
23                bodyMap.put('coveragePaymentType', String.valueOf(inputMap.get('coveragePaymentType')));
24            }
25            if (inputMap.containsKey('adjustedAmount') && inputMap.get('adjustedAmount') != null) {
26                bodyMap.put('adjustedAmount', String.valueOf(inputMap.get('adjustedAmount')));
27            }
28        } else {
29            System.debug('⚠️ No input map found in args');
30        }
31
32        String jsonBody = JSON.serialize(bodyMap);
33        System.debug('>>> Final JSON Body: ' + jsonBody);
34
35        String str = postDataToExternalApi(bodyMap, jsonBody);
36        return outputMap.put('response', str);
37    }
38
39    public static String postDataToExternalApi(Map<String, Object> bodyMap, String jsonBody) {
40        HttpRequest request = new HttpRequest();
41        Http http = new Http();
42
43        String claimId = (String) bodyMap.get('claimId');
44        String claimCoverageId = (String) bodyMap.get('claimCoverageId');
45
46        bodyMap.remove('claimId');
47        bodyMap.remove('claimCoverageId');
48
49        jsonBody = JSON.serialize(bodyMap);
50        System.debug('>>> Final JSON Body: ' + jsonBody);
51
52        if (String.isBlank(claimId) || String.isBlank(claimCoverageId)) {
53            String errorMsg = 'Missing required fields - claimId: ' + claimId + ', claimCoverageId: ' + claimCoverageId;
54            System.debug('⚠️ ' + errorMsg);
55            return 'Error: ' + errorMsg;
56        }
57
58        // ✅ Build endpoint dynamically
59        String endpoint = 'callout:invokeUW/services/data/v65.0/connect/insurance/claims/'
60                          + claimId + '/coverages/' + claimCoverageId + '/payment-details';
61        System.debug('>>> Dynamic Endpoint: ' + endpoint);
62
63        request.setEndpoint(endpoint);
64        request.setMethod('POST');
65        request.setHeader('Content-Type', 'application/json');
66        request.setTimeout(120000); // 2 mins
67        request.setBody(jsonBody);
68
69        try {
70            HttpResponse response = http.send(request);
71
72            System.debug('>>> Status Code: ' + response.getStatusCode());
73            System.debug('>>> Response Body: ' + response.getBody());
74
75            return response.getBody();
76        } catch (Exception e) {
77            System.debug('Exception: ' + e.getMessage());
78            return 'Exception: ' + e.getMessage();
79        }
80    }
81
82    // Sample test method
83    public static void testCreateCCPD() {
84        Map<String, Object> args = new Map<String, Object>();
85        Map<String, Object> input = new Map<String, Object>();
86        Map<String, Object> output = new Map<String, Object>();
87
88        input.put('claimId', '0Zkxx000000009hCAA');
89        input.put('claimCoverageId', '0kPxx000000006TEAQ');
90        input.put('claimedAmount', '1200.0');
91        input.put('coveragePaymentType', 'Loss');
92        input.put('adjustedAmount', '1200.0');
93
94        args.put('input', input);
95        args.put('output', output);
96
97        CreateCCPDIPTest1 test = new CreateCCPDIPTest1();
98        test.call('createCCPD', args);
99    }
100}