Skip to content

This PHP Class is help you to verification your Apple IAP receipt-data if your server is developed by PHP.

License

Notifications You must be signed in to change notification settings

iamleehom/ios-iap-verification-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apple In App Purchase Verification With PHP

Latest Stable Version Total Downloads Latest Unstable Version License Join the chat at https://gitter.im/ios-iap-verification/Lobby

This PHP Class is help you to verification your Apple IAP receipt-data if your server is developed by PHP.

Installation

It's recommended that you use Composer to install this library.

$ composer require leehom1988/ios-iap-verification-php

This will install this library and all required dependencies. This library requires PHP 5.6.0 or newer.

Usage(English)

Create an Demo.php file with the following contents:

<?php
require_once 'vendor/autoload.php';

use LeeHom\AppleInAppPurchaseVerification;

// The receipt-data from apple
$receiptData = 'MIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
// The password your own, if your IAP is not a subscription, let it empty string(like this:''), else use your own password
$password = 'baXXXXXXXXXXXXXXXXXXXXXXXXX';

$appleIAP = new AppleInAppPurchaseVerification($receiptData, $password, true);
$result = $appleIAP->validateReceipt();
echo $result;

Usage(中文)

创建一个名为Demo.php的文件,将以下内容拷贝至Demo.php文件中:

<?php
require_once 'vendor/autoload.php';

use LeeHom\AppleInAppPurchaseVerification;

// apple返回的支付参数 receipt-data
$receiptData = 'MIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
// 如果产品类型为订阅型的,请使用校验需要的密码;如果不是订阅型的产品,请将其置为空字符串
$password = 'baXXXXXXXXXXXXXXXXXXXXXXXXX';

$appleIAP = new AppleInAppPurchaseVerification($receiptData, $password, true);
$result = $appleIAP->validateReceipt();
echo $result;

View results:

  • Use PHP CLI, in the terminal windows, type the following contents:
$ php Demo.php start
  • Directly access to your Demo.php file in your browser.

Status codes:

  • 21000 The App Store could not read the JSON object you provided.
  • 21002 The data in the receipt-data property was malformed or missing.
  • 21003 The receipt could not be authenticated.
  • 21004 The shared secret you provided does not match the shared secret on file for your account. Only returned for iOS 6 style transaction receipts for auto-renewable subscriptions.
  • 21005 The receipt server is not currently available.
  • 21006 This receipt is valid but the subscription has expired. When this status code is returned to your server, the receipt data is also decoded and returned as part of the response. Only returned for iOS 6 style transaction receipts for auto-renewable subscriptions.
  • 21007 This receipt is from the test environment, but it was sent to the production environment for verification. Send it to the test environment instead.
  • 21008 This receipt is from the production environment, but it was sent to the test environment for verification. Send it to the production environment instead.

For Status codes more information, see Apple Receipt Validation Programming Guide.

Author:

If you have any question,Please be easy to contact me:

Hope it can help You, Just Enjoy It! 😁😁😁😁

  • (If you like it, Star it!️⭐⭐️)
  • (喜欢就给个星星吧!⭐️⭐)

License

The MIT License (MIT). Please see License File for more information.

About

This PHP Class is help you to verification your Apple IAP receipt-data if your server is developed by PHP.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages