Global API
...
Request
Payment
Create
1min
Here is the below example on how to to create a Payment using Breadwinners Global API.
Request
Response
1// Create a Map to store all the data of a Payment
2List<Object> paymentsList = new List<Object>();
3Map<String, Object> paymentMap = new Map<String, Object>();
4 paymentMap.put('DateString', '2021-11-11T00:00:00');
5 paymentMap.put('Amount', 50);
6 paymentMap.put('Reference', 'Test Payment');
7
8 // Initializing the Invoice
9 Map<String, Object> invoiceMap = new Map<String, Object>();
10 invoiceMap.put('InvoiceID', '93151e60-3cad-4384-a2ed-99935444a218');
11 paymentMap.put('Invoice', invoiceMap);
12
13 Map<String, Object> accountMap = new Map<String, Object>();
14 accountMap.put('Code', '880');
15 paymentMap.put('Account', accountMap);
16
17 paymentsList.add(paymentMap);
18// Initializing the RequestJSON Data to be passed.
19 Map<String, Object> reqJSONMap = new Map<String, Object>();
20 reqJSONMap.put('payments', paymentsList);
21 String reqJSON = JSON.serialize(reqJSONMap);
22
23 Map<String, Object> finalReqMap = new Map<String, Object>();
24 Map<String, Object> reqOptions = new Map<String, Object>();
25 finalReqMap.put('queryParameters', reqOptions);
26 finalReqMap.put('version', '1.0');
27 finalReqMap.put('action', 'createPayment');
28 finalReqMap.put('RequestJSON', reqJSON);
29 finalReqMap.put('skipDML', false);
30 //Required, if Xero Multi-Org is enabled in Breadwinner.
31 finalReqMap.put('xeroOrgId', '!aa00TM');
32 System.debug('Request ::: ' + finalReqMap);
33
34// Placing a request to Breadwinner Global API
35 Map<String, Object> respMap = bread_winner.BreadwinnerXeroAPI.call(finalReqMap);
36 System.debug('Response ::: ' + respMap);