1//Create a Map to store all the data of a Payment
2Map<String, Object> nsCustomerPayment = new Map<String, Object>();
3 nsCustomerPayment.put('internalId', '97006');
4 nsCustomerPayment.put('classification', new Map<String, Object>{'internalId'=>'2'});
5 nsCustomerPayment.put('department', new Map<String, Object>{'internalId'=>'1'});
6
7 nsCustomerPayment.put('memo', 'Payment 25 update');
8 nsCustomerPayment.put('tranDate', DateTime.newInstance(2020, 11, 07).getTime()/1000);
9 nsCustomerPayment.put('payment', '91000');
10
11
12 // apply only to Approved status containing invoices and having same customer as payment
13 List<Object> paymentApplyList = new List<Object>();
14 Map<String,Object> apply = new Map<String,Object>();
15 apply.put('doc', '97807');
16 apply.put('line', '0');
17 apply.put('apply',true);
18 paymentApplyList.add(apply);
19 nsCustomerPayment.put('applyList', new Map<String,Object>{'apply'=>paymentApplyList,'replaceAll'=>false});
20// Initializing the Payment Custom Fields
21 List<Object> paymentCustomFieldList = new List<Object>();
22 Map<String,Object> paymentCustomField = new Map<String,Object>();
23 paymentCustomField.put('fieldType', 'select');
24 paymentCustomField.put('scriptId', 'custbody_customlist');
25 paymentCustomField.put('valueLookup', new Map<String,Object>{'internalId'=>'1'});
26 paymentCustomFieldList.add(paymentCustomField);
27
28// Adding the Payment Custom Fields
29 nsCustomerPayment.put('customFieldList', new Map<String,Object>{'customField'=>paymentCustomFieldList});
30
31// Initializing the RequestJSON Data to be passed.
32Map<String, Object> requestJSONMap = new Map<String, Object>();
33 requestJSONMap.put('customerPayments', new List<Object>{nsCustomerPayment});
34 String reqJSON = JSON.serialize(requestJSONMap);
35
36Map<String, Object> reqObj = new Map<String, Object>();
37 reqObj.put('version', '1.0');
38 reqObj.put('action', 'updateCustomerPayment');
39 reqObj.put('requestJSON', reqJSON);
40
41// Placing a request to Breadwinner Global API
42Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
43System.debug(resp);
44