PayClaimCoveragePaymentDetail(claimId, coverageId, paymentDetailId, PayClaimCoveragePaymentDetailInput)

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, ConnectApi.PayClaimCoveragePaymentDetailInputRepresentation PayClaimCoveragePaymentDetailInput)

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.

PayClaimCoveragePaymentDetailInput

Return Value 

Type: ConnectApi.PayClaimCoveragePaymentDetailRep

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

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

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}