简体   繁体   中英

How to get Metro in-app purchases to work?

I'm trying to enable in-app purchase in my Metro app, but it doesn't seem to be working at all. I'm getting no error, and the return value is an empty string. My code looks like this:

await CurrentAppSimulator.RequestProductPurchaseAsync("bonus", false);
if (!licenseInformation.ProductLicenses["bonus"].IsActive) {
     error="purchase didn't work?";
}

And I get the error. I made sure to have the WindowsStoreProxy.xml file. It looks something like this.

    <Product ProductId="bonus" LicenseDuration="10">
        <MarketData xml:lang="en-us">
            <Name>Bonus pretend feature</Name>
            <Price>1.00</Price>
            <CurrencySymbol>$</CurrencySymbol>
            <CurrencyCode>USD</CurrencyCode>
        </MarketData>
    </Product>
    ...
  <LicenseInformation>
    <App>
        <IsActive>true</IsActive>
        <IsTrial>true</IsTrial>
    </App>
    <Product ProductId="bonus">
        <IsActive>false</IsActive>
    </Product>
  </LicenseInformation>

I think this file's read because if I put "true" under , then my app sees this particular product as purchased. I checked the documentation and it looks like I'm doing everything there.

When the code calls RequestProductPurchaseAsync, I get a dialog asking me to choose a return value. I pick S_OK, then click on Continue. I get an empty string as return value. The thing is, I'm getting the same outcome regardless of the string I put in as the first argument.

I must be missing something. What am I doing wrong? How do I diagnose this thing?

EDIT: Apparently the trick to make this work is to make sure your app isn't in trial mode - which is the default.

But how do diagnose this thing? How do I get error messages when things are going wrong, how do I get this API to tell me helpful errors like "purchase failed because app is in trial mode"?

See I had a fight over this issue with others also. i have implemented the code and my app is up in the store also and there's no complaint about it ... I'll explain step by step

1 -> I hope you are familiar with the code from the link In app purchase

2 -> you need to make the app live by default. You cannot complete the same in the trial mode ... running from developer machine.

3 -> Once this part of the code

await CurrentAppSimulator.RequestProductPurchaseAsync("product1"); 

and also change currentappsimulator to currentapp when live.

Is executed the entire process in handled by windows store.

4 -> If the product for in-app purchase is not there on store(you need to list all the in app purchase product while uploading the app to the store) it will automatically give an error that product not there.

5 -> if there's no credit card info then it will give an error message on its own..

ALL these are handled by windows store you just need the app up there with all the in app purchase. Now what's the financial deal between the client app (your app)and windows store I cant say there's some % of money as in any other business that you need to google out.

Reason for not being available in trial version: If they give us owr very own way to deduct money from some ones accnt then a trial version app distributed over a powershell file and will even help in in app purchase is so not right and legal also :)

No one believed me last time I stopped answering such question you can go ahead and explore more if you want to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM