P
P
Pavel2013-11-25 17:29:33
Windows phone
Pavel, 2013-11-25 17:29:33

How to check the validity of a purchase made in the windows phone store?

There is a client application where the user can purchase the product. There is a server where I want to check if the product was actually purchased. From the MS guides it is not entirely clear how to do this. There is an understanding that the receipt needs to be transferred to the server. Receiving a receipt inside the application

string xml = await Store.CurrentApp.GetProductReceiptAsync(pID);

then I send it to the server. Rectipt looks like
<?xml version="1.0"?><Receipt Version="1.0" CertificateId="A656B9B1B3AA509EEA30222E6D5E7DBDA9822DCD" xmlns="http://schemas.microsoft.com/windows/2012/store/receipt">
<ProductReceipt PurchasePrice="р.0" PurchaseDate="2013-11-25T14:21:54.069Z" Id="678d1af4-f3c6-4fce-8acb-96817cb80e25" AppId="08958126-61b3-4b30-a682-8b380d9171f3" ProductId="monthsubscription" ProductType="Consumable" PublisherUserId="exKUawlE0mnZi2GIsXMG/RbWarLKP2htxIwRkmX3eQM=" PublisherDeviceId="FP7oxlZ+BIiWm5urRmBTN7WqP05maZToolIYRHf8C/E=" MicrosoftProductId="ce2e53fd-af73-4b5a-973d-53e30d3ca364" />

  <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo>
      <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
      <SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
      <Reference URI="">
        <Transforms>
        <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
        </Transforms>
        <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
        <DigestValue>AO2nKCPdWObpmxraP0pAhmRWHPilriZeFzE94FkTohU=</DigestValue>
      </Reference>
    </SignedInfo>
    <SignatureValue>V4lIg+KOJwT5E8UT7sHt15Y6W1d9g6iQydiYFCkSN4ekgfmV8ARXR4Sx6a8njfgfoaZBvC+AKQdbei35VNt8iVQ8uIduwA4gsAfZX0zcKalMP60cdeB1hXmfiCAMNQw97g8POKOBgqqKpe3+syktYPiDI2Pab9K70bOPff23DkShS08fXGXvvftjM+yprO3HcO121iShSAC3S/e/tW3+CDEzHsmgRdLbL0Pos8fp2S4S0T5lqQzsCE3cNpqMT9o+EjiUBvZNY6xUpxvm9lEFFhXRw5W2Vaz2c1rNxLpXUBpiUK5vGn8uWuIC/uRI/1O2gL1gZhYXmqxOoUEF3PxAVA==
    </SignatureValue>
  </Signature>
</Receipt>

How can I check on the basis of this receipt that the purchase was actually made? Do I need to get a public key? What to do with him next?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Zolotov, 2013-11-26
@SZolotov

A little different. See, first you call the method

var receipt = await Store.CurrentApp.RequestProductPurchaseAsync(productInfo.ProductId, true);

If the purchase is made, then you get the recipe and do what you need.
That is, the fact of receiving a prescription is a confirmation of purchase.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question