---
title: Create
slug: xero/Fphk-create
description: Learn how to create a payment using the Breadwinners Global API with this comprehensive document. It includes a step-by-step guide on creating a Map to store payment data, initializing invoice and account information, constructing the requestJSON data, an
docTags: 
createdAt: 2021-12-22T07:42:57.000Z
---

Here is the below example on how to to create a Payment using Breadwinners Global API.

:::CodeblockTabs
Request

```apex
//  Create a Map to store all the data of a Payment
List<Object> paymentsList = new List<Object>();
Map<String, Object> paymentMap = new Map<String, Object>();
    paymentMap.put('DateString', '2021-11-11T00:00:00');
    paymentMap.put('Amount', 50);
    paymentMap.put('Reference', 'Test Payment');

    //  Initializing the Invoice
    Map<String, Object> invoiceMap = new Map<String, Object>();
    invoiceMap.put('InvoiceID', '93151e60-3cad-4384-a2ed-99935444a218');
    paymentMap.put('Invoice', invoiceMap);

    Map<String, Object> accountMap = new Map<String, Object>();
    accountMap.put('Code', '880');
    paymentMap.put('Account', accountMap);

    paymentsList.add(paymentMap);
//  Initializing the RequestJSON Data to be passed.
    Map<String, Object> reqJSONMap = new Map<String, Object>(); 
    reqJSONMap.put('payments', paymentsList); 
    String reqJSON = JSON.serialize(reqJSONMap); 

    Map<String, Object> finalReqMap = new Map<String, Object>(); 
    Map<String, Object> reqOptions = new Map<String, Object>(); 
    finalReqMap.put('queryParameters', reqOptions); 
    finalReqMap.put('version', '1.0'); 
    finalReqMap.put('action', 'createPayment'); 
    finalReqMap.put('RequestJSON', reqJSON); 
    finalReqMap.put('skipDML', false); 
    //Required, if Xero Multi-Org is enabled in Breadwinner. 
    finalReqMap.put('xeroOrgId', '!aa00TM'); 
    System.debug('Request ::: ' + finalReqMap);

//  Placing a request to Breadwinner Global API
    Map<String, Object> respMap = bread_winner.BreadwinnerXeroAPI.call(finalReqMap);
    System.debug('Response ::: ' + respMap);
```

Response

```json
{
   action=createPayment,
   responseJSON={
       "statusCode":200,
       "payments":[
         {
            "UpdatedDateUTC":"/Date(1640247312807+0000)/",
            "Status":"AUTHORISED",
            "SalesforceRecordId":'a056O00005CgjIg',
            "Reference":"Test Payment",
            "PaymentType":"ACCRECPAYMENT",
            "PaymentID":"731c9d1e-4669-42d4-b369-508a293d1429",
            "IsReconciled":false,
            "Invoice":{
               "Type":"ACCREC",
               "Payments":null,
               "LineItems":[
                  {
                     "UnitAmount":100.00,
                     "Tracking":[
                        
                     ],
                     "TaxType":"OUTPUT",
                     "TaxAmount":0.00,
                     "Quantity":10.0000,
                     "LineItemID":"883a96f4-6ab8-4241-9822-4aa38c700b5b",
                     "LineAmount":1000.00,
                     "ItemCode":null,
                     "DiscountRate":null,
                     "Description":"Line Item Description Updated",
                     "AccountCode":"200"
                  }
               ],
               "IsDiscounted":false,
               "InvoiceNumber":"INV-0007",
               "InvoiceID":"93151e60-3cad-4384-a2ed-99935444a218",
               "HasErrors":false,
               "CurrencyCode":"INR",
               "CreditNotes":null,
               "Contact":{
                  "Name":"Breadwinner Inc1",
                  "ContactStatus":null,
                  "ContactID":"f3044b57-fa66-4a8c-9bfe-7a4638764adf"
               },
               "AmountPaid":110.00,
               "AmountDue":890.00
            },
            "HasAccount":true,
            "DateVariable":"/Date(1640217600000+0000)/",
            "CurrencyRate":1.0000000000,
            "CreditNote":null,
            "BatchPaymentID":null,
            "BatchPayment":null,
            "BankAmount":50.00,
            "Amount":50.00,
            "Account":{
               "Code":"880",
               "AccountID":"72bae77e-149a-4d3b-8dac-06bfca1dd3e4"
            }
         }
      ],
      "errors":[
         
      ]
   },
   timestamp=1636643112614,
   validRequest=true,
   version=1.0
}
```
:::

