# What I need ?

It is necessary to has "**Paynet API KEY"** to use Paynet payment method and access services. If you are Paynet customer you can request Paynet API keys from [odeme.paynet.com.tr](https://odeme.paynet.com.tr/Account/Login?returnUrl=%2f) address. If you are not Paynet customer yet, you can request Paynet API key from <destek@paynet.com.tr> mail address.

{% hint style="warning" %}
It's necessary to has an static IP address to access Paynet services.
{% endhint %}

{% hint style="warning" %}
Both test system and live system support only **TLS 1.1** and **TLS 1.2** as security communication rule.
{% endhint %}

{% hint style="warning" %}
Use live system's URL and API Keys for using the live system.
{% endhint %}

## Secret Key

It is using for authenticate Paynet API Rest Services. The authentication type is HTTP Basic Authentication. Secret key is sent in the Authentication header of the HTTP Request. All sent requests must have an authentication header.

> ```
> Authorization: Basic sck_pcs_jECRyoZq0khnsV9elaF/SIBVvxQI+bIW
> ```

In the following example you can see how to perform basic authentication ;

```php
<?php  
			
$secret_key = "sck_pcs_rMnxDSW/43243434/YAzXXXXXXXXXXXX";
$PostURL = "https://pts-api.paynet.com.tr/v1/transaction/charge";
			
$session_id = $_REQUEST["session_id"];
$token_id 	= $_REQUEST["token_id"];
			
	
$params = array(
			'session_id' => $session_id,
			'token_id' => $token_id,
			'transaction_type' => 1,				
);
			
$options = array(
			'http' => array(
					'header'  =>"Accept: application/json; charset=UTF-8\r\n".
					"Content-type: application/json; charset=UTF-8\r\n".
					"Authorization: Basic ".$secret_key,
					'method'  => 'POST',
					'content' => json_encode($params),
					'ignore_errors' => true
					),
			);
			
$context  = stream_context_create($options);
$result = json_decode(@file_get_contents($PostURL, false, $context));
			
if($result->is_succeed == true)
{
  echo "Başarılı";
}
else
{
  echo "Başarısız";
}
			
?>
```
