PHP code example of abraovic / ios-receipt-validator

1. Go to this page and download the library: Download abraovic/ios-receipt-validator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

abraovic / ios-receipt-validator example snippets



abraovic\iOSReceiptValidator\Validate;
use abraovic\iOSReceiptValidator\Exception\iOSReceiptValidatorException;

try {
    $receipt = 'put-your-receipt-here';
    $sharedSecret = 'put-your-secret-here-if-any';

    // for sandbox mode
    Validate::$dev = true;

    $validate = new Validate($receipt, $sharedSecret);
    $response = $validate->execute(); // returns Response object
} catch (iOSReceiptValidatorException $e) {
    echo 'Caught exception: ' . $e->getMessage() . "\n";
}


$response->getStatus();
$response->getReceipt();  // returns Receipe object
$response->getLatestReceipt();
$response->getLatestReceiptInfo(); // returns Receipe object

$receipt->getBundleId();
$receipt->getApplicationVersion();
$receipt->getInApp();
$receipt->getOriginalApplicationVersion();
$receipt->getCreationDate();
$receipt->getOriginalPurchaseDate();