PayClaimCoveragePaymentDetail(claimId, coverageId, paymentDetailId)

Process payment for a specific claim coverage payment detail record.

API Version

65.0

Requires Chatter

No

Signature

public static ConnectApi.PayClaimCoveragePaymentDetailRep PayClaimCoveragePaymentDetail(String claimId, String coverageId, String paymentDetailId)

Parameters

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

Example

Use the PayClaimCoveragePaymentDetailCallable Apex class to trigger payment for a claim coverage payment detail record in an insurance claim. This class serves as an Apex wrapper for the Connect API endpoint: /connect/insurance/claims/{claimId}/coverages/{coverageId}/payment-details/{paymentDetailId}/pay. You can use this method to automate payment operations directly from Apex.

Class Definition
1
2public with sharing class PayClaimCoveragePaymentDetailCallable 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 == 'payClaimCoveragePaymentDetail') {
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 pay 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.PayClaimCoveragePaymentDetailRep paymentDetailData;
23            
24            // Call the Connect API to pay claim coverage payment detail
25            try {
26                // Call the Connect API resource directly using the correct method signature
27                // The endpoint is: /connect/insurance/claims/${claimId}/coverages/${coverageId}/payment-details/${paymentDetailId}/pay
28                paymentDetailData = ConnectApi.InsuranceClaimFamily.payClaimCoveragePaymentDetail(
29                    claimId, 
30                    claimCoverageId, 
31                    claimCoveragePaymentDetailId
32                );
33                
34                System.debug('Claim coverage payment detail paid successfully: ' + paymentDetailData);
35                
36                // Put the payment detail data in the output map
37                outputMap.put('paymentDetailData', paymentDetailData);
38                outputMap.put('isPaid', paymentDetailData.isSuccess);
39                
40                // Check if there are any errors
41                if (paymentDetailData.errors != null && !paymentDetailData.errors.isEmpty()) {
42                    outputMap.put('errors', paymentDetailData.errors);
43                    System.debug('Errors found: ' + paymentDetailData.errors);
44                }
45            }
46            catch (Exception e) {
47                System.debug('Error while paying claim coverage payment detail: ' + e.getMessage());
48                outputMap.put('error', e.getMessage());
49                outputMap.put('isPaid', false);
50            }
51            
52            // Return the payment detail data
53            return paymentDetailData;
54        }
55        
56        // If the action is not recognized, return null
57        return null;
58    }
59}
60// Usage Example:
61PayClaimCoveragePaymentDetailCallable callable = new PayClaimCoveragePaymentDetailCallable();
62// Prepare the input arguments
63Map<String, Object> input = new Map<String, Object>();
64// Set the required parameters
65input.put('claimId', '0Zkxx000000002ZCAQ');                    // Claim ID
66input.put('claimCoverageId', '0kPxx000000000cEAA');           // Claim Coverage ID  
67input.put('claimCoveragePaymentDetailId', '0l2xx000000002cAAA'); // Claim Coverage Payment Detail ID
68// Prepare the output map
69Map<String, Object> output = new Map<String, Object>();
70// Prepare the args map
71Map<String, Object> args = new Map<String, Object>();
72args.put('input', input);
73args.put('output', output);
74// Call the 'payClaimCoveragePaymentDetail' action
75Object result = callable.call('payClaimCoveragePaymentDetail', args);
76// Check the result
77if (result != null) {
78    System.debug('Claim coverage payment detail processed successfully: ' + result);
79    
80    // Access the processed payment detail data
81    ConnectApi.PayClaimCoveragePaymentDetailRep paymentDetailData = 
82        (ConnectApi.PayClaimCoveragePaymentDetailRep) result;
83    
84    // Process the result as needed
85    System.debug('Payment Detail Data: ' + paymentDetailData);
86    
87    // Check if the payment was successful
88    if (paymentDetailData.isSuccess) {
89        System.debug('Payment was successful');
90    } else {
91        System.debug('Payment failed');
92        if (paymentDetailData.errors != null) {
93            System.debug('Error details: ' + paymentDetailData.errors);
94        }
95    }
96} else {
97    System.debug('Error occurred: ' + output.get('error'));
98}
Usage Example
1PayClaimCoveragePaymentDetailCallable callable = new PayClaimCoveragePaymentDetailCallable();
2// Prepare the input arguments
3Map<String, Object> input = new Map<String, Object>();
4// Set the required parameters
5input.put('claimId', '0Zkxx000000002ZCAQ');                    // Claim ID
6input.put('claimCoverageId', '0kPxx000000000cEAA');           // Claim Coverage ID  
7input.put('claimCoveragePaymentDetailId', '0l2xx000000002cAAA'); // Claim Coverage Payment Detail ID
8// Prepare the output map
9Map<String, Object> output = new Map<String, Object>();
10// Prepare the args map
11Map<String, Object> args = new Map<String, Object>();
12args.put('input', input);
13args.put('output', output);
14// Call the 'payClaimCoveragePaymentDetail' action
15Object result = callable.call('payClaimCoveragePaymentDetail', args);
16// Check the result
17if (result != null) {
18    System.debug('Claim coverage payment detail processed successfully: ' + result);
19    
20    // Access the processed payment detail data
21    ConnectApi.PayClaimCoveragePaymentDetailRep paymentDetailData = 
22        (ConnectApi.PayClaimCoveragePaymentDetailRep) result;
23    
24    // Process the result as needed
25    System.debug('Payment Detail Data: ' + paymentDetailData);
26    
27    // Check if the payment was successful
28    if (paymentDetailData.isSuccess) {
29        System.debug('Payment was successful');
30    } else {
31        System.debug('Payment failed');
32        if (paymentDetailData.errors != null) {
33            System.debug('Error details: ' + paymentDetailData.errors);
34        }
35    }
36} else {
37    System.debug('Error occurred: ' + output.get('error'));
38}