AppGallery IAP is a PHP library to handle AppGallery purchase verification and Server Notifications

Overview

AppGallery IAP

About

AppGallery IAP is a PHP library to handle AppGallery purchase verification and Server Notifications. This package simplifies development by allowing you to work with ready-made data objects. The package also contains SHA256WithRSA signature verification with and without PSS filling.

Installation

Use composer

composer require chfur/appgallery-iap

Usage

The AppGallery IAP verifying Order and Subscription services can be found in the Package for verification. The implementation for the laravel framework can be found in the Laravel In-App purchase package.

Notification About a Key Subscription Event

You can use server notification handling "About a Key Subscription Event" as follow:

use CHfur\AppGallery\ServerNotifications\ServerNotification;
use CHfur\AppGallery\ServerNotifications\SubscriptionNotification;
use Huawei\IAP\Response\SubscriptionResponse;

$data = [/* AppGallery ServerNotification request */];
$publicKey = 'Your AppGallery notification public key';

/** @var ServerNotification $serverNotification */
$serverNotification = ServerNotification::parse($data, $publicKey);

if($serverNotification->isSubscriptionNotification()){
    /** @var SubscriptionNotification $subscriptionNotification */
    $subscriptionNotification = $serverNotification->getSubscriptionNotification();
    
    $productId = $subscriptionNotification->getProductId();
    $environment = $subscriptionNotification->getEnvironment();

    /** @var SubscriptionResponse $subscriptionResponse */
    $subscriptionResponse = $subscriptionNotification->getSubscriptionResponse();
    
    $notificationTypeName = $subscriptionNotification->getNotificationTypeName();
    
    switch ($notificationTypeName){
        case 'RENEWAL':
            //implement your logic
            break;
    }
}

Notification About a Key Event of Pending Purchase

And also you can use server notification handling "About a Key Event of Pending Purchase" as follow:

use CHfur\AppGallery\ServerNotifications\PendingPurchaseNotification;
use CHfur\AppGallery\ServerNotifications\ServerNotification;

$data = [/* AppGallery ServerNotification request */];
$publicKey = 'Your AppGallery notification public key';

/** @var ServerNotification $serverNotification */
$serverNotification = ServerNotification::parse($data, $publicKey);

if($serverNotification->isPendingPurchaseNotification()){
    /** @var PendingPurchaseNotification $pendingPurchaseNotification */
    $pendingPurchaseNotification = $serverNotification->getPendingPurchaseNotification();
    
    $productId = $pendingPurchaseNotification->getProductId();
    $purchaseToken = $pendingPurchaseNotification->getPurchaseToken();
    $isSuccessPayment = $pendingPurchaseNotification->getNotificationType();
    
    //implement your logic
}

License

The AppGallery IAP is an open-sourced software licensed under the MIT license.

TODO

  • Implementing verification without third-party packages
You might also like...
An un-offical API wrapper for logsnag.com to get notifications and track your project events
An un-offical API wrapper for logsnag.com to get notifications and track your project events

An un-offical API wrapper for logsnag.com to get notifications and track your project events

UpDown is an uptime monitor, We send out notifications when something's wrong.

About UpDown Updown is an uptime monitor, We send out notifications when something's wrong. Be the first to know that your website is down! Reliable m

It's basically a dynamic web browser extension that can display notifications with the help of an admin-controlled dynamic API.
It's basically a dynamic web browser extension that can display notifications with the help of an admin-controlled dynamic API.

D-NOTIFIER A self controlled dynamic API based web browser extension built by Sahil Kumar How It Works? It's basically a dynamic web browser extension

A Laravel artisan based package to create the AWS (SES + SNS) infrastructure to receive email event notifications with Http/Https endpoint.
A Laravel artisan based package to create the AWS (SES + SNS) infrastructure to receive email event notifications with Http/Https endpoint.

Laravel SES Tracking Setup the AWS infrastructure to handle email events using SES/SNS and http/s endpoints with a single Laravel artisan command. Thi

Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...)

COPS COPS stands for Calibre OPDS (and HTML) Php Server. See : COPS's home for more details. Don't forget to check the Wiki. Why ? In my opinion Calib

This project processes a small database with php all on a web server. This project uses XAMPP to run the web server and the database.

PHP-introduction This project processes a small database with php all on a web server. This project uses XAMPP to run the web server and the database.

Php-rpc-server - JSON RPC server implementation for PHP.

JSON RPC Server implementation for PHP. The json-rpc is a very simple protocol. You can see this by reading the protocol specification. This library i

For server-to-server comms from PHP to CloudKit.

CloudKit-PHP Today I found this fantastic gist by Mauricevb that demonstrates how to communicate with CloudKit from PHP. I already had a previous proj

A plugin that allows you to hear the sound "Welcome to the server!" when you join the server by NhanAZ for PocketMine-MP

General A plugin that allows you to hear the sound "Welcome to the server!" when you join the server by NhanAZ for PocketMine-MP Contacts You can cont

Releases(v1.2.0)
Owner
Dmitry
Dmitry
StickWithIt is an online food ordering website created using PHP. You can view and purchase various items as well as remove items from the cart.

StickWithIt (App Name) StickWithIt is an online food ordering website created using PHP. The database used here is MYSQL database. The tool used here

Jenil Gajjar 1 May 11, 2022
Verify purchase codes right on your WordPress dashboard.

envato-purchase-code-widget Verify purchase codes right on your WordPress dashboard. Install the plugin Go to Settings->EPCW and enter your "Envato AP

null 6 Oct 28, 2021
Get mobile app version and other related data from Google Play Store, Apple App Store and Huawei AppGallery

Mobile App Version Get mobile app version and other related data from Google Play Store, Apple App Store and Huawei AppGallery. Installation Add to co

Omer Salaj 11 Mar 15, 2022
You can handle iOS Application Subscription Server Side with Laravel.

Auto Renewing Subscriptions for iOS Apps with Laravel This repository help you to handle iOS Application Subscription on server side. It provides Save

Ajay Thakkar 2 Jun 29, 2022
Fact Extraction and VERification Over Unstructured and Structured information

Repository for Fact Extraction and VERification Over Unstructured and Structured information (FEVEROUS), used for the FEVER Workshop Shared Task at EMNLP2021.

Rami 49 Dec 9, 2022
The Phar Installation and Verification Environment (PHIVE)

The Phar Installation and Verification Environment (PHIVE) Installation and verification of phar distributed PHP applications has never been this easy

null 509 Dec 29, 2022
PHP library to handle IPv4, IPv6 and IP ranges

IPLib - Handle IPv4, IPv6 and IP ranges Introduction IPLib is a modern, PSR-compliant, test-driven IP addresses and subnets manipulation library. It i

Michele Locati 212 Jan 3, 2023
JSON schema models and generated code to validate and handle various data in PocketMine-MP

DataModels JSON schema models and generated code to validate and handle various data in PocketMine-MP This library uses php-json-schema-model-generato

PMMP 2 Nov 9, 2022
A bundle to handle encoding and decoding of parameters using OpenSSL and Doctrine lifecycle events.

SpecShaper Encrypt Bundle A bundle to handle encoding and decoding of parameters using OpenSSL and Doctrine lifecycle events. Features include: Master

Mark Ogilvie 48 Nov 4, 2022
A very simple way to handle self-hosted WordPress plugin updates

Simple WP Plugin Update handling A very simple way to handle self-hosted WordPress plugin updates This uses the "update_plugins_{$hostname}" filter in

Peter Viszt 5 Jun 13, 2023