| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2c.hellogtx.com/library/RazorPay/documents/ |
Upload File : |
## Customer
### Create customer
```php
$api->customer->create(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com','contact'=>'9123456780','notes'=> array('notes_key_1'=> 'Tea, Earl Grey, Hot','notes_key_2'=> 'Tea, Earl Grey… decaf'));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| name* | string | Name of the customer |
| email | string | Email of the customer |
| contact | string | Contact number of the customer |
| notes | array | A key-value pair |
**Response:**
```json
{
"id" : "cust_1Aa00000000004",
"entity": "customer",
"name" : "Gaurav Kumar",
"email" : "gaurav.kumar@example.com",
"contact" : "9123456780",
"gstin": "29XAbbA4369J1PA",
"notes":{
"notes_key_1":"Tea, Earl Grey, Hot",
"notes_key_2":"Tea, Earl Grey… decaf."
},
"created_at ": 1234567890
}
```
-------------------------------------------------------------------------------------------------------
### Edit customer
```php
$api->customer->fetch($customerId)->edit(array('name' => 'Razorpay User', 'email' => 'customer@razorpay.com','notes'=> array('notes_key_1'=> 'Tea, Earl Grey, Hot','notes_key_2'=> 'Tea, Earl Grey… decaf')));
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be updated |
| email | string | Email of the customer |
| contact | string | Contact number of the customer |
| notes | array | A key-value pair |
**Response:**
```json
{
"id": "cust_1Aa00000000003",
"entity": "customer",
"name": "Gaurav Kumar",
"email": "Gaurav.Kumar@example.com",
"contact": "9000000000",
"gstin": null,
"notes": {
"notes_key_1": "Tea, Earl Grey, Hot",
"notes_key_2": "Tea, Earl Grey… decaf."
},
"created_at": 1582033731
}
```
-------------------------------------------------------------------------------------------------------
### Fetch all customer
```php
$api->customer->all($options)
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| count | integer | number of payments to fetch (default: 10) |
| skip | integer | number of payments to be skipped (default: 0) |
**Response:**
```json
{
"entity":"collection",
"count":1,
"items":[
{
"id":"cust_1Aa00000000001",
"entity":"customer",
"name":"Gaurav Kumar",
"email":"gaurav.kumar@example.com",
"contact":"9876543210",
"gstin":"29XAbbA4369J1PA",
"notes":{
"note_key_1":"September",
"note_key_2":"Make it so."
},
"created_at ":1234567890
}
]
}
```
-------------------------------------------------------------------------------------------------------
### Fetch a customer
```php
$api->customer->fetch($customerId)
```
**Parameters:**
| Name | Type | Description |
|---------------|-------------|---------------------------------------------|
| customerId* | string | The id of the customer to be fetched |
**Response:**
```json
{
"id" : "cust_1Aa00000000001",
"entity": "customer",
"name" : "Saurav Kumar",
"email" : "Saurav.kumar@example.com",
"contact" : "+919000000000",
"gstin":"29XAbbA4369J1PA",
"notes" : [],
"created_at ": 1234567890
}
```
-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
<br>
<br>
**For reference click [here](https://razorpay.com/docs/api/customers/)**