# Anti-cheat Methods

{% hint style="danger" %}
**This generation of SDK is deprecated and is no longer supported.**\
Information about the [current version can be found here](/integration/integration-of-sdk-v2/setting-up-events/anticheat-methods.md).
{% endhint %}

## Validation of payments and time adjustments in devtodev SDK for iOS

### **Payments validation**

To be protected from fraudulent transactions, we recommend you to use devtodev Anticheat service.

Use this method, and devtodev will check the transaction's validity with the payment platform, and the response will be returned to the application.

```
[DevToDevCheat verifyPaymentWithCompletion:(void (^)(ReceiptStatus))completionBlock];
```

The result can take one of the following values:

```
typedef enum {
    ReceiptValid,
    ReceiptNotValid,
    ReceiptServerError,
    ReceiptInternalError,
    ReceiptSandbox
} ReceiptStatus;
```

In case of a successful check call the following main SDK method:

```
[DevToDev realPayment: (NSString *) transactionId withInAppPrice:(float) inAppPrice 
         andInAppName: (NSString *) inAppName andInAppCurrencyISOCode: (NSString *) inAppCurrencyISOCode];
```

If the transaction hasn’t passed verification, do not perform the Payment event.

{% hint style="warning" %}
We do not recommend to use the result of devtodev anti-cheat verification as a condition for giving or not giving in-game currency or item purchased by a user!
{% endhint %}

### **Time cheats check**

To check for time cheats call checkTime method every time when the app is being launched

```
[DevToDevCheat checkTime: (void (^)(TimeStatus status)) completionBlock];
```

The result can take one of the following values:

```
typedef enum {
    Valid,
    Forward,
    Rewind
} TimeStatus;
```

## Validation of payments and time adjustments in devtodev SDK for Android

### Payments validation

To be protected from fraudulent transactions, we recommend you to use devtodev Anticheat service

Use this method, and devtodev will check the transaction validity with the payment platform, and the response will be returned to the application.

Call following method when GooglePlay returns the transaction to your onActivityResult:

```
DevToDevCheat.verifyPayment(String receipt, String signature, String publicKey, 
                            OnVerifyListener onVerifyListener);
```

You can get sharedSecret key here:

1. Go to the Google Play Developer Console and sign in. Make sure that you sign in to the account from which the application you are licensing is published (or will be published).
2. In the application details page, locate the Services & APIs link and click it.
3. In the Services & APIs page, locate the Licensing & In-App Billing section.

Your public key for licensing is given in the Your License Key For This Application field.

The result can take one of the following values:

```
public enum VerifyStatus {	
                           Valid,
                           Invalid,
                           InternalError,
                           ServerError
                         };
```

In case of a successful check call following the main SDK method:

```
DevToDev.realPayment(String pPaymentId, float pInAppPrice, String pInAppName, String pInAppCurrencyISOCode);
```

If the transaction hasn’t passed verification, do not perform the Payment event.

{% hint style="warning" %}
We do not recommend to use the result of devtodev anti-cheat verification as a condition for giving or not giving in-game currency or item purchased by a user!
{% endhint %}

### Time cheats check

To check for time cheats call checkTime method every time when the app is being launched

```
DevToDevCheat.verifyTime(OnTimeVerifyListener onTimeVerifyListener);
```

The result can take one of the following values:

```
public enum TimeStatus {
                         Valid,
                         Forward,
                         Rewind
                       };
```

## Validation of payments and time adjustments in devtodev SDK for Unity

### Payments validation

To be protected from fraudulent transactions, we recommend you to use devtodev Anticheat service.

Use this method, and devtodev will check the transaction validity with the payment platform, and the response will be returned to the application.

1\. Call the method for payment verification:

```
DevToDev.AntiCheat.VerifyReceipt(string receipt, string signature, string publicKey,
                                 OnReceiptVerifyCallback callback);
```

or if you are using Unity IAP plugin:

```
DevToDev.AntiCheat.VerifyReceipt(string purchasedProduct, string publicKey, OnReceiptVerifyCallback callback)
```

where OnReceiptVerifyCallback is the function like this:

```
public void onReceiptVerifyCallback (DevToDev.ReceiptVerificationStatus status) {
  Debug.Log ("Verification status" + status);
  //TODO put your source here
}
```

Here's how to find your application's public key for licensing (for Google Play platform only, for other platforms the publicKey is not used):

1. Go to the [Google Play Console](http://play.google.com/apps/publish) and sign in. Make sure that you sign in to the account from which the application you are licensing is published (or will be published).
2. In the application details page, locate the Services & APIs link and click it.
3. In the Services & APIs page, locate the Licensing & In-App Billing section. Your public key for licensing is given in the Your License Key For This Application field.

ReceiptVerificationStatus can take one of the following values:

```
public enum ReceiptVerificationStatus {
  ReceiptValid,
  ReceiptNotValid,
  ReceiptServerError,
  ReceiptSandbox,
  ReceiptInternalError    
};
```

{% hint style="info" %}
**Don't forget that it is enough to set only&#x20;*****receipt*****&#x20;field to check the payment on iOS (iTunes) or Windows/Windows Phone (Microsoft Store), and for Android (Google Play) the fields&#x20;*****signature*****&#x20;and&#x20;*****publicKey*****&#x20;should be set.**
{% endhint %}

{% hint style="warning" %}
Сore SDK should be initialized prior to the call of **VerifyPayment** function. &#x20;
{% endhint %}

2\. In case of an unsuccessful check (ReceiptNotValid result) do not call SDK method RealPayment. In other cases:&#x20;

```
DevToDev.Anatylics.RealPayment(string pPaymentId, float pInAppPrice, string pInAppName,
                               string pInAppCurrencyISOCode);
```

### Time cheats check

To check for time cheats call VerifyTime method.

1\. Call the method to time verification:

```
DevToDev.AntiCheat.VerifyTime(OnTimeVerifyCallback callback);
```

where OnTimeVerifyCallback is the function like this:

```
public void onTimeVerifyFinished (DevToDev.TimeVerificationStatus status) {
  Debug.Log ("Verification status" + status);
  //TODO put your source here
};
```

DevToDevTimeVerificationStatus can take one of the following values:

```
public enum TimeVerificationStatus {
   TimeValid,
   TimeForward,
   TimeRewind
};
```

{% hint style="warning" %}
Сore SDK should be initialized prior to the call of VerifyTime function.&#x20;
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.devtodev.com/integration/integration-of-sdk/analytics-intergation/anticheat-methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
