Newer Version Available

This content describes an older version of this product. View Latest

CancelClaimCoveragePaymentDetail(claimId, coverageId, paymentDetailId)

Cancel payment for a claim coverage payment detail record.

API Version

65.0

Requires Chatter

No

Signature

public static ConnectApi.CancelClaimCoveragePaymentDetailRep CancelClaimCoveragePaymentDetail(String claimId, String coverageId, String paymentDetailId)

Parameters

claimId
Type: String
ID of the claim.
coverageId
Type: String
ID of the claim coverage record.
paymentDetailId
Type: String
ID of the claim coverage payment detail record.

Example

Use this Apex sample to cancel a claim coverage payment detail record using the Cancel Claim Coverage Payment Detail API. This example shows how to invoke the Connect API method ConnectApi.InsuranceClaimFamily.CancelClaimCoveragePaymentDetail() and handle success and error responses in Apex.

Class Definition
This Apex example shows how to cancel a specific claim coverage payment detail for a given claim and coverage.
1
2public with sharing class CancelClaimCoveragePaymentDetailCallable 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 == 'cancelClaimCoveragePaymentDetail') {
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 claimCoveragePaymentDetailId = (String) inputMap.get('claimCoveragePaymentDetailId');
15            
16            System.debug('Start of connect API call to cancel claim coverage payment detail');
17            System.debug('Claim ID: ' + claimId);
18            System.debug('Claim Coverage ID: ' + claimCoverageId);
19            System.debug('Claim Coverage Payment Detail ID: ' + claimCoveragePaymentDetailId);
20            
21            // Initialize the output representation
22            ConnectApi.CancelClaimCoveragePaymentDetailRep paymentDetailData;
23            
24            try {
25                // Call the Connect API resource using the correct method signature
26                // Endpoint: /connect/insurance/claims/{claimId}/coverages/{coverageId}/payment-details/{paymentDetailId}/cancelPayment
27                paymentDetailData = ConnectApi.InsuranceClaimFamily.cancelClaimCoveragePaymentDetail(
28                    claimId, 
29                    claimCoverageId, 
30                    claimCoveragePaymentDetailId
31                );
32                
33                System.debug('Claim coverage payment detail cancelled successfully: ' + paymentDetailData);
34                
35                // Add results to output map
36                outputMap.put('paymentDetailData', paymentDetailData);
37                outputMap.put('isCancelled', paymentDetailData.isSuccess);
38                
39                // Handle errors if present
40                if (paymentDetailData.errors != null && !paymentDetailData.errors.isEmpty()) {
41                    outputMap.put('errors', paymentDetailData.errors);
42                    System.debug('Errors found: ' + paymentDetailData.errors);
43                }
44            } catch (Exception e) {
45                System.debug('Error while canceling claim coverage payment detail: ' + e.getMessage());
46                outputMap.put('error', e.getMessage());
47                outputMap.put('isCancelled', false);
48            }
49            
50            return paymentDetailData;
51        }
52        
53        // Return null if the action is unrecognized
54        return null;
55    }
56}
Usage Example
Use the CancelClaimCoveragePaymentDetailCallable class to execute the cancelClaimCoveragePaymentDetail action and process the result.
1CancelClaimCoveragePaymentDetailCallable callable = new CancelClaimCoveragePaymentDetailCallable();
2
3// Prepare the input arguments
4Map<String, Object> input = new Map<String, Object>();
5input.put('claimId', '0ZkXK00000000010AA');                    // Claim ID
6input.put('claimCoverageId', '0kPXK00000000012AA');             // Claim Coverage ID  
7input.put('claimCoveragePaymentDetailId', '0l2XK000000006TYAQ'); // Claim Coverage Payment Detail ID
8
9// Prepare output and argument maps
10Map<String, Object> output = new Map<String, Object>();
11Map<String, Object> args = new Map<String, Object>();
12args.put('input', input);
13args.put('output', output);
14
15// Call the 'cancelClaimCoveragePaymentDetail' action
16Object result = callable.call('cancelClaimCoveragePaymentDetail', args);
17
18// Check the result
19if (result != null) {
20    System.debug('Claim coverage payment detail processed successfully: ' + result);
21    
22    // Access the processed payment detail data
23    ConnectApi.CancelClaimCoveragePaymentDetailRep paymentDetailData = 
24        (ConnectApi.CancelClaimCoveragePaymentDetailRep) result;
25    
26    // Process the result
27    System.debug('Payment Detail Data: ' + paymentDetailData);
28    
29    if (paymentDetailData.isSuccess) {
30        System.debug('Cancellation was successful');
31    } else {
32        System.debug('Cancellation failed');
33        if (paymentDetailData.errors != null) {
34            System.debug('Error details: ' + paymentDetailData.errors);
35        }
36    }
37} else {
38    System.debug('Error occurred: ' + output.get('error'));
39}