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.

Return Value 

Type: ConnectApi.CancelClaimCoveragePaymentDetailRep

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.

1public with sharing class CancelClaimCoveragePaymentDetailCallable 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 == 'cancelClaimCoveragePaymentDetail') {
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 claimCoveragePaymentDetailId = (String) inputMap.get('claimCoveragePaymentDetailId');
14
15            System.debug('Start of connect API call to cancel claim coverage payment detail');
16            System.debug('Claim ID: ' + claimId);
17            System.debug('Claim Coverage ID: ' + claimCoverageId);
18            System.debug('Claim Coverage Payment Detail ID: ' + claimCoveragePaymentDetailId);
19
20            // Initialize the output representation
21            ConnectApi.CancelClaimCoveragePaymentDetailRep paymentDetailData;
22
23            try {
24                // Call the Connect API resource using the correct method signature
25                // Endpoint: /connect/insurance/claims/{claimId}/coverages/{coverageId}/payment-details/{paymentDetailId}/cancelPayment
26                paymentDetailData = ConnectApi.InsuranceClaimFamily.cancelClaimCoveragePaymentDetail(
27                    claimId,
28                    claimCoverageId,
29                    claimCoveragePaymentDetailId
30                );
31
32                System.debug('Claim coverage payment detail cancelled successfully: ' + paymentDetailData);
33
34                // Add results to output map
35                outputMap.put('paymentDetailData', paymentDetailData);
36                outputMap.put('isCancelled', paymentDetailData.isSuccess);
37
38                // Handle errors if present
39                if (paymentDetailData.errors != null && !paymentDetailData.errors.isEmpty()) {
40                    outputMap.put('errors', paymentDetailData.errors);
41                    System.debug('Errors found: ' + paymentDetailData.errors);
42                }
43            } catch (Exception e) {
44                System.debug('Error while canceling claim coverage payment detail: ' + e.getMessage());
45                outputMap.put('error', e.getMessage());
46                outputMap.put('isCancelled', false);
47            }
48
49            return paymentDetailData;
50        }
51
52        // Return null if the action is unrecognized
53        return null;
54    }
55}

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}