# Subscriber Transactions

After each subscription payment, a default customerReferenceCode is generated for the customer whose details are provided. Currently, this reference code can only be used to retrieve and update customer information.

Customers are created or updated based on the email parameter. For example, a unique reference code, let's say 'A', is generated for a customer when a subscription is created with email address 'X'. If the email address 'X' is used in another subscription, the customer details sent in the request are updated, and once again, a unique reference code 'A' is generated.

There are 3 different methods that can be used on subscribers.

1. [Update Subscriber](#post-v2-subscription-customers-customerreferencecode)
2. [Get Subscriber](#get-v2-subscription-customers-customerreferencecode)
3. [List of Subscribers](#get-v2-subscription-customers)

## Update Subscriber

> Update all details of a subscriber via API. Provide the subscriber's \*\*customerReferenceCode\*\* as a path parameter and include the fields to be updated in the request body. At least \*\*one field\*\* in the body is required; only the provided fields will be updated.<br>

```json
{"openapi":"3.0.3","info":{"title":"Subscription - Subscriber Management","version":"1.1.0"},"servers":[{"url":"https://api.iyzipay.com","description":"iyzico API"}],"paths":{"/v2/subscription/customers/{customerReferenceCode}":{"post":{"summary":"Update Subscriber","description":"Update all details of a subscriber via API. Provide the subscriber's **customerReferenceCode** as a path parameter and include the fields to be updated in the request body. At least **one field** in the body is required; only the provided fields will be updated.\n","tags":["Subscription"],"parameters":[{"$ref":"#/components/parameters/AuthHeader"},{"$ref":"#/components/parameters/ContentTypeHeader"},{"name":"customerReferenceCode","in":"path","required":true,"schema":{"type":"string"},"description":"Subscriber reference code."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerUpdateRequest"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerUpdateResponse"}}}},"400":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"parameters":{"AuthHeader":{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"},"description":"Authorization header, a signed hash value that starts with **IYZWSv2** and is generated in Base64 format."},"ContentTypeHeader":{"name":"Content-Type","in":"header","required":true,"schema":{"type":"string"},"description":"Request content type."}},"schemas":{"CustomerUpdateRequest":{"type":"object","description":"Fields to update. All fields are **optional**, but the body must contain at least one property.\n","minProperties":1,"properties":{"name":{"type":"string","description":"First name."},"surname":{"type":"string","description":"Last name."},"email":{"type":"string","description":"Email address."},"gsmNumber":{"type":"string","description":"GSM number. Prefer **+90** format."},"identityNumber":{"type":"string","description":"Turkish National ID Number (11 digits)."},"billingAddress":{"$ref":"#/components/schemas/CustomerAddress"},"shippingAddress":{"$ref":"#/components/schemas/CustomerAddress"}}},"CustomerAddress":{"type":"object","description":"Address information.","properties":{"address":{"type":"string","description":"Address line."},"zipCode":{"type":"string","description":"Postal/ZIP code."},"contactName":{"type":"string","description":"Contact name."},"city":{"type":"string","description":"City."},"district":{"type":"string","description":"District (if any)."},"country":{"type":"string","description":"Country."}}},"CustomerUpdateResponse":{"type":"object","properties":{"status":{"type":"string","enum":["success","failure"],"description":"Indicates the result of the request."},"systemTime":{"type":"integer","description":"The current epoch time in milliseconds at the moment of the response."},"data":{"type":"object","description":"Updated subscriber information.","properties":{"referenceCode":{"type":"string","description":"Subscriber reference code."},"createdDate":{"type":"integer","description":"Subscriber creation time (epoch ms)."},"status":{"type":"string","enum":["ACTIVE"],"description":"Record status."},"name":{"type":"string","description":"First name."},"surname":{"type":"string","description":"Last name."},"identityNumber":{"type":"string","description":"Turkish National ID Number."},"email":{"type":"string","description":"Email address."},"gsmNumber":{"type":"string","description":"GSM number."},"contactEmail":{"type":"string","description":"Contact email."},"contactGsmNumber":{"type":"string","description":"Contact GSM number."},"billingAddress":{"$ref":"#/components/schemas/CustomerAddress"},"shippingAddress":{"$ref":"#/components/schemas/CustomerAddress"}}}}},"ErrorResponse":{"type":"object","properties":{"status":{"type":"string","enum":["failure"],"description":"Indicates the request result (failure)."},"errorCode":{"type":"string","description":"Error code."},"errorMessage":{"type":"string","description":"Error message."},"systemTime":{"type":"integer","description":"The current epoch time in milliseconds at the moment of the response."}}}}}}
```

#### Sample Codes

<table data-view="cards"><thead><tr><th></th></tr></thead><tbody><tr><td><a href="https://github.com/iyzico/iyzipay-php/blob/master/samples/subscription-samples/update_customer.php">PHP</a></td></tr><tr><td><a href="https://github.com/iyzico/iyzipay-java/blob/master/src/test/java/com/iyzipay/sample/subscription/SubscriptionCustomerSample.java#L54">Java</a></td></tr><tr><td><a href="https://github.com/iyzico/iyzipay-dotnet/blob/master/Iyzipay.Samples/SubscriptionCustomerSample.cs#L68">.Net</a></td></tr><tr><td><a href="https://github.com/iyzico/iyzipay-node/blob/master/samples/IyzipaySubscriptionSamples.js#L197">Node.js</a></td></tr><tr><td><a href="https://www.postman.com/iyzico/iyzico/request/hxware5/5-3-update-customer">Postman</a></td></tr></tbody></table>

## Subscriber Detail

> Retrieve all details of a subscriber by its reference code.

```json
{"openapi":"3.0.3","info":{"title":"Subscription - Subscriber Management","version":"1.1.0"},"servers":[{"url":"https://api.iyzipay.com","description":"iyzico API"}],"paths":{"/v2/subscription/customers/{customerReferenceCode}":{"get":{"summary":"Subscriber Detail","description":"Retrieve all details of a subscriber by its reference code.","tags":["Subscription"],"parameters":[{"$ref":"#/components/parameters/AuthHeader"},{"$ref":"#/components/parameters/ContentTypeHeader"},{"name":"customerReferenceCode","in":"path","required":true,"schema":{"type":"string"},"description":"Subscriber reference code."}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerDetailResponse"}}}},"400":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"parameters":{"AuthHeader":{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"},"description":"Authorization header, a signed hash value that starts with **IYZWSv2** and is generated in Base64 format."},"ContentTypeHeader":{"name":"Content-Type","in":"header","required":true,"schema":{"type":"string"},"description":"Request content type."}},"schemas":{"CustomerDetailResponse":{"type":"object","properties":{"status":{"type":"string","enum":["success","failure"]},"systemTime":{"type":"integer","description":"The current epoch time in milliseconds at the moment of the response."},"data":{"type":"object","description":"Subscriber (customer) details.","properties":{"referenceCode":{"type":"string","description":"Subscriber reference code."},"createdDate":{"type":"integer","description":"Creation time (epoch ms)."},"status":{"type":"string","enum":["ACTIVE"],"description":"Record status."},"name":{"type":"string","description":"First name."},"surname":{"type":"string","description":"Last name."},"identityNumber":{"type":"string","description":"Turkish National ID Number."},"email":{"type":"string","description":"Subscriber email."},"gsmNumber":{"type":"string","description":"Subscriber GSM number."},"contactEmail":{"type":"string","description":"Contact email."},"contactGsmNumber":{"type":"string","description":"Contact GSM number."},"billingAddress":{"$ref":"#/components/schemas/CustomerAddress"},"shippingAddress":{"$ref":"#/components/schemas/CustomerAddress"}}}}},"CustomerAddress":{"type":"object","description":"Address information.","properties":{"address":{"type":"string","description":"Address line."},"zipCode":{"type":"string","description":"Postal/ZIP code."},"contactName":{"type":"string","description":"Contact name."},"city":{"type":"string","description":"City."},"district":{"type":"string","description":"District (if any)."},"country":{"type":"string","description":"Country."}}},"ErrorResponse":{"type":"object","properties":{"status":{"type":"string","enum":["failure"],"description":"Indicates the request result (failure)."},"errorCode":{"type":"string","description":"Error code."},"errorMessage":{"type":"string","description":"Error message."},"systemTime":{"type":"integer","description":"The current epoch time in milliseconds at the moment of the response."}}}}}}
```

#### Sample Codes

<table data-view="cards"><thead><tr><th></th></tr></thead><tbody><tr><td><a href="https://github.com/iyzico/iyzipay-php/blob/master/samples/subscription-samples/retrieve_customer.php">PHP</a></td></tr><tr><td><a href="https://github.com/iyzico/iyzipay-java/blob/master/src/test/java/com/iyzipay/sample/subscription/SubscriptionCustomerSample.java#L89">Java</a></td></tr><tr><td><a href="https://github.com/iyzico/iyzipay-dotnet/blob/master/Iyzipay.Samples/SubscriptionCustomerSample.cs#L122">.Net</a></td></tr><tr><td><a href="https://github.com/iyzico/iyzipay-node/blob/master/samples/IyzipaySubscriptionSamples.js#L233">Node.js</a></td></tr><tr><td><a href="https://www.postman.com/iyzico/iyzico/request/t0if1ge/5-4-retrieve-customer">Postman</a></td></tr></tbody></table>

## List Subscribers

> List all subscribers with basic details.

```json
{"openapi":"3.0.3","info":{"title":"Subscription - Subscriber Management","version":"1.1.0"},"servers":[{"url":"https://api.iyzipay.com","description":"iyzico API"}],"paths":{"/v2/subscription/customers":{"get":{"summary":"List Subscribers","description":"List all subscribers with basic details.","tags":["Subscription"],"parameters":[{"$ref":"#/components/parameters/AuthHeader"},{"$ref":"#/components/parameters/ContentTypeHeader"},{"name":"page","in":"query","required":false,"schema":{"type":"integer"},"description":"Page number to fetch."},{"name":"count","in":"query","required":false,"schema":{"type":"integer"},"description":"Number of subscribers per page."}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerListResponse"}}}},"400":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"parameters":{"AuthHeader":{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"},"description":"Authorization header, a signed hash value that starts with **IYZWSv2** and is generated in Base64 format."},"ContentTypeHeader":{"name":"Content-Type","in":"header","required":true,"schema":{"type":"string"},"description":"Request content type."}},"schemas":{"CustomerListResponse":{"type":"object","properties":{"status":{"type":"string","enum":["success","failure"]},"systemTime":{"type":"integer","description":"The current epoch time in milliseconds at the moment of the response."},"data":{"type":"object","description":"Pagination info and subscriber list.","properties":{"totalCount":{"type":"integer","description":"Total number of records."},"currentPage":{"type":"integer","description":"Current page."},"pageCount":{"type":"integer","description":"Total page count."},"items":{"type":"array","description":"Subscriber records.","items":{"type":"object","allOf":[{"$ref":"#/components/schemas/CustomerDetailResponse/properties/data"}]}}}}}},"CustomerDetailResponse":{"properties":{"data":{"type":"object","description":"Subscriber (customer) details.","properties":{"referenceCode":{"type":"string","description":"Subscriber reference code."},"createdDate":{"type":"integer","description":"Creation time (epoch ms)."},"status":{"type":"string","enum":["ACTIVE"],"description":"Record status."},"name":{"type":"string","description":"First name."},"surname":{"type":"string","description":"Last name."},"identityNumber":{"type":"string","description":"Turkish National ID Number."},"email":{"type":"string","description":"Subscriber email."},"gsmNumber":{"type":"string","description":"Subscriber GSM number."},"contactEmail":{"type":"string","description":"Contact email."},"contactGsmNumber":{"type":"string","description":"Contact GSM number."},"billingAddress":{"$ref":"#/components/schemas/CustomerAddress"},"shippingAddress":{"$ref":"#/components/schemas/CustomerAddress"}}}}},"CustomerAddress":{"type":"object","description":"Address information.","properties":{"address":{"type":"string","description":"Address line."},"zipCode":{"type":"string","description":"Postal/ZIP code."},"contactName":{"type":"string","description":"Contact name."},"city":{"type":"string","description":"City."},"district":{"type":"string","description":"District (if any)."},"country":{"type":"string","description":"Country."}}},"ErrorResponse":{"type":"object","properties":{"status":{"type":"string","enum":["failure"],"description":"Indicates the request result (failure)."},"errorCode":{"type":"string","description":"Error code."},"errorMessage":{"type":"string","description":"Error message."},"systemTime":{"type":"integer","description":"The current epoch time in milliseconds at the moment of the response."}}}}}}
```

#### Sample Codes

<table data-view="cards"><thead><tr><th></th></tr></thead><tbody><tr><td><a href="https://github.com/iyzico/iyzipay-php/blob/master/samples/subscription-samples/list_customers.php">PHP</a></td></tr><tr><td><a href="https://github.com/iyzico/iyzipay-java/blob/master/src/test/java/com/iyzipay/sample/subscription/SubscriptionCustomerListSample.java">Java</a></td></tr><tr><td><a href="https://github.com/iyzico/iyzipay-dotnet/blob/master/Iyzipay.Samples/SubscriptionCustomerSample.cs#L141">.Net</a></td></tr><tr><td><a href="https://github.com/iyzico/iyzipay-node/blob/master/samples/IyzipaySubscriptionSamples.js#L244">Node.js</a></td></tr><tr><td><a href="https://www.postman.com/iyzico/iyzico/request/aa7ianc/5-2-list-customers">Postman</a></td></tr></tbody></table>
