---
title: Update
slug: quickbooks/sw_B-update
description: Learn how to update a payment record efficiently and securely with this step-by-step document. Discover how to utilize Payment Id and Customer Id to ensure precise modifications. Explore a handy code snippet that demonstrates how to create a data map, ini
docTags: 
createdAt: 2021-12-31T06:38:46.000Z
---

The following is an example of update Payment. The Payment Id (Id) and Customer Id (Id) are required to update the payment (See [Payment](docId\:ASRn2GZJqlQI_5JeXDwaa) for the available fields).&#x20;

:::hint{type="info"}
Note:  You can only update one record at a time.

- When you want to update specific fields of an entity without affecting others, use a sparse update operation by setting sparse= 'true' in your request. This approach is more efficient and less prone to unintended changes than a full update.
:::

:::CodeblockTabs
Request

```apex
//  Create a Map to store all the data of a Customer
Map<String, Object> paymentMap = new Map<String, Object>(); 
    paymentMap.put('Id','889');
    paymentMap.put('TotalAmt','200');
    paymentMap.put('CustomerRef' , new Map<String, Object>{'value' => '226'});
	paymentMap.put('SyncToken','0');
	paymentMap.put('PrivateNote','Memo field updated');
	
// Required, make sure you add all Lines, otherwise, the payment will not be applied to any invoices.
    
//  Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
    requestJSONMap.put('payments', new List<Object>{paymentMap});
    String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
    reqObj.put('version', '1.0');
    reqObj.put('action', 'updatePayment');
    reqObj.put('requestJSON', reqJSON);
    //Required, if QuickBooks Multi-Org is enabled in Breadwinner. 
    reqObj.put('qbOrgId', '4620816365285051610');

//  Placing a request to Breadwinner Global API
Map<String, Object> respMap = breadwinner_qbo.BreadwinnerQBAPI.call(reqObj);
System.debug(respMap);
```

Response

```json
{
action=updatePayment,
responseJSON={
    "statusCode": 200,
    "payments": [
        {
            "UnappliedAmt": 200.00,
            "TxnDate": "2023-05-30",
            "TotalAmt": 200.00,
            "SyncToken": "1",
            "sparse": false,
            "PrivateNote": "Memo field updated",
            "MetaData": {
                "LastUpdatedTime": "2023-05-30T06:18:32-07:00",
                "CreateTime": "2023-05-30T04:59:07-07:00"
            },
            "Line": [
              {
               "Amount": 300, 
                "LinkedTxn": [
                 {
                  "TxnId": "67", 
                  "TxnType": "Invoice"
                 }
                ]
              }, 
            ],
            "Id": "889",
            "ExchangeRate": 1,
            "DepositToAccountRef": {
                "value": "4"
            },
            "CustomerRef": {
                "value": "226",
                "name": "John Melton"
            },
            "CurrencyRef": {
                "value": "CAD",
                "name": "Canadian Dollar"
            }
        }
    ]
},
timestamp=1685452713054,
validRequest=true,
version=1.0
}
```
:::

