Anticheat methods
Recommended sequence of actions when working with transactions
Get response about a completed transaction from the payment system.
Either send data about the received transaction for verification by calling devtodev anti-cheat methods or use your own tools for transaction verification.
If the transaction has successfully passed verification, perform the Payment event. If the transaction has not passed verification, do not perform the Payment event.
Payment Validation
The devtodev service allows you to validate transactions to prevent fraud from influencing your statistics. For this, you need to integrate DTDAntiCheat
module.
We strongly discourage you from using verification results for deciding on allowing or denying users to receive their purchases! We do not recommend to mark users as cheaters based on the results of this verification! Employ this method exclusively for preventing fraud transaction data from being sent to devtodev!
To validate the transaction you can use the verifyPayment(completionHandler: @escaping (DTDVerifyResponse) -> Void)
method immediately during the transaction processing, e.g.:
extension Purchases: SKPaymentTransactionObserver {
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction in transactions {
switch transaction.transactionState {
case .purchased:
DTDAntiCheat.verifyPayment { response in
switch response.receiptStatus {
case .receiptInternalError:
// your code
break
case .receiptValid:
// your code
break
case .receiptSandbox:
// your code
break
case .receiptServerError:
// your code
break
case .receiptNotValid:
// your code
break
@unknown default: break
}
SKPaymentQueue.default().finishTransaction(transaction)
}
case .restored:
SKPaymentQueue.default().finishTransaction(transaction)
case .failed:
SKPaymentQueue.default().finishTransaction(transaction)
default:
break
}
}
}
}
DTDVerifyResponse
DTDVerifyResponse
The DTDVerifyResponse object returned while validating the transaction has two properties:
Property
Description
receiptStatus
Enum type DTDReceiptStatus
that represents the result of the transaction validation.
verificationResult
Additional information from the validation server.
DTDReceiptStatus
DTDReceiptStatus
The enum type returned as a result of validation can receive the following values:
Value
Description
receiptValid
The payment is valid, the transaction is genuine.
receiptNotValid
The payment is invalid, the transaction may be a duplicate or fraud.
receiptServerError
Server error when validating the payment.
receiptSandbox
Test payment.
receiptInternalError
Internal SDK error.
Last updated
Was this helpful?