1. Go to this page and download the library: Download zdk/applestore 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/ */
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionRenewed;
class AutoRenewSubscription
{
/**
* @param SubscriptionRenewed $event
*/
public function handle(SubscriptionRenewed $event)
{
// do some stuff
}
}
use \Imdhemy\Purchases\Facades\Product;
use \Imdhemy\GooglePlay\Products\ProductPurchase;
$itemId = 'product_id';
$token = 'purchase_token';
Product::googlePlay()->id($itemId)->token($token)->acknowledge();
// You can optionally submit a developer payload
Product::googlePlay()->id($itemId)->token($token)->acknowledge("your_developer_payload");
/** @var ProductPurchase $productReceipt */
$productReceipt = Product::googlePlay()->id($itemId)->token($token)->get();
use Imdhemy\AppStore\Receipts\ReceiptResponse;
use \Imdhemy\Purchases\Facades\Product;
$receiptData = 'the_base64_encoded_receipt_data';
/** @var ReceiptResponse $receiptResponse */
$receiptResponse = Product::appStore()->receiptData($receiptData)->verifyReceipt();
use Imdhemy\GooglePlay\Subscriptions\SubscriptionPurchase;
use Imdhemy\Purchases\Facades\Subscription;
$itemId = 'product_id';
$token = 'purchase_token';
Subscription::googlePlay()->id($itemId)->token($token)->acknowledge();
// You can optionally submit a developer payload
Subscription::googlePlay()->id($itemId)->token($token)->acknowledge("your_developer_payload");
/** @var SubscriptionPurchase $subscriptionReceipt */
$subscriptionReceipt = Subscription::googlePlay()->id($itemId)->token($token)->get();
// You can optionally override the package name
Subscription::googlePlay()->packageName('com.example.name')->id($itemId)->token($token)->get();
use Imdhemy\Purchases\Facades\Subscription;
// To verify a subscription receipt
$receiptData = 'the_base64_encoded_receipt_data';
$receiptResponse = Subscription::appStore()->receiptData($receiptData)->verifyReceipt();
// If the subscription is an auto-renewable one,
//call the renewable() method before the trigger method verifyReceipt()
$receiptResponse = Subscription::appStore()->receiptData($receiptData)->renewable()->verifyReceipt();
// or you can omit the renewable() method and use the verifyRenewable() method instead
$receiptResponse = Subscription::appStore()->receiptData($receiptData)->verifyRenewable();
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionRenewed;
class AutoRenewSubscription
{
/**
* @param SubscriptionRenewed $event
*/
public function handle(SubscriptionRenewed $event)
{
// The following data can be retrieved from the event
$notification = $event->getServerNotification();
$subscription = $notification->getSubscription();
$uniqueIdentifier = $subscription->getUniqueIdentifier();
$expirationTime = $subscription->getExpiryTime();
// The following steps are up to you, this is only an imagined scenario.
$user = $this->findUserBySubscriptionId($uniqueIdentifier);
$user->getSubscription()->setExpirationTime($expirationTime);
$user->save();
$this->notifyUserAboutUpdate($user);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.