1Map<String, Object> subscriptionData = new Map<String, Object>();
2
3// Required fields
4subscriptionData.put('processorCustomerId', 'processorCustomerId'); //required
5subscriptionData.put('locationId', 'locationId'); //required to Square, if not specified we are sending a request to Square to get the main Square location id.
6subscriptionData.put('processorPlanId', 'processorPlanId'); //required
7
8// Optional fields
9subscriptionData.put('processorPaymentMethodId', 'processorPaymentMethodId'); // If not specified, the collection method will be considered “send_invoice”.
10subscriptionData.put('startDate', 'startDate');
11
12// Initializing the RequestJSON Data to be passed.
13Map<String, Object> requestJSONMap = new Map<String, Object>();
14requestJSONMap.put('subscriptions', new List<Object>{subscriptionData});
15String reqJSON = JSON.serialize(requestJSONMap);
16
17Map<String, Object> reqObj = new Map<String, Object>();
18reqObj.put('version','1.0');
19reqObj.put('action','CreateSubscription');
20reqObj.put('processorId', 'processorId');
21reqObj.put('requestJSON',reqJSON);
22
23// Placing a request to Breadwinner Global API
24Map<String,Object> resp = bw_payments.BreadwinnerPaymentsAPI.call(reqObj);
25System.debug(resp);