2017 © Pedro Peláez
 

library ms-receipt-validator

Microsoft Store Receipt Validator

image

calibr/ms-receipt-validator

Microsoft Store Receipt Validator

  • Tuesday, December 20, 2016
  • by calibr
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Why?

This library was created to easily validate Microsoft Store purchase receipts on the server side., (*1)

Installation

composer require calibr/ms-receipt-validator, (*2)

Usage

Assume that client passes receipt to the server side and we receive it in the variable $_POST["receiptXML"], validation of the receipt will look like:, (*3)

<?php

use Calibr\MSReceiptValidator\Validator;

$validator = new Validator();
// validation(omit exception handling)
$receipt = $validator->load($_POST["receiptXML"]);

// if we are here receipt has been successfully validated and we have all receipt data in the $receipt variable

Validator#load method

Validation is run by calling load method on the Validator class instance. This method takes only one argument - receipt XML string and returns Receipt., (*4)

Validator#setPublicKey method

If you want to set public key directly you need to pass the public key string to this method., (*5)

, (*6)

Receipt object format

Field
date
deviceId
productReceipt
appReceipt
publicKey
xmlDoc (DOMDocument created from XML string)

, (*7)

Product receipt object format

Field
id
appId
productId
purchaseDate
productType
purchasePrice
expirationDate

App receipt object format

, (*8)

Field
id
appId
purchaseDate
licenseType

Error handling

Validator#load method throws an exception if an error occurs. Possible exceptions:, (*9)

  • Calibr\MSReceiptValidator\FailFetchPublicKeyException - Microsoft server didn't respond or respond with an error, see details in the exception message
  • Calibr\MSReceiptValidator\MalformedReceiptException - Receipt is invalid, see details in the exception message
  • Calibr\MSReceiptValidator\ValidationFailedException - Receipt didn't pass signature verification process

The Versions

20/12 2016

dev-master

9999999-dev

Microsoft Store Receipt Validator

  Sources   Download

The Requires

 

The Development Requires

by Avatar calibr

20/12 2016

1.2.1

1.2.1.0

Microsoft Store Receipt Validator

  Sources   Download

The Requires

 

The Development Requires

by Avatar calibr

20/12 2016

1.2.0

1.2.0.0

Microsoft Store Receipt Validator

  Sources   Download

The Requires

 

The Development Requires

by Avatar calibr

18/12 2016

1.1.0

1.1.0.0

Microsoft Store Receipt Validator

  Sources   Download

The Requires

 

The Development Requires

by Avatar calibr

18/12 2016

1.0.0

1.0.0.0

Microsoft Store Receipt Validator

  Sources   Download

The Requires

 

The Development Requires

by Avatar calibr