---
title: Create
slug: netsuite/XN_c-create
description: Learn how to create a Customer Payment in NetSuite by using the "createCustomerPayment" action and passing payment data through the "customerPayments" field. This document provides step-by-step instructions and example code to help you set various fields 
docTags: 
createdAt: 2021-12-14T12:51:15.000Z
---

To create a Customer Payment in NetSuite, use action as "createCustomerPayment" and pass the Customer Payment data in the requestJSON under "customerPayments".

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

The following is an example of creating a Customer Payment where we are setting every possible field (See[﻿](https://app.archbee.io/docs/-LIHUUnv_7XNQrtzHsKkC/hnjmkN99QxWdEafyYIFSq)﻿ [Customer Payment](docId\:L_S8oFAL1497WkaPqKUlH)  the available fields).  The response will return the response back from NetSuite, which includes the NetSuite Customer Payment Id (internalId), plus the newly created Salesforce ﻿Customer Payment Id (salesforceID)

:::CodeblockTabs
Request

```apex
//Create a Map to store all the data of a Payment
Map<String, Object> nsCustomerPayment = new Map<String, Object>();
    nsCustomerPayment.put('classification', new Map<String, Object>{'internalId'=>'5'});
    nsCustomerPayment.put('currencyRecord', new Map<String, Object>{'internalId'=>'1'});
    nsCustomerPayment.put('department', new Map<String, Object>{'internalId'=>'2'});
    nsCustomerPayment.put('location', new Map<String, Object>{'internalId'=>'1'});
    
    nsCustomerPayment.put('customer', new Map<String, Object>{'internalId'=>'63587'});
    nsCustomerPayment.put('memo', 'Payment 25');
    nsCustomerPayment.put('tranDate', DateTime.newInstance(2020, 09, 07).getTime()/1000);
    nsCustomerPayment.put('payment', '97006');
        
    //  Initializing the Payment Custom Fields
    List<Object> paymentCustomFieldList = new List<Object>();
    Map<String,Object> paymentCustomField = new Map<String,Object>();
        paymentCustomField.put('fieldType', 'select');
        paymentCustomField.put('scriptId', 'custbody_customlist');
        paymentCustomField.put('valueLookup', new Map<String,Object>{'internalId'=>'2'});
        paymentCustomFieldList.add(paymentCustomField);

//  Adding the Payment Custom Fields
    nsCustomerPayment.put('customFieldList', new Map<String,Object>{'customField'=>paymentCustomFieldList});

//  Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
    requestJSONMap.put('customerPayments', new List<Object>{nsCustomerPayment});
    String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
    reqObj.put('version', '1.0');
    reqObj.put('action', 'createCustomerPayment');
    reqObj.put('requestJSON', reqJSON);

//  Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);

```

Response

```json
{
  action=createCustomerPayment,
  timestamp=1639492143080,
  validRequest=true,
  version=1.0,
  responseJSON={
    "errors":[],
    "status":"200",
    "customerPayments": [
      {
        "undepFunds": true,
        "unapplied": 96770.0,
        "tranId": "113",
        "tranDate": 1599364800,
        "subsidiary": {
          "type": null,
          "name": "Parent Company",
          "internalId": "1",
          "externalId": null
        },
        "status": "Not Deposited",
        "salesforceID": "a0L1m000003Ee6PEAS",
        "payment": 97006.0,
        "memo": "Payment 25",
        "location": {
          "type": null,
          "name": "test : Atlanta west",
          "internalId": "1",
          "externalId": null
        },
        "lastModifiedDate": 1648039356,
        "internalId": "97006",
        "externalId": null,
        "exchangeRate": 1.0,
        "department": {
          "type": null,
          "name": "Sales",
          "internalId": "2",
          "externalId": null
        },
        "customForm": {
          "type": null,
          "name": "Custom Customer Payment",
          "internalId": "105",
          "externalId": null
        },
        "customFieldList": null,
        "customer": {
          "type": null,
          "name": "CUST1022AT Spider Man",
          "internalId": "63587",
          "externalId": null
        },
        "currencyName": "US Dollars",
        "createdDate": 1648032330,
        "classification": {
          "type": null,
          "name": "Corporate Sales",
          "internalId": "5",
          "externalId": null
        },
        "applyList": null,
        "applied": 0.0
      }
    ],
  } 
}
```
:::



