PHP code example of alxmsl / appstoreclient

1. Go to this page and download the library: Download alxmsl/appstoreclient 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/ */

    

alxmsl / appstoreclient example snippets


use alxmsl\AppStore\Client;
use alxmsl\AppStore\Exception\ExpiredSubscriptionException;

/**
 * Define needed constants
 */
const PASSWORD = 'secredsharedpassword',
      SANDBOX = true,
      RECEIPT = 'MySECReT5u8sCR1Pti0NRece1Pt=';

// Create App Store client for production or sandbox
$AppStore = new Client();
$AppStore->setPassword(PASSWORD)
    ->setSandbox(SANDBOX);

// Verify subscription receipt
try {
    var_dump($AppStore->verifyReceipt(RECEIPT));
} catch (ExpiredSubscriptionException $ex) {
    var_dump($ex->getStatus());
}

use alxmsl\AppStore\Client;

/**
 * Define needed constants
 */
const SANDBOX = true,
      RECEIPT = 'MySECReTRece1Pt=';

// Create App Store client for production or sandbox
$AppStore = new Client();
$AppStore->setSandbox(SANDBOX);

// Verify purchase receipt
var_dump($AppStore->verifyReceipt(RECEIPT));